-
Notifications
You must be signed in to change notification settings - Fork 38
/
scanner.l
221 lines (211 loc) · 7.78 KB
/
scanner.l
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
%{
#include <stdio.h>
#include "parser.h"
YY_BUFFER_STATE mybuffer;
void prepare_parse(char* msg) {
mybuffer = yy_scan_string(msg);
}
void cleanup_parse() {
yy_delete_buffer(mybuffer);
}
%}
%option stack
%x DSTR
%x SSTR
NUMBER [0-9]+
S [\t\r \n]+
AT "@"
LPAREN "("
RPAREN ")"
PIPE "|"
LT "<"
SLASH "/"
DBLSLASH "//"
BANG "!"
COLON ":"
DBLCOLON "::"
QUERY "?"
HASH "#"
COMMA {S}?","
DOT "."
DBLDOT ".."
GT {S}?">"
LBRA "["
RBRA "]"
TILDE {S}?"~"
SPLAT "*"
PLUS {S}?"+"
DASH "-"
EQ "="
LTE "<="
GTE ">="
DOLLAR "$"
STRING (['][^']*['])|(["][^"]*["])
BSLASHLIT \\(.|\n)
OTHER (.|\n)
XANCESTOR "ancestor"
XANCESTORSELF "ancestor-or-self"
XATTR "attribute"
XCHILD "child"
XDESC "descendant"
XDESCSELF "descendant-or-self"
XFOLLOW "following"
XFOLLOWSIB "following-sibling"
XNS "namespace"
XPARENT "parent"
XPRE "preceding"
XPRESIB "preceding-sibling"
XSELF "self"
XOR "or"
XAND "and"
XDIV "div"
XMOD "mod"
XCOMMENT "comment"
XTEXT "text"
XPI "processing-instruction"
XNODE "node"
CXEQUATION [0-9]+n
CXOPHE "|="
CXOPNE "!="
CXOPSTARTEQ "^="
CXOPENDEQ "$="
CXOPCONTAINS "*="
CXOPCONTAINS2 "~="
CXFIRST ":first"
CXLAST ":last"
CXNOT ":not"
CXEVEN ":even"
CXODD ":odd"
CXEQ ":eq"
CXGT ":gt"
CXLT ":lt"
CXCONTENT ":content"
CXHEADER ":header"
CXCONTAINS ":contains"
CXEMPTY ":empty"
CXHAS ":has"
CXPARENT ":parent"
CXNTHCH ":nth-child"
CXNTHLASTCH ":nth-last-child"
CXNTHTYPE ":nth-of-type"
CXNTHLASTTYPE ":nth-last-of-type"
CXFIRSTCH ":first-child"
CXLASTCH ":last-child"
CXFIRSTTYPE ":first-of-type"
CXLASTTYPE ":last-of-type"
CXONLYCH ":only-child"
CXONLYTYPE ":only-of-type"
CXINPUT ":input"
CXTEXT ":text"
CXPASSWORD ":password"
CXRADIO ":radio"
CXCHECKBOX ":checkbox"
CXSUBMIT ":submit"
CXIMAGE ":image"
CXRESET ":reset"
CXBUTTON ":button"
CXFILE ":file"
CXENABLED ":enabled"
CXDISABLED ":disabled"
CXCHECKED ":checked"
CXSELECTED ":selected"
NAME [a-zA-Z_][a-zA-Z0-9\-_]*
%%
{NUMBER} yylval.string = strdup(yytext); return NUMBER;
{S} yylval.string = strdup(yytext); return S;
{AT} yylval.string = strdup(yytext); return AT;
{LPAREN} yylval.string = strdup(yytext); return LPAREN;
{RPAREN} yylval.string = strdup(yytext); return RPAREN;
{PIPE} yylval.string = strdup(yytext); return PIPE;
{LT} yylval.string = strdup(yytext); return LT;
{SLASH} yylval.string = strdup(yytext); return SLASH;
{DBLSLASH} yylval.string = strdup(yytext); return DBLSLASH;
{BANG} yylval.string = strdup(yytext); return BANG;
{COLON} yylval.string = strdup(yytext); return COLON;
{DBLCOLON} yylval.string = strdup(yytext); return DBLCOLON;
{QUERY} yylval.string = strdup(yytext); return QUERY;
{HASH} yylval.string = strdup(yytext); return HASH;
{COMMA} yylval.string = strdup(yytext); return COMMA;
{DOT} yylval.string = strdup(yytext); return DOT;
{DBLDOT} yylval.string = strdup(yytext); return DBLDOT;
{GT} yylval.string = strdup(yytext); return GT;
{LBRA} yylval.string = strdup(yytext); return LBRA;
{RBRA} yylval.string = strdup(yytext); return RBRA;
{TILDE} yylval.string = strdup(yytext); return TILDE;
{SPLAT} yylval.string = strdup(yytext); return SPLAT;
{PLUS} yylval.string = strdup(yytext); return PLUS;
{DASH} yylval.string = strdup(yytext); return DASH;
{EQ} yylval.string = strdup(yytext); return EQ;
{LTE} yylval.string = strdup(yytext); return LTE;
{GTE} yylval.string = strdup(yytext); return GTE;
{DOLLAR} yylval.string = strdup(yytext); return DOLLAR;
{BSLASHLIT} yylval.string = strdup(yytext); return BSLASHLIT;
{XANCESTOR} yylval.string = strdup(yytext); return XANCESTOR;
{XANCESTORSELF} yylval.string = strdup(yytext); return XANCESTORSELF;
{XATTR} yylval.string = strdup(yytext); return XATTR;
{XCHILD} yylval.string = strdup(yytext); return XCHILD;
{XDESC} yylval.string = strdup(yytext); return XDESC;
{XDESCSELF} yylval.string = strdup(yytext); return XDESCSELF;
{XFOLLOW} yylval.string = strdup(yytext); return XFOLLOW;
{XFOLLOWSIB} yylval.string = strdup(yytext); return XFOLLOWSIB;
{XNS} yylval.string = strdup(yytext); return XNS;
{XPARENT} yylval.string = strdup(yytext); return XPARENT;
{XPRE} yylval.string = strdup(yytext); return XPRE;
{XPRESIB} yylval.string = strdup(yytext); return XPRESIB;
{XSELF} yylval.string = strdup(yytext); return XSELF;
{XOR} yylval.string = strdup(yytext); return XOR;
{XAND} yylval.string = strdup(yytext); return XAND;
{XDIV} yylval.string = strdup(yytext); return XDIV;
{XMOD} yylval.string = strdup(yytext); return XMOD;
{XCOMMENT} yylval.string = strdup(yytext); return XCOMMENT;
{XTEXT} yylval.string = strdup(yytext); return XTEXT;
{XPI} yylval.string = strdup(yytext); return XPI;
{XNODE} yylval.string = strdup(yytext); return XNODE;
{CXEQUATION} yylval.string = strdup(yytext); return CXEQUATION;
{CXOPHE} yylval.string = strdup(yytext); return CXOPHE;
{CXOPNE} yylval.string = strdup(yytext); return CXOPNE;
{CXOPSTARTEQ} yylval.string = strdup(yytext); return CXOPSTARTEQ;
{CXOPENDEQ} yylval.string = strdup(yytext); return CXOPENDEQ;
{CXOPCONTAINS} yylval.string = strdup(yytext); return CXOPCONTAINS;
{CXOPCONTAINS2} yylval.string = strdup(yytext); return CXOPCONTAINS2;
{CXFIRST} yylval.string = strdup(yytext); return CXFIRST;
{CXLAST} yylval.string = strdup(yytext); return CXLAST;
{CXNOT} yylval.string = strdup(yytext); return CXNOT;
{CXEVEN} yylval.string = strdup(yytext); return CXEVEN;
{CXODD} yylval.string = strdup(yytext); return CXODD;
{CXEQ} yylval.string = strdup(yytext); return CXEQ;
{CXGT} yylval.string = strdup(yytext); return CXGT;
{CXLT} yylval.string = strdup(yytext); return CXLT;
{CXCONTENT} yylval.string = strdup(yytext); return CXCONTENT;
{CXHEADER} yylval.string = strdup(yytext); return CXHEADER;
{CXCONTAINS} yylval.string = strdup(yytext); return CXCONTAINS;
{CXEMPTY} yylval.string = strdup(yytext); return CXEMPTY;
{CXHAS} yylval.string = strdup(yytext); return CXHAS;
{CXPARENT} yylval.string = strdup(yytext); return CXPARENT;
{CXNTHCH} yylval.string = strdup(yytext); return CXNTHCH;
{CXNTHLASTCH} yylval.string = strdup(yytext); return CXNTHLASTCH;
{CXNTHTYPE} yylval.string = strdup(yytext); return CXNTHTYPE;
{CXNTHLASTTYPE} yylval.string = strdup(yytext); return CXNTHLASTTYPE;
{CXFIRSTCH} yylval.string = strdup(yytext); return CXFIRSTCH;
{CXLASTCH} yylval.string = strdup(yytext); return CXLASTCH;
{CXFIRSTTYPE} yylval.string = strdup(yytext); return CXFIRSTTYPE;
{CXLASTTYPE} yylval.string = strdup(yytext); return CXLASTTYPE;
{CXONLYCH} yylval.string = strdup(yytext); return CXONLYCH;
{CXONLYTYPE} yylval.string = strdup(yytext); return CXONLYTYPE;
{CXINPUT} yylval.string = strdup(yytext); return CXINPUT;
{CXTEXT} yylval.string = strdup(yytext); return CXTEXT;
{CXPASSWORD} yylval.string = strdup(yytext); return CXPASSWORD;
{CXRADIO} yylval.string = strdup(yytext); return CXRADIO;
{CXCHECKBOX} yylval.string = strdup(yytext); return CXCHECKBOX;
{CXSUBMIT} yylval.string = strdup(yytext); return CXSUBMIT;
{CXIMAGE} yylval.string = strdup(yytext); return CXIMAGE;
{CXRESET} yylval.string = strdup(yytext); return CXRESET;
{CXBUTTON} yylval.string = strdup(yytext); return CXBUTTON;
{CXFILE} yylval.string = strdup(yytext); return CXFILE;
{CXENABLED} yylval.string = strdup(yytext); return CXENABLED;
{CXDISABLED} yylval.string = strdup(yytext); return CXDISABLED;
{CXCHECKED} yylval.string = strdup(yytext); return CXCHECKED;
{CXSELECTED} yylval.string = strdup(yytext); return CXSELECTED;
{NAME} yylval.string = strdup(yytext); return NAME;
{STRING} yylval.string = strdup(yytext); return STRING;
{OTHER} yylval.string = strdup(yytext); return OTHER;