File: 004_yyaccept.go

package info (click to toggle)
re2c 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 50,052 kB
  • sloc: cpp: 32,477; ml: 8,279; sh: 5,265; makefile: 968; haskell: 612; python: 428; ansic: 227; javascript: 111; java: 3
file content (144 lines) | stat: -rw-r--r-- 2,024 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Code generated by re2go, DO NOT EDIT.
//line "codegen/go/004_yyaccept.re":1
//go:generate re2go $INPUT -o $OUTPUT 
package main

func Lex(str string) int {
	var cursor, marker int

	
//line "codegen/go/004_yyaccept.go":11
{
	var yych byte
	yyaccept := 0
	yych = str[cursor]
	switch (yych) {
	case 'a':
		goto yy2
	default:
		goto yy1
	}
yy1:
	cursor += 1
//line "codegen/go/004_yyaccept.re":17
	{
		return -1
	}
//line "codegen/go/004_yyaccept.go":28
yy2:
	yyaccept = 0
	cursor += 1
	marker = cursor
	yych = str[cursor]
	switch (yych) {
	case 'b':
		goto yy4
	default:
		goto yy3
	}
yy3:
//line "codegen/go/004_yyaccept.re":21
	{
		return 1
	}
//line "codegen/go/004_yyaccept.go":45
yy4:
	cursor += 1
	yych = str[cursor]
	switch (yych) {
	case 'c':
		goto yy6
	default:
		goto yy5
	}
yy5:
	cursor = marker
	switch (yyaccept) {
	case 0:
		goto yy3
	case 1:
		goto yy7
	default:
		goto yy10
	}
yy6:
	yyaccept = 1
	cursor += 1
	marker = cursor
	yych = str[cursor]
	switch (yych) {
	case 'd':
		goto yy8
	default:
		goto yy7
	}
yy7:
//line "codegen/go/004_yyaccept.re":25
	{
		return 2
	}
//line "codegen/go/004_yyaccept.go":81
yy8:
	cursor += 1
	yych = str[cursor]
	switch (yych) {
	case 'e':
		goto yy9
	default:
		goto yy5
	}
yy9:
	yyaccept = 2
	cursor += 1
	marker = cursor
	yych = str[cursor]
	switch (yych) {
	case 'f':
		goto yy11
	default:
		goto yy10
	}
yy10:
//line "codegen/go/004_yyaccept.re":29
	{
		return 3
	}
//line "codegen/go/004_yyaccept.go":107
yy11:
	cursor += 1
	yych = str[cursor]
	switch (yych) {
	case 'g':
		goto yy12
	default:
		goto yy5
	}
yy12:
	cursor += 1
//line "codegen/go/004_yyaccept.re":33
	{
		return 4
	}
//line "codegen/go/004_yyaccept.go":123
}
//line "codegen/go/004_yyaccept.re":36

}

func main() {
	if Lex("\000") != -1 {
		panic("expected error")
	}
	if Lex("a\000") != 1 {
		panic("expected 'a'")
	}
	if Lex("abc\000") != 2 {
		panic("expected 'abc'")
	}
	if Lex("abcde\000") != 3 {
		panic("expected 'abcde'")
	}
	if Lex("abcdefg\000") != 4 {
		panic("expected 'abcdefg'")
	}
}