-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrparam_lex.go
206 lines (181 loc) · 3.9 KB
/
strparam_lex.go
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//line strparam.rl:1
package strparam
import (
"fmt"
)
//line strparam_lex.go:11
const strparam_start int = 1
const strparam_first_final int = 1
const strparam_error int = 0
const strparam_en_main int = 1
//line strparam.rl:15
type lexer struct {
// It must be an array containting the data to process.
data []byte
// Data end pointer. This should be initialized to p plus the data length on every run of the machine. In Java and Ruby code this should be initialized to the data length.
pe int
// Data pointer. In C/D code this variable is expected to be a pointer to the character data to process. It should be initialized to the beginning of the data block on every run of the machine. In Java and Ruby it is used as an offset to data and must be an integer. In this case it should be initialized to zero on every run of the machine.
p int
// This must be a pointer to character data. In Java and Ruby code this must be an integer. See Section 6.3 for more information.
ts int
// Also a pointer to character data.
te int
// This must be an integer value. It is a variable sometimes used by scanner code to keep track of the most recent successful pattern match.
act int
// Current state. This must be an integer and it should persist across invocations of the machine when the data is broken into blocks that are processed independently. This variable may be modified from outside the execution loop, but not from within.
cs int
// This must be an integer value and will be used as an offset to stack, giving the next available spot on the top of the stack.
top int
}
func newLexer(data []byte) *lexer {
lex := &lexer{
data: data,
pe: len(data),
}
//line strparam_lex.go:56
{
lex.cs = strparam_start
lex.ts = 0
lex.te = 0
lex.act = 0
}
//line strparam.rl:51
return lex
}
func (lex *lexer) Lex(out *yySymType) int {
eof := lex.pe
tok := 0
//line strparam_lex.go:72
{
if (lex.p) == (lex.pe) {
goto _test_eof
}
switch lex.cs {
case 1:
goto st_case_1
case 0:
goto st_case_0
case 2:
goto st_case_2
}
goto st_out
tr0:
//line strparam.rl:75
lex.te = (lex.p) + 1
goto st1
tr3:
//line strparam.rl:59
lex.te = (lex.p) + 1
{
// fmt.Printf("ragel: openb = %q\n", string(lex.data[lex.ts:lex.te]))
tok = OPENB
{
(lex.p)++
lex.cs = 1
goto _out
}
}
goto st1
tr4:
//line strparam.rl:70
lex.te = (lex.p) + 1
{
// fmt.Printf("ragel: closeb = %q\n", string(lex.data[lex.ts:lex.te]))
tok = CLOSEB
{
(lex.p)++
lex.cs = 1
goto _out
}
}
goto st1
tr5:
//line strparam.rl:64
lex.te = (lex.p)
(lex.p)--
{
out.str = string(lex.data[lex.ts:lex.te])
// fmt.Printf("ragel: word = %q\n", string(lex.data[lex.ts:lex.te]))
tok = WORD
{
(lex.p)++
lex.cs = 1
goto _out
}
}
goto st1
st1:
//line NONE:1
lex.ts = 0
if (lex.p)++; (lex.p) == (lex.pe) {
goto _test_eof1
}
st_case_1:
//line NONE:1
lex.ts = (lex.p)
//line strparam_lex.go:131
switch lex.data[(lex.p)] {
case 32:
goto tr0
case 123:
goto tr3
case 125:
goto tr4
}
switch {
case lex.data[(lex.p)] < 65:
if 9 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 13 {
goto tr0
}
case lex.data[(lex.p)] > 90:
if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 122 {
goto st2
}
default:
goto st2
}
goto st0
st_case_0:
st0:
lex.cs = 0
goto _out
st2:
if (lex.p)++; (lex.p) == (lex.pe) {
goto _test_eof2
}
st_case_2:
switch {
case lex.data[(lex.p)] > 90:
if 97 <= lex.data[(lex.p)] && lex.data[(lex.p)] <= 122 {
goto st2
}
case lex.data[(lex.p)] >= 65:
goto st2
}
goto tr5
st_out:
_test_eof1:
lex.cs = 1
goto _test_eof
_test_eof2:
lex.cs = 2
goto _test_eof
_test_eof:
{
}
if (lex.p) == eof {
switch lex.cs {
case 2:
goto tr5
}
}
_out:
{
}
}
//line strparam.rl:79
return tok
}
func (lex *lexer) Error(e string) {
fmt.Println("error:", e)
}