OILS / _gen / _tmp / match.re2c-input.h View on Github | oilshell.org

1277 lines, 1108 significant
1
2/* Common stuff */
3
4/*!re2c
5 re2c:define:YYCTYPE = "unsigned char";
6 re2c:define:YYCURSOR = p;
7 re2c:yyfill:enable = 0; // generated code doesn't ask for more input
8*/
9
10static inline void MatchOshToken(int lex_mode, const unsigned char* line, int line_len,
11 int start_pos, int* id, int* end_pos) {
12 assert(start_pos <= line_len); /* caller should have checked */
13
14 const unsigned char* p = line + start_pos; /* modified by re2c */
15 //printf("p: %p q: %p\n", p, q);
16
17 __attribute__((unused)) const unsigned char* YYMARKER; /* why do we need this? */
18 switch (lex_mode) {
19
20 case lex_mode__Comment:
21 for (;;) {
22 /*!re2c
23 [^\n\x00]* { *id = id__Ignored_Comment; break; }
24 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
25 */
26 }
27 break;
28
29 case lex_mode__ShCommand:
30 for (;;) {
31 /*!re2c
32 [a-zA-Z_][a-zA-Z0-9_]* "+" ? "=" { *id = id__Lit_VarLike; break; }
33 [a-zA-Z_][a-zA-Z0-9_]* "[" { *id = id__Lit_ArrayLhsOpen; break; }
34 "]" "+" ? "=" { *id = id__Lit_ArrayLhsClose; break; }
35 "((" { *id = id__Op_DLeftParen; break; }
36 "[" { *id = id__Lit_LBracket; break; }
37 "]" { *id = id__Lit_RBracket; break; }
38 "*" { *id = id__Lit_Star; break; }
39 "?" { *id = id__Lit_QMark; break; }
40 "###" { *id = id__Lit_TPound; break; }
41 "..." { *id = id__Lit_TDot; break; }
42 "{" { *id = id__Lit_LBrace; break; }
43 "}" { *id = id__Lit_RBrace; break; }
44 "," { *id = id__Lit_Comma; break; }
45 "=" { *id = id__Lit_Equals; break; }
46 "@" { *id = id__Lit_At; break; }
47 "@" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Lit_Splice; break; }
48 "@[" { *id = id__Lit_AtLBracket; break; }
49 "@{." { *id = id__Lit_AtLBraceDot; break; }
50 [0-9]? [0-9]? "<" { *id = id__Redir_Less; break; }
51 [0-9]? [0-9]? ">" { *id = id__Redir_Great; break; }
52 [0-9]? [0-9]? "<" "<" { *id = id__Redir_DLess; break; }
53 [0-9]? [0-9]? "<" "<" "<" { *id = id__Redir_TLess; break; }
54 [0-9]? [0-9]? ">" ">" { *id = id__Redir_DGreat; break; }
55 [0-9]? [0-9]? "<" "<" "-" { *id = id__Redir_DLessDash; break; }
56 [0-9]? [0-9]? ">" "&" { *id = id__Redir_GreatAnd; break; }
57 [0-9]? [0-9]? "<" "&" { *id = id__Redir_LessAnd; break; }
58 [0-9]? [0-9]? "<" ">" { *id = id__Redir_LessGreat; break; }
59 [0-9]? [0-9]? ">" "|" { *id = id__Redir_Clobber; break; }
60 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" { *id = id__Redir_Less; break; }
61 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" { *id = id__Redir_Great; break; }
62 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "<" { *id = id__Redir_DLess; break; }
63 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "<" "<" { *id = id__Redir_TLess; break; }
64 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" ">" { *id = id__Redir_DGreat; break; }
65 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "<" "-" { *id = id__Redir_DLessDash; break; }
66 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" "&" { *id = id__Redir_GreatAnd; break; }
67 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "&" { *id = id__Redir_LessAnd; break; }
68 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" ">" { *id = id__Redir_LessGreat; break; }
69 "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" "|" { *id = id__Redir_Clobber; break; }
70 "&>" { *id = id__Redir_AndGreat; break; }
71 "&>>" { *id = id__Redir_AndDGreat; break; }
72 "[[" { *id = id__KW_DLeftBracket; break; }
73 "!" { *id = id__KW_Bang; break; }
74 "for" { *id = id__KW_For; break; }
75 "while" { *id = id__KW_While; break; }
76 "until" { *id = id__KW_Until; break; }
77 "do" { *id = id__KW_Do; break; }
78 "done" { *id = id__KW_Done; break; }
79 "in" { *id = id__KW_In; break; }
80 "case" { *id = id__KW_Case; break; }
81 "esac" { *id = id__KW_Esac; break; }
82 "if" { *id = id__KW_If; break; }
83 "fi" { *id = id__KW_Fi; break; }
84 "then" { *id = id__KW_Then; break; }
85 "else" { *id = id__KW_Else; break; }
86 "elif" { *id = id__KW_Elif; break; }
87 "function" { *id = id__KW_Function; break; }
88 "time" { *id = id__KW_Time; break; }
89 "const" { *id = id__KW_Const; break; }
90 "var" { *id = id__KW_Var; break; }
91 "setvar" { *id = id__KW_SetVar; break; }
92 "setglobal" { *id = id__KW_SetGlobal; break; }
93 "call" { *id = id__KW_Call; break; }
94 "proc" { *id = id__KW_Proc; break; }
95 "typed" { *id = id__KW_Typed; break; }
96 "func" { *id = id__KW_Func; break; }
97 "break" { *id = id__ControlFlow_Break; break; }
98 "continue" { *id = id__ControlFlow_Continue; break; }
99 "return" { *id = id__ControlFlow_Return; break; }
100 "exit" { *id = id__ControlFlow_Exit; break; }
101 "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; }
102 "\\\n" { *id = id__Ignored_LineCont; break; }
103 "`" { *id = id__Left_Backtick; break; }
104 "$(" { *id = id__Left_DollarParen; break; }
105 "${" { *id = id__Left_DollarBrace; break; }
106 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
107 "$((" { *id = id__Left_DollarDParen; break; }
108 "$[" { *id = id__Left_DollarBracket; break; }
109 "\"" { *id = id__Left_DoubleQuote; break; }
110 "'" { *id = id__Left_SingleQuote; break; }
111 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
112 "$'" { *id = id__Left_DollarSingleQuote; break; }
113 "<(" { *id = id__Left_ProcSubIn; break; }
114 ">(" { *id = id__Left_ProcSubOut; break; }
115 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
116 "$" [0-9] { *id = id__VSub_Number; break; }
117 "$!" { *id = id__VSub_Bang; break; }
118 "$@" { *id = id__VSub_At; break; }
119 "$#" { *id = id__VSub_Pound; break; }
120 "$$" { *id = id__VSub_Dollar; break; }
121 "$*" { *id = id__VSub_Star; break; }
122 "$-" { *id = id__VSub_Hyphen; break; }
123 "$?" { *id = id__VSub_QMark; break; }
124 [\x80-\xffa-zA-Z0-9_.\-]+ { *id = id__Lit_Chars; break; }
125 "~" { *id = id__Lit_Tilde; break; }
126 "/" { *id = id__Lit_Slash; break; }
127 ":" { *id = id__Lit_Colon; break; }
128 "$" { *id = id__Lit_Dollar; break; }
129 "#" { *id = id__Lit_Pound; break; }
130 [ \t]+ { *id = id__WS_Space; break; }
131 "\n" { *id = id__Op_Newline; break; }
132 "&" { *id = id__Op_Amp; break; }
133 "|" { *id = id__Op_Pipe; break; }
134 "|&" { *id = id__Op_PipeAmp; break; }
135 "&&" { *id = id__Op_DAmp; break; }
136 "||" { *id = id__Op_DPipe; break; }
137 ";" { *id = id__Op_Semi; break; }
138 ";;" { *id = id__Op_DSemi; break; }
139 ";&" { *id = id__Op_SemiAmp; break; }
140 ";;&" { *id = id__Op_DSemiAmp; break; }
141 "(" { *id = id__Op_LParen; break; }
142 ")" { *id = id__Op_RParen; break; }
143 [^\x00] { *id = id__Lit_Other; break; }
144 ",(" { *id = id__ExtGlob_Comma; break; }
145 "@(" { *id = id__ExtGlob_At; break; }
146 "*(" { *id = id__ExtGlob_Star; break; }
147 "+(" { *id = id__ExtGlob_Plus; break; }
148 "?(" { *id = id__ExtGlob_QMark; break; }
149 "!(" { *id = id__ExtGlob_Bang; break; }
150 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
151 */
152 }
153 break;
154
155 case lex_mode__Backtick:
156 for (;;) {
157 /*!re2c
158 "`" { *id = id__Backtick_Right; break; }
159 "\\" [$`\\] { *id = id__Backtick_Quoted; break; }
160 "\\" "\"" { *id = id__Backtick_DoubleQuote; break; }
161 [^`\\\x00]+ { *id = id__Backtick_Other; break; }
162 [^\x00] { *id = id__Backtick_Other; break; }
163 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
164 */
165 }
166 break;
167
168 case lex_mode__DBracket:
169 for (;;) {
170 /*!re2c
171 "]]" { *id = id__Lit_DRightBracket; break; }
172 "!" { *id = id__KW_Bang; break; }
173 "<" { *id = id__Op_Less; break; }
174 ">" { *id = id__Op_Great; break; }
175 "-z" { *id = id__BoolUnary_z; break; }
176 "-n" { *id = id__BoolUnary_n; break; }
177 "-o" { *id = id__BoolUnary_o; break; }
178 "-t" { *id = id__BoolUnary_t; break; }
179 "-v" { *id = id__BoolUnary_v; break; }
180 "-R" { *id = id__BoolUnary_R; break; }
181 "-a" { *id = id__BoolUnary_a; break; }
182 "-b" { *id = id__BoolUnary_b; break; }
183 "-c" { *id = id__BoolUnary_c; break; }
184 "-d" { *id = id__BoolUnary_d; break; }
185 "-e" { *id = id__BoolUnary_e; break; }
186 "-f" { *id = id__BoolUnary_f; break; }
187 "-g" { *id = id__BoolUnary_g; break; }
188 "-h" { *id = id__BoolUnary_h; break; }
189 "-k" { *id = id__BoolUnary_k; break; }
190 "-L" { *id = id__BoolUnary_L; break; }
191 "-p" { *id = id__BoolUnary_p; break; }
192 "-r" { *id = id__BoolUnary_r; break; }
193 "-s" { *id = id__BoolUnary_s; break; }
194 "-S" { *id = id__BoolUnary_S; break; }
195 "-u" { *id = id__BoolUnary_u; break; }
196 "-w" { *id = id__BoolUnary_w; break; }
197 "-x" { *id = id__BoolUnary_x; break; }
198 "-O" { *id = id__BoolUnary_O; break; }
199 "-G" { *id = id__BoolUnary_G; break; }
200 "-N" { *id = id__BoolUnary_N; break; }
201 "=" { *id = id__BoolBinary_GlobEqual; break; }
202 "==" { *id = id__BoolBinary_GlobDEqual; break; }
203 "!=" { *id = id__BoolBinary_GlobNEqual; break; }
204 "=~" { *id = id__BoolBinary_EqualTilde; break; }
205 "-ef" { *id = id__BoolBinary_ef; break; }
206 "-nt" { *id = id__BoolBinary_nt; break; }
207 "-ot" { *id = id__BoolBinary_ot; break; }
208 "-eq" { *id = id__BoolBinary_eq; break; }
209 "-ne" { *id = id__BoolBinary_ne; break; }
210 "-gt" { *id = id__BoolBinary_gt; break; }
211 "-ge" { *id = id__BoolBinary_ge; break; }
212 "-lt" { *id = id__BoolBinary_lt; break; }
213 "-le" { *id = id__BoolBinary_le; break; }
214 "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; }
215 "\\\n" { *id = id__Ignored_LineCont; break; }
216 "`" { *id = id__Left_Backtick; break; }
217 "$(" { *id = id__Left_DollarParen; break; }
218 "${" { *id = id__Left_DollarBrace; break; }
219 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
220 "$((" { *id = id__Left_DollarDParen; break; }
221 "$[" { *id = id__Left_DollarBracket; break; }
222 "\"" { *id = id__Left_DoubleQuote; break; }
223 "'" { *id = id__Left_SingleQuote; break; }
224 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
225 "$'" { *id = id__Left_DollarSingleQuote; break; }
226 "<(" { *id = id__Left_ProcSubIn; break; }
227 ">(" { *id = id__Left_ProcSubOut; break; }
228 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
229 "$" [0-9] { *id = id__VSub_Number; break; }
230 "$!" { *id = id__VSub_Bang; break; }
231 "$@" { *id = id__VSub_At; break; }
232 "$#" { *id = id__VSub_Pound; break; }
233 "$$" { *id = id__VSub_Dollar; break; }
234 "$*" { *id = id__VSub_Star; break; }
235 "$-" { *id = id__VSub_Hyphen; break; }
236 "$?" { *id = id__VSub_QMark; break; }
237 [\x80-\xffa-zA-Z0-9_.\-]+ { *id = id__Lit_Chars; break; }
238 "~" { *id = id__Lit_Tilde; break; }
239 "/" { *id = id__Lit_Slash; break; }
240 ":" { *id = id__Lit_Colon; break; }
241 "$" { *id = id__Lit_Dollar; break; }
242 "#" { *id = id__Lit_Pound; break; }
243 [ \t]+ { *id = id__WS_Space; break; }
244 "\n" { *id = id__Op_Newline; break; }
245 "&" { *id = id__Op_Amp; break; }
246 "|" { *id = id__Op_Pipe; break; }
247 "|&" { *id = id__Op_PipeAmp; break; }
248 "&&" { *id = id__Op_DAmp; break; }
249 "||" { *id = id__Op_DPipe; break; }
250 ";" { *id = id__Op_Semi; break; }
251 ";;" { *id = id__Op_DSemi; break; }
252 ";&" { *id = id__Op_SemiAmp; break; }
253 ";;&" { *id = id__Op_DSemiAmp; break; }
254 "(" { *id = id__Op_LParen; break; }
255 ")" { *id = id__Op_RParen; break; }
256 [^\x00] { *id = id__Lit_Other; break; }
257 ",(" { *id = id__ExtGlob_Comma; break; }
258 "@(" { *id = id__ExtGlob_At; break; }
259 "*(" { *id = id__ExtGlob_Star; break; }
260 "+(" { *id = id__ExtGlob_Plus; break; }
261 "?(" { *id = id__ExtGlob_QMark; break; }
262 "!(" { *id = id__ExtGlob_Bang; break; }
263 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
264 */
265 }
266 break;
267
268 case lex_mode__SQ_Raw:
269 for (;;) {
270 /*!re2c
271 [^'\x00]+ { *id = id__Lit_Chars; break; }
272 "'" { *id = id__Right_SingleQuote; break; }
273 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
274 */
275 }
276 break;
277
278 case lex_mode__DQ:
279 for (;;) {
280 /*!re2c
281 "\\" [$`"\\] { *id = id__Lit_EscapedChar; break; }
282 "\\" { *id = id__Lit_BadBackslash; break; }
283 "\\\n" { *id = id__Ignored_LineCont; break; }
284 "`" { *id = id__Left_Backtick; break; }
285 "$(" { *id = id__Left_DollarParen; break; }
286 "${" { *id = id__Left_DollarBrace; break; }
287 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
288 "$((" { *id = id__Left_DollarDParen; break; }
289 "$[" { *id = id__Left_DollarBracket; break; }
290 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
291 "$" [0-9] { *id = id__VSub_Number; break; }
292 "$!" { *id = id__VSub_Bang; break; }
293 "$@" { *id = id__VSub_At; break; }
294 "$#" { *id = id__VSub_Pound; break; }
295 "$$" { *id = id__VSub_Dollar; break; }
296 "$*" { *id = id__VSub_Star; break; }
297 "$-" { *id = id__VSub_Hyphen; break; }
298 "$?" { *id = id__VSub_QMark; break; }
299 [^$`"\x00\\]+ { *id = id__Lit_Chars; break; }
300 "$" { *id = id__Lit_Dollar; break; }
301 "\"" { *id = id__Right_DoubleQuote; break; }
302 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
303 */
304 }
305 break;
306
307 case lex_mode__SQ_C:
308 for (;;) {
309 /*!re2c
310 "\\" "x" [0-9a-fA-F]{1,2} { *id = id__Char_Hex; break; }
311 "\\" "u" [0-9a-fA-F]{1,4} { *id = id__Char_Unicode4; break; }
312 "\\" "U" [0-9a-fA-F]{1,8} { *id = id__Char_Unicode8; break; }
313 "\\" [0abeEfrtnv\\] { *id = id__Char_OneChar; break; }
314 "\\" { *id = id__Unknown_Backslash; break; }
315 "\\\n" { *id = id__Unknown_Backslash; break; }
316 "\\" [0-7]{1,3} { *id = id__Char_Octal3; break; }
317 "\\'" { *id = id__Char_OneChar; break; }
318 "\\\"" { *id = id__Char_OneChar; break; }
319 [^\\'\x00]+ { *id = id__Lit_Chars; break; }
320 "'" { *id = id__Right_SingleQuote; break; }
321 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
322 */
323 }
324 break;
325
326 case lex_mode__J8_Str:
327 for (;;) {
328 /*!re2c
329 "'" { *id = id__Right_SingleQuote; break; }
330 "\\" [\\"/bfnrt] { *id = id__Char_OneChar; break; }
331 "\\'" { *id = id__Char_OneChar; break; }
332 "\\" "y" [0-9a-fA-F]{2,2} { *id = id__Char_YHex; break; }
333 "\\" [uU]"{" [0-9a-fA-F]{1,6} "}" { *id = id__Char_UBraced; break; }
334 "\\" { *id = id__Unknown_Backslash; break; }
335 [^\\'\x00]+ { *id = id__Lit_Chars; break; }
336 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
337 */
338 }
339 break;
340
341 case lex_mode__Arith:
342 for (;;) {
343 /*!re2c
344 "`" { *id = id__Left_Backtick; break; }
345 "$(" { *id = id__Left_DollarParen; break; }
346 "${" { *id = id__Left_DollarBrace; break; }
347 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
348 "$((" { *id = id__Left_DollarDParen; break; }
349 "$[" { *id = id__Left_DollarBracket; break; }
350 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
351 "$" [0-9] { *id = id__VSub_Number; break; }
352 "$!" { *id = id__VSub_Bang; break; }
353 "$@" { *id = id__VSub_At; break; }
354 "$#" { *id = id__VSub_Pound; break; }
355 "$$" { *id = id__VSub_Dollar; break; }
356 "$*" { *id = id__VSub_Star; break; }
357 "$-" { *id = id__VSub_Hyphen; break; }
358 "$?" { *id = id__VSub_QMark; break; }
359 "\"" { *id = id__Left_DoubleQuote; break; }
360 "'" { *id = id__Left_SingleQuote; break; }
361 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
362 "$'" { *id = id__Left_DollarSingleQuote; break; }
363 [ \t\r\n]+ { *id = id__Ignored_Space; break; }
364 [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Lit_ArithVarLike; break; }
365 [0-9]+ { *id = id__Lit_Digits; break; }
366 "@" { *id = id__Lit_At; break; }
367 "#" { *id = id__Lit_Pound; break; }
368 ";" { *id = id__Arith_Semi; break; }
369 "," { *id = id__Arith_Comma; break; }
370 "+" { *id = id__Arith_Plus; break; }
371 "-" { *id = id__Arith_Minus; break; }
372 "*" { *id = id__Arith_Star; break; }
373 "/" { *id = id__Arith_Slash; break; }
374 "%" { *id = id__Arith_Percent; break; }
375 "++" { *id = id__Arith_DPlus; break; }
376 "--" { *id = id__Arith_DMinus; break; }
377 "**" { *id = id__Arith_DStar; break; }
378 "(" { *id = id__Arith_LParen; break; }
379 ")" { *id = id__Arith_RParen; break; }
380 "[" { *id = id__Arith_LBracket; break; }
381 "]" { *id = id__Arith_RBracket; break; }
382 "}" { *id = id__Arith_RBrace; break; }
383 "?" { *id = id__Arith_QMark; break; }
384 ":" { *id = id__Arith_Colon; break; }
385 "<=" { *id = id__Arith_LessEqual; break; }
386 "<" { *id = id__Arith_Less; break; }
387 ">=" { *id = id__Arith_GreatEqual; break; }
388 ">" { *id = id__Arith_Great; break; }
389 "==" { *id = id__Arith_DEqual; break; }
390 "!=" { *id = id__Arith_NEqual; break; }
391 "&&" { *id = id__Arith_DAmp; break; }
392 "||" { *id = id__Arith_DPipe; break; }
393 "!" { *id = id__Arith_Bang; break; }
394 ">>" { *id = id__Arith_DGreat; break; }
395 "<<" { *id = id__Arith_DLess; break; }
396 "&" { *id = id__Arith_Amp; break; }
397 "|" { *id = id__Arith_Pipe; break; }
398 "^" { *id = id__Arith_Caret; break; }
399 "~" { *id = id__Arith_Tilde; break; }
400 "=" { *id = id__Arith_Equal; break; }
401 "+=" { *id = id__Arith_PlusEqual; break; }
402 "-=" { *id = id__Arith_MinusEqual; break; }
403 "*=" { *id = id__Arith_StarEqual; break; }
404 "/=" { *id = id__Arith_SlashEqual; break; }
405 "%=" { *id = id__Arith_PercentEqual; break; }
406 ">>=" { *id = id__Arith_DGreatEqual; break; }
407 "<<=" { *id = id__Arith_DLessEqual; break; }
408 "&=" { *id = id__Arith_AmpEqual; break; }
409 "^=" { *id = id__Arith_CaretEqual; break; }
410 "|=" { *id = id__Arith_PipeEqual; break; }
411 "\\\n" { *id = id__Ignored_LineCont; break; }
412 [^\x00] { *id = id__Unknown_Tok; break; }
413 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
414 */
415 }
416 break;
417
418 case lex_mode__ExtGlob:
419 for (;;) {
420 /*!re2c
421 "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; }
422 "\\\n" { *id = id__Ignored_LineCont; break; }
423 "`" { *id = id__Left_Backtick; break; }
424 "$(" { *id = id__Left_DollarParen; break; }
425 "${" { *id = id__Left_DollarBrace; break; }
426 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
427 "$((" { *id = id__Left_DollarDParen; break; }
428 "$[" { *id = id__Left_DollarBracket; break; }
429 "\"" { *id = id__Left_DoubleQuote; break; }
430 "'" { *id = id__Left_SingleQuote; break; }
431 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
432 "$'" { *id = id__Left_DollarSingleQuote; break; }
433 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
434 "$" [0-9] { *id = id__VSub_Number; break; }
435 "$!" { *id = id__VSub_Bang; break; }
436 "$@" { *id = id__VSub_At; break; }
437 "$#" { *id = id__VSub_Pound; break; }
438 "$$" { *id = id__VSub_Dollar; break; }
439 "$*" { *id = id__VSub_Star; break; }
440 "$-" { *id = id__VSub_Hyphen; break; }
441 "$?" { *id = id__VSub_QMark; break; }
442 ",(" { *id = id__ExtGlob_Comma; break; }
443 "@(" { *id = id__ExtGlob_At; break; }
444 "*(" { *id = id__ExtGlob_Star; break; }
445 "+(" { *id = id__ExtGlob_Plus; break; }
446 "?(" { *id = id__ExtGlob_QMark; break; }
447 "!(" { *id = id__ExtGlob_Bang; break; }
448 [^\\$`"'|)@*+!?\x00]+ { *id = id__Lit_Chars; break; }
449 "|" { *id = id__Op_Pipe; break; }
450 ")" { *id = id__Op_RParen; break; }
451 [^\x00] { *id = id__Lit_Other; break; }
452 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
453 */
454 }
455 break;
456
457 case lex_mode__VSub_1:
458 for (;;) {
459 /*!re2c
460 [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_Name; break; }
461 [0-9]+ { *id = id__VSub_Number; break; }
462 "!" { *id = id__VSub_Bang; break; }
463 "@" { *id = id__VSub_At; break; }
464 "#" { *id = id__VSub_Pound; break; }
465 "$" { *id = id__VSub_Dollar; break; }
466 "*" { *id = id__VSub_Star; break; }
467 "-" { *id = id__VSub_Hyphen; break; }
468 "?" { *id = id__VSub_QMark; break; }
469 "." { *id = id__VSub_Dot; break; }
470 "}" { *id = id__Right_DollarBrace; break; }
471 "\\\n" { *id = id__Ignored_LineCont; break; }
472 "\n" { *id = id__Unknown_Tok; break; }
473 [^\x00] { *id = id__Unknown_Tok; break; }
474 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
475 */
476 }
477 break;
478
479 case lex_mode__VSub_2:
480 for (;;) {
481 /*!re2c
482 ":-" { *id = id__VTest_ColonHyphen; break; }
483 "-" { *id = id__VTest_Hyphen; break; }
484 ":=" { *id = id__VTest_ColonEquals; break; }
485 "=" { *id = id__VTest_Equals; break; }
486 ":?" { *id = id__VTest_ColonQMark; break; }
487 "?" { *id = id__VTest_QMark; break; }
488 ":+" { *id = id__VTest_ColonPlus; break; }
489 "+" { *id = id__VTest_Plus; break; }
490 "@Q" { *id = id__VOp0_Q; break; }
491 "@E" { *id = id__VOp0_E; break; }
492 "@P" { *id = id__VOp0_P; break; }
493 "@A" { *id = id__VOp0_A; break; }
494 "@a" { *id = id__VOp0_a; break; }
495 "|" { *id = id__VOpYsh_Pipe; break; }
496 " " { *id = id__VOpYsh_Space; break; }
497 "%" { *id = id__VOp1_Percent; break; }
498 "%%" { *id = id__VOp1_DPercent; break; }
499 "#" { *id = id__VOp1_Pound; break; }
500 "##" { *id = id__VOp1_DPound; break; }
501 "^" { *id = id__VOp1_Caret; break; }
502 "^^" { *id = id__VOp1_DCaret; break; }
503 "," { *id = id__VOp1_Comma; break; }
504 ",," { *id = id__VOp1_DComma; break; }
505 "/" { *id = id__VOp2_Slash; break; }
506 ":" { *id = id__VOp2_Colon; break; }
507 "[" { *id = id__VOp2_LBracket; break; }
508 "]" { *id = id__VOp2_RBracket; break; }
509 "@" { *id = id__VOp3_At; break; }
510 "*" { *id = id__VOp3_Star; break; }
511 "}" { *id = id__Right_DollarBrace; break; }
512 "\\\n" { *id = id__Ignored_LineCont; break; }
513 "\n" { *id = id__Unknown_Tok; break; }
514 [^\x00] { *id = id__Unknown_Tok; break; }
515 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
516 */
517 }
518 break;
519
520 case lex_mode__VSub_ArgUnquoted:
521 for (;;) {
522 /*!re2c
523 "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; }
524 "\\\n" { *id = id__Ignored_LineCont; break; }
525 "/" { *id = id__Lit_Slash; break; }
526 "#" { *id = id__Lit_Pound; break; }
527 "%" { *id = id__Lit_Percent; break; }
528 "}" { *id = id__Right_DollarBrace; break; }
529 "$" { *id = id__Lit_Dollar; break; }
530 "`" { *id = id__Left_Backtick; break; }
531 "$(" { *id = id__Left_DollarParen; break; }
532 "${" { *id = id__Left_DollarBrace; break; }
533 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
534 "$((" { *id = id__Left_DollarDParen; break; }
535 "$[" { *id = id__Left_DollarBracket; break; }
536 "\"" { *id = id__Left_DoubleQuote; break; }
537 "'" { *id = id__Left_SingleQuote; break; }
538 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
539 "$'" { *id = id__Left_DollarSingleQuote; break; }
540 "<(" { *id = id__Left_ProcSubIn; break; }
541 ">(" { *id = id__Left_ProcSubOut; break; }
542 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
543 "$" [0-9] { *id = id__VSub_Number; break; }
544 "$!" { *id = id__VSub_Bang; break; }
545 "$@" { *id = id__VSub_At; break; }
546 "$#" { *id = id__VSub_Pound; break; }
547 "$$" { *id = id__VSub_Dollar; break; }
548 "$*" { *id = id__VSub_Star; break; }
549 "$-" { *id = id__VSub_Hyphen; break; }
550 "$?" { *id = id__VSub_QMark; break; }
551 ",(" { *id = id__ExtGlob_Comma; break; }
552 "@(" { *id = id__ExtGlob_At; break; }
553 "*(" { *id = id__ExtGlob_Star; break; }
554 "+(" { *id = id__ExtGlob_Plus; break; }
555 "?(" { *id = id__ExtGlob_QMark; break; }
556 "!(" { *id = id__ExtGlob_Bang; break; }
557 "~" { *id = id__Lit_Tilde; break; }
558 [^$`~/}"'\x00\\#%<>@!?+*]+ { *id = id__Lit_Chars; break; }
559 [^\x00] { *id = id__Lit_Other; break; }
560 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
561 */
562 }
563 break;
564
565 case lex_mode__VSub_ArgDQ:
566 for (;;) {
567 /*!re2c
568 "\\" [$`"\\] { *id = id__Lit_EscapedChar; break; }
569 "\\" { *id = id__Lit_BadBackslash; break; }
570 "/" { *id = id__Lit_Slash; break; }
571 "#" { *id = id__Lit_Pound; break; }
572 "%" { *id = id__Lit_Percent; break; }
573 "}" { *id = id__Right_DollarBrace; break; }
574 "$" { *id = id__Lit_Dollar; break; }
575 "`" { *id = id__Left_Backtick; break; }
576 "$(" { *id = id__Left_DollarParen; break; }
577 "${" { *id = id__Left_DollarBrace; break; }
578 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
579 "$((" { *id = id__Left_DollarDParen; break; }
580 "$[" { *id = id__Left_DollarBracket; break; }
581 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
582 "$" [0-9] { *id = id__VSub_Number; break; }
583 "$!" { *id = id__VSub_Bang; break; }
584 "$@" { *id = id__VSub_At; break; }
585 "$#" { *id = id__VSub_Pound; break; }
586 "$$" { *id = id__VSub_Dollar; break; }
587 "$*" { *id = id__VSub_Star; break; }
588 "$-" { *id = id__VSub_Hyphen; break; }
589 "$?" { *id = id__VSub_QMark; break; }
590 "\\}" { *id = id__Lit_EscapedChar; break; }
591 [^$`/}"\x00\\#%]+ { *id = id__Lit_Chars; break; }
592 "\"" { *id = id__Left_DoubleQuote; break; }
593 "$'" { *id = id__Left_DollarSingleQuote; break; }
594 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
595 */
596 }
597 break;
598
599 case lex_mode__VSub_Zsh:
600 for (;;) {
601 /*!re2c
602 "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; }
603 "\\\n" { *id = id__Ignored_LineCont; break; }
604 "`" { *id = id__Left_Backtick; break; }
605 "$(" { *id = id__Left_DollarParen; break; }
606 "${" { *id = id__Left_DollarBrace; break; }
607 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
608 "$((" { *id = id__Left_DollarDParen; break; }
609 "$[" { *id = id__Left_DollarBracket; break; }
610 "\"" { *id = id__Left_DoubleQuote; break; }
611 "'" { *id = id__Left_SingleQuote; break; }
612 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
613 "$'" { *id = id__Left_DollarSingleQuote; break; }
614 "<(" { *id = id__Left_ProcSubIn; break; }
615 ">(" { *id = id__Left_ProcSubOut; break; }
616 "}" { *id = id__Right_DollarBrace; break; }
617 [^\x00] { *id = id__Lit_Other; break; }
618 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
619 */
620 }
621 break;
622
623 case lex_mode__BashRegex:
624 for (;;) {
625 /*!re2c
626 "`" { *id = id__Left_Backtick; break; }
627 "$(" { *id = id__Left_DollarParen; break; }
628 "${" { *id = id__Left_DollarBrace; break; }
629 "$" "{" "(" [^)\x00]+ ")" { *id = id__Left_DollarBraceZsh; break; }
630 "$((" { *id = id__Left_DollarDParen; break; }
631 "$[" { *id = id__Left_DollarBracket; break; }
632 "\"" { *id = id__Left_DoubleQuote; break; }
633 "'" { *id = id__Left_SingleQuote; break; }
634 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
635 "$'" { *id = id__Left_DollarSingleQuote; break; }
636 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
637 "$" [0-9] { *id = id__VSub_Number; break; }
638 "$!" { *id = id__VSub_Bang; break; }
639 "$@" { *id = id__VSub_At; break; }
640 "$#" { *id = id__VSub_Pound; break; }
641 "$$" { *id = id__VSub_Dollar; break; }
642 "$*" { *id = id__VSub_Star; break; }
643 "$-" { *id = id__VSub_Hyphen; break; }
644 "$?" { *id = id__VSub_QMark; break; }
645 [\x80-\xffa-zA-Z0-9_.\-]+ { *id = id__Lit_Chars; break; }
646 "~" { *id = id__Lit_Tilde; break; }
647 "/" { *id = id__Lit_Slash; break; }
648 [ \t]+ { *id = id__WS_Space; break; }
649 "(" { *id = id__BashRegex_LParen; break; }
650 ")" { *id = id__Op_RParen; break; }
651 "\n" { *id = id__BashRegex_AllowedInParens; break; }
652 "&" { *id = id__BashRegex_AllowedInParens; break; }
653 ";" { *id = id__BashRegex_AllowedInParens; break; }
654 ">" { *id = id__BashRegex_AllowedInParens; break; }
655 "<" { *id = id__BashRegex_AllowedInParens; break; }
656 [^\x00] { *id = id__Lit_Other; break; }
657 "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; }
658 "\\\n" { *id = id__Ignored_LineCont; break; }
659 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
660 */
661 }
662 break;
663
664 case lex_mode__FuncParens:
665 for (;;) {
666 /*!re2c
667 [ \t]* "(" [ \t]* ")" { *id = id__LookAhead_FuncParens; break; }
668 [^\x00] { *id = id__Unknown_Tok; break; }
669 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
670 */
671 }
672 break;
673
674 case lex_mode__PrintfOuter:
675 for (;;) {
676 /*!re2c
677 "\\" "x" [0-9a-fA-F]{1,2} { *id = id__Char_Hex; break; }
678 "\\" "u" [0-9a-fA-F]{1,4} { *id = id__Char_Unicode4; break; }
679 "\\" "U" [0-9a-fA-F]{1,8} { *id = id__Char_Unicode8; break; }
680 "\\" [0abeEfrtnv\\] { *id = id__Char_OneChar; break; }
681 "\\" { *id = id__Unknown_Backslash; break; }
682 "\\" [0-7]{1,3} { *id = id__Char_Octal3; break; }
683 [^%\\\x00]+ { *id = id__Lit_Chars; break; }
684 "%%" { *id = id__Format_EscapedPercent; break; }
685 "%" { *id = id__Format_Percent; break; }
686 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
687 */
688 }
689 break;
690
691 case lex_mode__PrintfPercent:
692 for (;;) {
693 /*!re2c
694 [\- +#] { *id = id__Format_Flag; break; }
695 "0" { *id = id__Format_Zero; break; }
696 [1-9][0-9]* { *id = id__Format_Num; break; }
697 "*" { *id = id__Format_Star; break; }
698 "." { *id = id__Format_Dot; break; }
699 [disqbcouxXeEfFgG] { *id = id__Format_Type; break; }
700 "(" [^()\x00]* ")" "T" { *id = id__Format_Time; break; }
701 [^\x00] { *id = id__Unknown_Tok; break; }
702 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
703 */
704 }
705 break;
706
707 case lex_mode__Expr:
708 for (;;) {
709 /*!re2c
710 "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; }
711 "$" [0-9] { *id = id__VSub_Number; break; }
712 "$!" { *id = id__VSub_Bang; break; }
713 "$@" { *id = id__VSub_At; break; }
714 "$#" { *id = id__VSub_Pound; break; }
715 "$$" { *id = id__VSub_Dollar; break; }
716 "$*" { *id = id__VSub_Star; break; }
717 "$-" { *id = id__VSub_Hyphen; break; }
718 "$?" { *id = id__VSub_QMark; break; }
719 "$(" { *id = id__Left_DollarParen; break; }
720 "${" { *id = id__Left_DollarBrace; break; }
721 "$[" { *id = id__Left_DollarBracket; break; }
722 "\"" { *id = id__Left_DoubleQuote; break; }
723 "$\"" { *id = id__Left_DollarDoubleQuote; break; }
724 "j\"" { *id = id__Left_JDoubleQuote; break; }
725 "'" { *id = id__Left_SingleQuote; break; }
726 "r'" { *id = id__Left_RSingleQuote; break; }
727 "u'" { *id = id__Left_USingleQuote; break; }
728 "b'" { *id = id__Left_BSingleQuote; break; }
729 "$'" { *id = id__Left_DollarSingleQuote; break; }
730 "^\"" { *id = id__Left_CaretDoubleQuote; break; }
731 "\"\"\"" { *id = id__Left_TDoubleQuote; break; }
732 "$\"\"\"" { *id = id__Left_DollarTDoubleQuote; break; }
733 "'''" { *id = id__Left_TSingleQuote; break; }
734 "r'''" { *id = id__Left_RTSingleQuote; break; }
735 "u'''" { *id = id__Left_UTSingleQuote; break; }
736 "b'''" { *id = id__Left_BTSingleQuote; break; }
737 "@(" { *id = id__Left_AtParen; break; }
738 "^(" { *id = id__Left_CaretParen; break; }
739 "^[" { *id = id__Left_CaretBracket; break; }
740 "^{" { *id = id__Left_CaretBrace; break; }
741 ":|" { *id = id__Left_ColonPipe; break; }
742 "%(" { *id = id__Left_PercentParen; break; }
743 "%[" { *id = id__Expr_Reserved; break; }
744 "%{" { *id = id__Expr_Reserved; break; }
745 "@{" { *id = id__Expr_Reserved; break; }
746 "@[" { *id = id__Expr_Reserved; break; }
747 ";" { *id = id__Op_Semi; break; }
748 "(" { *id = id__Op_LParen; break; }
749 ")" { *id = id__Op_RParen; break; }
750 "[" { *id = id__Op_LBracket; break; }
751 "]" { *id = id__Op_RBracket; break; }
752 "{" { *id = id__Op_LBrace; break; }
753 "}" { *id = id__Op_RBrace; break; }
754 "null" { *id = id__Expr_Null; break; }
755 "true" { *id = id__Expr_True; break; }
756 "false" { *id = id__Expr_False; break; }
757 "and" { *id = id__Expr_And; break; }
758 "or" { *id = id__Expr_Or; break; }
759 "not" { *id = id__Expr_Not; break; }
760 "for" { *id = id__Expr_For; break; }
761 "is" { *id = id__Expr_Is; break; }
762 "in" { *id = id__Expr_In; break; }
763 "if" { *id = id__Expr_If; break; }
764 "else" { *id = id__Expr_Else; break; }
765 "func" { *id = id__Expr_Func; break; }
766 "capture" { *id = id__Expr_Capture; break; }
767 "as" { *id = id__Expr_As; break; }
768 "\\" [0rtn\\"'] { *id = id__Char_OneChar; break; }
769 "\\" "x" [0-9a-fA-F]{2,2} { *id = id__Char_Hex; break; }
770 "#" "'" [^'\x00]"'" { *id = id__Char_Pound; break; }
771 "\\" [uU]"{" [0-9a-fA-F]{1,6} "}" { *id = id__Char_UBraced; break; }
772 [0-9]("_" ? [0-9])* { *id = id__Expr_DecInt; break; }
773 "0" [bB]("_" ? [01])+ { *id = id__Expr_BinInt; break; }
774 "0" [oO]("_" ? [0-7])+ { *id = id__Expr_OctInt; break; }
775 "0" [xX]("_" ? [0-9a-fA-F])+ { *id = id__Expr_HexInt; break; }
776 [0-9]("_" ? [0-9])* ("." [0-9]("_" ? [0-9])* )? ([eE][+\-]? [0-9]+ )? { *id = id__Expr_Float; break; }
777 [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Expr_Name; break; }
778 "%" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Expr_Symbol; break; }
779 "," { *id = id__Arith_Comma; break; }
780 ":" { *id = id__Arith_Colon; break; }
781 "?" { *id = id__Arith_QMark; break; }
782 "+" { *id = id__Arith_Plus; break; }
783 "-" { *id = id__Arith_Minus; break; }
784 "*" { *id = id__Arith_Star; break; }
785 "^" { *id = id__Arith_Caret; break; }
786 "/" { *id = id__Arith_Slash; break; }
787 "%" { *id = id__Arith_Percent; break; }
788 "**" { *id = id__Arith_DStar; break; }
789 "++" { *id = id__Arith_DPlus; break; }
790 "<" { *id = id__Arith_Less; break; }
791 ">" { *id = id__Arith_Great; break; }
792 "<=" { *id = id__Arith_LessEqual; break; }
793 ">=" { *id = id__Arith_GreatEqual; break; }
794 "===" { *id = id__Expr_TEqual; break; }
795 "!==" { *id = id__Expr_NotDEqual; break; }
796 "==" { *id = id__Unknown_DEqual; break; }
797 "&" { *id = id__Arith_Amp; break; }
798 "|" { *id = id__Arith_Pipe; break; }
799 ">>" { *id = id__Arith_DGreat; break; }
800 "<<" { *id = id__Arith_DLess; break; }
801 "~" { *id = id__Arith_Tilde; break; }
802 "!~" { *id = id__Expr_NotTilde; break; }
803 "~~" { *id = id__Expr_DTilde; break; }
804 "!~~" { *id = id__Expr_NotDTilde; break; }
805 "=" { *id = id__Arith_Equal; break; }
806 "+=" { *id = id__Arith_PlusEqual; break; }
807 "-=" { *id = id__Arith_MinusEqual; break; }
808 "*=" { *id = id__Arith_StarEqual; break; }
809 "/=" { *id = id__Arith_SlashEqual; break; }
810 "%=" { *id = id__Arith_PercentEqual; break; }
811 ">>=" { *id = id__Arith_DGreatEqual; break; }
812 "<<=" { *id = id__Arith_DLessEqual; break; }
813 "&=" { *id = id__Arith_AmpEqual; break; }
814 "|=" { *id = id__Arith_PipeEqual; break; }
815 "^=" { *id = id__Arith_CaretEqual; break; }
816 "**=" { *id = id__Expr_DStarEqual; break; }
817 "//=" { *id = id__Expr_DSlashEqual; break; }
818 "!" { *id = id__Expr_Bang; break; }
819 "//" { *id = id__Expr_DSlash; break; }
820 "~==" { *id = id__Expr_TildeDEqual; break; }
821 "." { *id = id__Expr_Dot; break; }
822 ".." { *id = id__Expr_DDot; break; }
823 "->" { *id = id__Expr_RArrow; break; }
824 "$" { *id = id__Expr_Dollar; break; }
825 "<-" { *id = id__Expr_Reserved; break; }
826 "=>" { *id = id__Expr_RDArrow; break; }
827 "..." { *id = id__Expr_Ellipsis; break; }
828 "///" { *id = id__Expr_Reserved; break; }
829 "@" { *id = id__Expr_At; break; }
830 "@@" { *id = id__Expr_DoubleAt; break; }
831 "\n" { *id = id__Op_Newline; break; }
832 "#" [^\n\x00]* { *id = id__Ignored_Comment; break; }
833 [ \t\r]+ { *id = id__Ignored_Space; break; }
834 "\\\n" { *id = id__Ignored_LineCont; break; }
835 [^\x00] { *id = id__Unknown_Tok; break; }
836 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
837 */
838 }
839 break;
840
841 default:
842 assert(0);
843
844 }
845 *end_pos = p - line; /* relative */
846}
847
848
849static inline void MatchEchoToken(const unsigned char* line, int line_len,
850 int start_pos, int* id, int* end_pos) {
851 assert(start_pos <= line_len); /* caller should have checked */
852
853 const unsigned char* p = line + start_pos; /* modified by re2c */
854
855 /* Echo and History lexer apparently need this, but others don't */
856 __attribute__((unused)) const unsigned char* YYMARKER;
857
858 for (;;) {
859 /*!re2c
860
861 "\\" "x" [0-9a-fA-F]{1,2} { *id = id__Char_Hex; break; }
862 "\\" "u" [0-9a-fA-F]{1,4} { *id = id__Char_Unicode4; break; }
863 "\\" "U" [0-9a-fA-F]{1,8} { *id = id__Char_Unicode8; break; }
864 "\\" [0abeEfrtnv\\] { *id = id__Char_OneChar; break; }
865 "\\" { *id = id__Unknown_Backslash; break; }
866 "\\" "0" [0-7]{1,3} { *id = id__Char_Octal4; break; }
867 "\\c" { *id = id__Char_Stop; break; }
868 [^\\\x00]+ { *id = id__Lit_Chars; break; }
869 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
870
871 */
872 }
873 *end_pos = p - line; /* relative */
874}
875
876
877static inline void MatchGlobToken(const unsigned char* line, int line_len,
878 int start_pos, int* id, int* end_pos) {
879 assert(start_pos <= line_len); /* caller should have checked */
880
881 const unsigned char* p = line + start_pos; /* modified by re2c */
882
883 /* Echo and History lexer apparently need this, but others don't */
884 __attribute__((unused)) const unsigned char* YYMARKER;
885
886 for (;;) {
887 /*!re2c
888
889 "*" { *id = id__Glob_Star; break; }
890 "?" { *id = id__Glob_QMark; break; }
891 "!" { *id = id__Glob_Bang; break; }
892 "^" { *id = id__Glob_Caret; break; }
893 "[" { *id = id__Glob_LBracket; break; }
894 "]" { *id = id__Glob_RBracket; break; }
895 "\\" [^\x00] { *id = id__Glob_EscapedChar; break; }
896 "\\" { *id = id__Glob_BadBackslash; break; }
897 [a-zA-Z0-9_]+ { *id = id__Glob_CleanLiterals; break; }
898 [^\x00] { *id = id__Glob_OtherLiteral; break; }
899 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
900
901 */
902 }
903 *end_pos = p - line; /* relative */
904}
905
906
907static inline void MatchPS1Token(const unsigned char* line, int line_len,
908 int start_pos, int* id, int* end_pos) {
909 assert(start_pos <= line_len); /* caller should have checked */
910
911 const unsigned char* p = line + start_pos; /* modified by re2c */
912
913 /* Echo and History lexer apparently need this, but others don't */
914 __attribute__((unused)) const unsigned char* YYMARKER;
915
916 for (;;) {
917 /*!re2c
918
919 "\\" [0-7]{1,3} { *id = id__PS_Octal3; break; }
920 "\\" [adehHjlnrstT@AuvVwW!#$\\] { *id = id__PS_Subst; break; }
921 "\\" "D" "{" [^}\x00]* "}" { *id = id__PS_Subst; break; }
922 "\\[" { *id = id__PS_LBrace; break; }
923 "\\]" { *id = id__PS_RBrace; break; }
924 [^\\\x00]+ { *id = id__PS_Literals; break; }
925 "\\" { *id = id__PS_BadBackslash; break; }
926 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
927
928 */
929 }
930 *end_pos = p - line; /* relative */
931}
932
933
934static inline void MatchHistoryToken(const unsigned char* line, int line_len,
935 int start_pos, int* id, int* end_pos) {
936 assert(start_pos <= line_len); /* caller should have checked */
937
938 const unsigned char* p = line + start_pos; /* modified by re2c */
939
940 /* Echo and History lexer apparently need this, but others don't */
941 __attribute__((unused)) const unsigned char* YYMARKER;
942
943 for (;;) {
944 /*!re2c
945
946 "!" [!*^$] { *id = id__History_Op; break; }
947 "!" "-" ? [0-9]+ { *id = id__History_Num; break; }
948 "!" "?" ? [a-zA-Z_/.][0-9a-zA-Z_/.]+ [ \t\r\n] { *id = id__History_Search; break; }
949 "#" [^\x00]* { *id = id__History_Other; break; }
950 "'" [^'\x00]* "'" ? { *id = id__History_Other; break; }
951 [^!\\'#\x00]+ { *id = id__History_Other; break; }
952 "\\" [^\x00] { *id = id__History_Other; break; }
953 [^\x00] { *id = id__History_Other; break; }
954 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
955
956 */
957 }
958 *end_pos = p - line; /* relative */
959}
960
961
962static inline void MatchBraceRangeToken(const unsigned char* line, int line_len,
963 int start_pos, int* id, int* end_pos) {
964 assert(start_pos <= line_len); /* caller should have checked */
965
966 const unsigned char* p = line + start_pos; /* modified by re2c */
967
968 /* Echo and History lexer apparently need this, but others don't */
969 __attribute__((unused)) const unsigned char* YYMARKER;
970
971 for (;;) {
972 /*!re2c
973
974 "-" ? [0-9]+ { *id = id__Range_Int; break; }
975 [a-zA-Z] { *id = id__Range_Char; break; }
976 "." "." { *id = id__Range_Dots; break; }
977 [^\x00] { *id = id__Range_Other; break; }
978 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
979
980 */
981 }
982 *end_pos = p - line; /* relative */
983}
984
985
986static inline void MatchJ8Token(const unsigned char* line, int line_len,
987 int start_pos, int* id, int* end_pos) {
988 assert(start_pos <= line_len); /* caller should have checked */
989
990 const unsigned char* p = line + start_pos; /* modified by re2c */
991
992 /* Echo and History lexer apparently need this, but others don't */
993 __attribute__((unused)) const unsigned char* YYMARKER;
994
995 for (;;) {
996 /*!re2c
997
998 "\"" { *id = id__Left_DoubleQuote; break; }
999 "j\"" { *id = id__Left_JDoubleQuote; break; }
1000 "u'" { *id = id__Left_USingleQuote; break; }
1001 "'" { *id = id__Left_USingleQuote; break; }
1002 "b'" { *id = id__Left_BSingleQuote; break; }
1003 "[" { *id = id__J8_LBracket; break; }
1004 "]" { *id = id__J8_RBracket; break; }
1005 "{" { *id = id__J8_LBrace; break; }
1006 "}" { *id = id__J8_RBrace; break; }
1007 "(" { *id = id__J8_LParen; break; }
1008 ")" { *id = id__J8_RParen; break; }
1009 "," { *id = id__J8_Comma; break; }
1010 ":" { *id = id__J8_Colon; break; }
1011 "null" { *id = id__J8_Null; break; }
1012 "true" { *id = id__J8_Bool; break; }
1013 "false" { *id = id__J8_Bool; break; }
1014 "-" ? ([1-9][0-9]* | [0-9]) { *id = id__J8_Int; break; }
1015 "-" ? ([1-9][0-9]* | [0-9])("." [0-9]+ )? ([eE][\-+]? [0-9]+ )? { *id = id__J8_Float; break; }
1016 [a-zA-Z_][a-zA-Z0-9_]* { *id = id__J8_Identifier; break; }
1017 [~!@$%^&*+=|;./<>?\-]+ { *id = id__J8_Operator; break; }
1018 [ \r\t]+ { *id = id__Ignored_Space; break; }
1019 "\n" { *id = id__Ignored_Newline; break; }
1020 "#" [^\n\x00]* { *id = id__Ignored_Comment; break; }
1021 [^\x00] { *id = id__Unknown_Tok; break; }
1022 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1023
1024 */
1025 }
1026 *end_pos = p - line; /* relative */
1027}
1028
1029
1030static inline void MatchJ8LinesToken(const unsigned char* line, int line_len,
1031 int start_pos, int* id, int* end_pos) {
1032 assert(start_pos <= line_len); /* caller should have checked */
1033
1034 const unsigned char* p = line + start_pos; /* modified by re2c */
1035
1036 /* Echo and History lexer apparently need this, but others don't */
1037 __attribute__((unused)) const unsigned char* YYMARKER;
1038
1039 for (;;) {
1040 /*!re2c
1041
1042 "\"" { *id = id__Left_DoubleQuote; break; }
1043 "j\"" { *id = id__Left_JDoubleQuote; break; }
1044 "u'" { *id = id__Left_USingleQuote; break; }
1045 "'" { *id = id__Left_USingleQuote; break; }
1046 "b'" { *id = id__Left_BSingleQuote; break; }
1047 [ \r\t]+ { *id = id__WS_Space; break; }
1048 "\n" { *id = id__J8_Newline; break; }
1049 [\x01-\x1f] { *id = id__Char_AsciiControl; break; }
1050 [^ \t\r\n'"\x00-\x1f]+ { *id = id__Lit_Chars; break; }
1051 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1052
1053 */
1054 }
1055 *end_pos = p - line; /* relative */
1056}
1057
1058
1059static inline void MatchJ8StrToken(const unsigned char* line, int line_len,
1060 int start_pos, int* id, int* end_pos) {
1061 assert(start_pos <= line_len); /* caller should have checked */
1062
1063 const unsigned char* p = line + start_pos; /* modified by re2c */
1064
1065 /* Echo and History lexer apparently need this, but others don't */
1066 __attribute__((unused)) const unsigned char* YYMARKER;
1067
1068 for (;;) {
1069 /*!re2c
1070
1071 "'" { *id = id__Right_SingleQuote; break; }
1072 "\\" [\\"/bfnrt] { *id = id__Char_OneChar; break; }
1073 "\\'" { *id = id__Char_OneChar; break; }
1074 "\\" "y" [0-9a-fA-F]{2,2} { *id = id__Char_YHex; break; }
1075 "\\" [uU]"{" [0-9a-fA-F]{1,6} "}" { *id = id__Char_UBraced; break; }
1076 "\\" { *id = id__Unknown_Backslash; break; }
1077 [\x01-\x1f] { *id = id__Char_AsciiControl; break; }
1078 [^\\'\x00-\x1f]+ { *id = id__Lit_Chars; break; }
1079 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1080
1081 */
1082 }
1083 *end_pos = p - line; /* relative */
1084}
1085
1086
1087static inline void MatchJsonStrToken(const unsigned char* line, int line_len,
1088 int start_pos, int* id, int* end_pos) {
1089 assert(start_pos <= line_len); /* caller should have checked */
1090
1091 const unsigned char* p = line + start_pos; /* modified by re2c */
1092
1093 /* Echo and History lexer apparently need this, but others don't */
1094 __attribute__((unused)) const unsigned char* YYMARKER;
1095
1096 for (;;) {
1097 /*!re2c
1098
1099 "\"" { *id = id__Right_DoubleQuote; break; }
1100 "\\" [\\"/bfnrt] { *id = id__Char_OneChar; break; }
1101 "\\" "u" [0-9a-fA-F]{4,4} { *id = id__Char_Unicode4; break; }
1102 "\\" "u" [dD][89aAbB][0-9a-fA-F][0-9a-fA-F]"\\" "u" [dD][cCdDeEfF][0-9a-fA-F][0-9a-fA-F] { *id = id__Char_SurrogatePair; break; }
1103 "\\" { *id = id__Unknown_Backslash; break; }
1104 [\x01-\x1f] { *id = id__Char_AsciiControl; break; }
1105 [^\\"\x00-\x1f]+ { *id = id__Lit_Chars; break; }
1106 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1107
1108 */
1109 }
1110 *end_pos = p - line; /* relative */
1111}
1112
1113
1114static inline int IsValidVarName(const unsigned char* s, int len) {
1115 const unsigned char* p = s; /* modified by re2c */
1116 const unsigned char* end = s + len;
1117
1118 /* MatchBraceRangeToken needs this, but others don't */
1119 __attribute__((unused)) const unsigned char* YYMARKER;
1120
1121 /*!re2c
1122 re2c:define:YYCTYPE = "unsigned char";
1123 re2c:define:YYCURSOR = p;
1124 [a-zA-Z_][a-zA-Z0-9_]* { return p == end; } // Match must be anchored right, like $
1125 * { return 0; }
1126 */
1127}
1128
1129
1130static inline int ShouldHijack(const unsigned char* s, int len) {
1131 const unsigned char* p = s; /* modified by re2c */
1132 const unsigned char* end = s + len;
1133
1134 /* MatchBraceRangeToken needs this, but others don't */
1135 __attribute__((unused)) const unsigned char* YYMARKER;
1136
1137 /*!re2c
1138 re2c:define:YYCTYPE = "unsigned char";
1139 re2c:define:YYCURSOR = p;
1140 "#" "!" [^\x00]* "s" "h" [ \t\r\n][^\x00]* { return p == end; } // Match must be anchored right, like $
1141 * { return 0; }
1142 */
1143}
1144
1145
1146static inline int LooksLikeInteger(const unsigned char* s, int len) {
1147 const unsigned char* p = s; /* modified by re2c */
1148 const unsigned char* end = s + len;
1149
1150 /* MatchBraceRangeToken needs this, but others don't */
1151 __attribute__((unused)) const unsigned char* YYMARKER;
1152
1153 /*!re2c
1154 re2c:define:YYCTYPE = "unsigned char";
1155 re2c:define:YYCURSOR = p;
1156 [ \t\r\n]* "-" ? [0-9]("_" ? [0-9])* [ \t\r\n]* { return p == end; } // Match must be anchored right, like $
1157 * { return 0; }
1158 */
1159}
1160
1161
1162static inline int LooksLikeFloat(const unsigned char* s, int len) {
1163 const unsigned char* p = s; /* modified by re2c */
1164 const unsigned char* end = s + len;
1165
1166 /* MatchBraceRangeToken needs this, but others don't */
1167 __attribute__((unused)) const unsigned char* YYMARKER;
1168
1169 /*!re2c
1170 re2c:define:YYCTYPE = "unsigned char";
1171 re2c:define:YYCURSOR = p;
1172 [ \t\r\n]* "-" ? [0-9]("_" ? [0-9])* ("." [0-9]("_" ? [0-9])* )? ([eE][+\-]? [0-9]+ )? [ \t\r\n]* { return p == end; } // Match must be anchored right, like $
1173 * { return 0; }
1174 */
1175}
1176
1177
1178static inline int BracketUnary(const unsigned char* s, int len) {
1179 const unsigned char* p = s; /* modified by re2c */
1180 const unsigned char* end = s + len;
1181
1182 __attribute__((unused)) const unsigned char* YYMARKER;
1183 int id;
1184
1185 for (;;) {
1186 /*!re2c
1187
1188 "-G" { id = id__BoolUnary_G; break; }
1189 "-L" { id = id__BoolUnary_L; break; }
1190 "-N" { id = id__BoolUnary_N; break; }
1191 "-O" { id = id__BoolUnary_O; break; }
1192 "-R" { id = id__BoolUnary_R; break; }
1193 "-S" { id = id__BoolUnary_S; break; }
1194 "-a" { id = id__BoolUnary_a; break; }
1195 "-b" { id = id__BoolUnary_b; break; }
1196 "-c" { id = id__BoolUnary_c; break; }
1197 "-d" { id = id__BoolUnary_d; break; }
1198 "-e" { id = id__BoolUnary_e; break; }
1199 "-f" { id = id__BoolUnary_f; break; }
1200 "-g" { id = id__BoolUnary_g; break; }
1201 "-h" { id = id__BoolUnary_h; break; }
1202 "-k" { id = id__BoolUnary_k; break; }
1203 "-n" { id = id__BoolUnary_n; break; }
1204 "-o" { id = id__BoolUnary_o; break; }
1205 "-p" { id = id__BoolUnary_p; break; }
1206 "-r" { id = id__BoolUnary_r; break; }
1207 "-s" { id = id__BoolUnary_s; break; }
1208 "-t" { id = id__BoolUnary_t; break; }
1209 "-u" { id = id__BoolUnary_u; break; }
1210 "-v" { id = id__BoolUnary_v; break; }
1211 "-w" { id = id__BoolUnary_w; break; }
1212 "-x" { id = id__BoolUnary_x; break; }
1213 "-z" { id = id__BoolUnary_z; break; }
1214 * { return id__Undefined_Tok; }
1215
1216 */
1217 }
1218 // must be an exact match
1219 return (p == end) ? id : id__Undefined_Tok;
1220}
1221
1222
1223static inline int BracketBinary(const unsigned char* s, int len) {
1224 const unsigned char* p = s; /* modified by re2c */
1225 const unsigned char* end = s + len;
1226
1227 __attribute__((unused)) const unsigned char* YYMARKER;
1228 int id;
1229
1230 for (;;) {
1231 /*!re2c
1232
1233 "!=" { id = id__BoolBinary_NEqual; break; }
1234 "-ef" { id = id__BoolBinary_ef; break; }
1235 "-eq" { id = id__BoolBinary_eq; break; }
1236 "-ge" { id = id__BoolBinary_ge; break; }
1237 "-gt" { id = id__BoolBinary_gt; break; }
1238 "-le" { id = id__BoolBinary_le; break; }
1239 "-lt" { id = id__BoolBinary_lt; break; }
1240 "-ne" { id = id__BoolBinary_ne; break; }
1241 "-nt" { id = id__BoolBinary_nt; break; }
1242 "-ot" { id = id__BoolBinary_ot; break; }
1243 "<" { id = id__Op_Less; break; }
1244 "=" { id = id__BoolBinary_Equal; break; }
1245 "==" { id = id__BoolBinary_DEqual; break; }
1246 ">" { id = id__Op_Great; break; }
1247 * { return id__Undefined_Tok; }
1248
1249 */
1250 }
1251 // must be an exact match
1252 return (p == end) ? id : id__Undefined_Tok;
1253}
1254
1255
1256static inline int BracketOther(const unsigned char* s, int len) {
1257 const unsigned char* p = s; /* modified by re2c */
1258 const unsigned char* end = s + len;
1259
1260 __attribute__((unused)) const unsigned char* YYMARKER;
1261 int id;
1262
1263 for (;;) {
1264 /*!re2c
1265
1266 "!" { id = id__KW_Bang; break; }
1267 "(" { id = id__Op_LParen; break; }
1268 ")" { id = id__Op_RParen; break; }
1269 "]" { id = id__Arith_RBracket; break; }
1270 * { return id__Undefined_Tok; }
1271
1272 */
1273 }
1274 // must be an exact match
1275 return (p == end) ? id : id__Undefined_Tok;
1276}
1277