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

1323 lines, 1140 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 "\\" [\\"'nrt] { *id = id__Char_OneChar; break; }
769 "\\" "y" [0-9a-fA-F]{2,2} { *id = id__Char_YHex; break; }
770 "\\" "x" [0-9a-fA-F]{2,2} { *id = id__Char_Hex; 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__Unknown_DAmp; break; }
798 "||" { *id = id__Unknown_DPipe; break; }
799 "&" { *id = id__Arith_Amp; break; }
800 "|" { *id = id__Arith_Pipe; break; }
801 ">>" { *id = id__Arith_DGreat; break; }
802 "<<" { *id = id__Arith_DLess; break; }
803 "~" { *id = id__Arith_Tilde; break; }
804 "!~" { *id = id__Expr_NotTilde; break; }
805 "~~" { *id = id__Expr_DTilde; break; }
806 "!~~" { *id = id__Expr_NotDTilde; break; }
807 "=" { *id = id__Arith_Equal; break; }
808 "+=" { *id = id__Arith_PlusEqual; break; }
809 "-=" { *id = id__Arith_MinusEqual; break; }
810 "*=" { *id = id__Arith_StarEqual; break; }
811 "/=" { *id = id__Arith_SlashEqual; break; }
812 "%=" { *id = id__Arith_PercentEqual; break; }
813 ">>=" { *id = id__Arith_DGreatEqual; break; }
814 "<<=" { *id = id__Arith_DLessEqual; break; }
815 "&=" { *id = id__Arith_AmpEqual; break; }
816 "|=" { *id = id__Arith_PipeEqual; break; }
817 "^=" { *id = id__Arith_CaretEqual; break; }
818 "**=" { *id = id__Expr_DStarEqual; break; }
819 "//=" { *id = id__Expr_DSlashEqual; break; }
820 "!" { *id = id__Expr_Bang; break; }
821 "//" { *id = id__Expr_DSlash; break; }
822 "~==" { *id = id__Expr_TildeDEqual; break; }
823 "." { *id = id__Expr_Dot; break; }
824 ".." { *id = id__Unknown_DDot; break; }
825 "..<" { *id = id__Expr_DDotLessThan; break; }
826 "..=" { *id = id__Expr_DDotEqual; break; }
827 "->" { *id = id__Expr_RArrow; break; }
828 "$" { *id = id__Expr_Dollar; break; }
829 "<-" { *id = id__Expr_Reserved; break; }
830 "=>" { *id = id__Expr_RDArrow; break; }
831 "..." { *id = id__Expr_Ellipsis; break; }
832 "///" { *id = id__Expr_Reserved; break; }
833 "@" { *id = id__Expr_At; break; }
834 "@@" { *id = id__Expr_DoubleAt; break; }
835 "\n" { *id = id__Op_Newline; break; }
836 "#" [^\n\x00]* { *id = id__Ignored_Comment; break; }
837 [ \t\r]+ { *id = id__Ignored_Space; break; }
838 "\\\n" { *id = id__Ignored_LineCont; break; }
839 [^\x00] { *id = id__Unknown_Tok; break; }
840 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
841 */
842 }
843 break;
844
845 default:
846 assert(0);
847
848 }
849 *end_pos = p - line; /* relative */
850}
851
852
853static inline void MatchEchoToken(const unsigned char* line, int line_len,
854 int start_pos, int* id, int* end_pos) {
855 assert(start_pos <= line_len); /* caller should have checked */
856
857 const unsigned char* p = line + start_pos; /* modified by re2c */
858
859 /* Echo and History lexer apparently need this, but others don't */
860 __attribute__((unused)) const unsigned char* YYMARKER;
861
862 for (;;) {
863 /*!re2c
864
865 "\\" "x" [0-9a-fA-F]{1,2} { *id = id__Char_Hex; break; }
866 "\\" "u" [0-9a-fA-F]{1,4} { *id = id__Char_Unicode4; break; }
867 "\\" "U" [0-9a-fA-F]{1,8} { *id = id__Char_Unicode8; break; }
868 "\\" [0abeEfrtnv\\] { *id = id__Char_OneChar; break; }
869 "\\" { *id = id__Unknown_Backslash; break; }
870 "\\" "0" [0-7]{1,3} { *id = id__Char_Octal4; break; }
871 "\\c" { *id = id__Char_Stop; break; }
872 [^\\\x00]+ { *id = id__Lit_Chars; break; }
873 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
874
875 */
876 }
877 *end_pos = p - line; /* relative */
878}
879
880
881static inline void MatchGlobToken(const unsigned char* line, int line_len,
882 int start_pos, int* id, int* end_pos) {
883 assert(start_pos <= line_len); /* caller should have checked */
884
885 const unsigned char* p = line + start_pos; /* modified by re2c */
886
887 /* Echo and History lexer apparently need this, but others don't */
888 __attribute__((unused)) const unsigned char* YYMARKER;
889
890 for (;;) {
891 /*!re2c
892
893 "*" { *id = id__Glob_Star; break; }
894 "?" { *id = id__Glob_QMark; break; }
895 "!" { *id = id__Glob_Bang; break; }
896 "^" { *id = id__Glob_Caret; break; }
897 "[" { *id = id__Glob_LBracket; break; }
898 "]" { *id = id__Glob_RBracket; break; }
899 "\\" [^\x00] { *id = id__Glob_EscapedChar; break; }
900 "\\" { *id = id__Glob_BadBackslash; break; }
901 [a-zA-Z0-9_]+ { *id = id__Glob_CleanLiterals; break; }
902 [^\x00] { *id = id__Glob_OtherLiteral; break; }
903 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
904
905 */
906 }
907 *end_pos = p - line; /* relative */
908}
909
910
911static inline void MatchPS1Token(const unsigned char* line, int line_len,
912 int start_pos, int* id, int* end_pos) {
913 assert(start_pos <= line_len); /* caller should have checked */
914
915 const unsigned char* p = line + start_pos; /* modified by re2c */
916
917 /* Echo and History lexer apparently need this, but others don't */
918 __attribute__((unused)) const unsigned char* YYMARKER;
919
920 for (;;) {
921 /*!re2c
922
923 "\\" [0-7]{1,3} { *id = id__PS_Octal3; break; }
924 "\\" [adehHjlnrstT@AuvVwW!#$\\] { *id = id__PS_Subst; break; }
925 "\\" "D" "{" [^}\x00]* "}" { *id = id__PS_Subst; break; }
926 "\\[" { *id = id__PS_LBrace; break; }
927 "\\]" { *id = id__PS_RBrace; break; }
928 [^\\\x00]+ { *id = id__PS_Literals; break; }
929 "\\" { *id = id__PS_BadBackslash; break; }
930 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
931
932 */
933 }
934 *end_pos = p - line; /* relative */
935}
936
937
938static inline void MatchHistoryToken(const unsigned char* line, int line_len,
939 int start_pos, int* id, int* end_pos) {
940 assert(start_pos <= line_len); /* caller should have checked */
941
942 const unsigned char* p = line + start_pos; /* modified by re2c */
943
944 /* Echo and History lexer apparently need this, but others don't */
945 __attribute__((unused)) const unsigned char* YYMARKER;
946
947 for (;;) {
948 /*!re2c
949
950 "!" [!*^$] { *id = id__History_Op; break; }
951 "!" "-" ? [0-9]+ { *id = id__History_Num; break; }
952 "!" "?" ? [a-zA-Z_/.][0-9a-zA-Z_/.]+ [ \t\r\n] { *id = id__History_Search; break; }
953 "#" [^\x00]* { *id = id__History_Other; break; }
954 "'" [^'\x00]* "'" ? { *id = id__History_Other; break; }
955 [^!\\'#\x00]+ { *id = id__History_Other; break; }
956 "\\" [^\x00] { *id = id__History_Other; break; }
957 [^\x00] { *id = id__History_Other; break; }
958 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
959
960 */
961 }
962 *end_pos = p - line; /* relative */
963}
964
965
966static inline void MatchBraceRangeToken(const unsigned char* line, int line_len,
967 int start_pos, int* id, int* end_pos) {
968 assert(start_pos <= line_len); /* caller should have checked */
969
970 const unsigned char* p = line + start_pos; /* modified by re2c */
971
972 /* Echo and History lexer apparently need this, but others don't */
973 __attribute__((unused)) const unsigned char* YYMARKER;
974
975 for (;;) {
976 /*!re2c
977
978 "-" ? [0-9]+ { *id = id__Range_Int; break; }
979 [a-zA-Z] { *id = id__Range_Char; break; }
980 "." "." { *id = id__Range_Dots; break; }
981 [^\x00] { *id = id__Range_Other; break; }
982 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
983
984 */
985 }
986 *end_pos = p - line; /* relative */
987}
988
989
990static inline void MatchJ8Token(const unsigned char* line, int line_len,
991 int start_pos, int* id, int* end_pos) {
992 assert(start_pos <= line_len); /* caller should have checked */
993
994 const unsigned char* p = line + start_pos; /* modified by re2c */
995
996 /* Echo and History lexer apparently need this, but others don't */
997 __attribute__((unused)) const unsigned char* YYMARKER;
998
999 for (;;) {
1000 /*!re2c
1001
1002 "\"" { *id = id__Left_DoubleQuote; break; }
1003 "j\"" { *id = id__Left_JDoubleQuote; break; }
1004 "u'" { *id = id__Left_USingleQuote; break; }
1005 "'" { *id = id__Left_USingleQuote; break; }
1006 "b'" { *id = id__Left_BSingleQuote; break; }
1007 "[" { *id = id__J8_LBracket; break; }
1008 "]" { *id = id__J8_RBracket; break; }
1009 "{" { *id = id__J8_LBrace; break; }
1010 "}" { *id = id__J8_RBrace; break; }
1011 "(" { *id = id__J8_LParen; break; }
1012 ")" { *id = id__J8_RParen; break; }
1013 "," { *id = id__J8_Comma; break; }
1014 ":" { *id = id__J8_Colon; break; }
1015 "null" { *id = id__J8_Null; break; }
1016 "true" { *id = id__J8_Bool; break; }
1017 "false" { *id = id__J8_Bool; break; }
1018 "-" ? ([1-9][0-9]* | [0-9]) { *id = id__J8_Int; break; }
1019 "-" ? ([1-9][0-9]* | [0-9])("." [0-9]+ )? ([eE][\-+]? [0-9]+ )? { *id = id__J8_Float; break; }
1020 [a-zA-Z_][a-zA-Z0-9_]* { *id = id__J8_Identifier; break; }
1021 [~!@$%^&*+=|;./<>?\-]+ { *id = id__J8_Operator; break; }
1022 [ \r\t]+ { *id = id__Ignored_Space; break; }
1023 "\n" { *id = id__Ignored_Newline; break; }
1024 "#" [^\n\x00]* { *id = id__Ignored_Comment; break; }
1025 [^\x00] { *id = id__Unknown_Tok; break; }
1026 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1027
1028 */
1029 }
1030 *end_pos = p - line; /* relative */
1031}
1032
1033
1034static inline void MatchJ8LinesToken(const unsigned char* line, int line_len,
1035 int start_pos, int* id, int* end_pos) {
1036 assert(start_pos <= line_len); /* caller should have checked */
1037
1038 const unsigned char* p = line + start_pos; /* modified by re2c */
1039
1040 /* Echo and History lexer apparently need this, but others don't */
1041 __attribute__((unused)) const unsigned char* YYMARKER;
1042
1043 for (;;) {
1044 /*!re2c
1045
1046 "\"" { *id = id__Left_DoubleQuote; break; }
1047 "j\"" { *id = id__Left_JDoubleQuote; break; }
1048 "u'" { *id = id__Left_USingleQuote; break; }
1049 "'" { *id = id__Left_USingleQuote; break; }
1050 "b'" { *id = id__Left_BSingleQuote; break; }
1051 [ \r\t]+ { *id = id__WS_Space; break; }
1052 "\n" { *id = id__J8_Newline; break; }
1053 [\x01-\x1f] { *id = id__Char_AsciiControl; break; }
1054 [^ \t\r\n'"\x00-\x1f]+ { *id = id__Lit_Chars; break; }
1055 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1056
1057 */
1058 }
1059 *end_pos = p - line; /* relative */
1060}
1061
1062
1063static inline void MatchJ8StrToken(const unsigned char* line, int line_len,
1064 int start_pos, int* id, int* end_pos) {
1065 assert(start_pos <= line_len); /* caller should have checked */
1066
1067 const unsigned char* p = line + start_pos; /* modified by re2c */
1068
1069 /* Echo and History lexer apparently need this, but others don't */
1070 __attribute__((unused)) const unsigned char* YYMARKER;
1071
1072 for (;;) {
1073 /*!re2c
1074
1075 "'" { *id = id__Right_SingleQuote; break; }
1076 "\\" [\\"/bfnrt] { *id = id__Char_OneChar; break; }
1077 "\\'" { *id = id__Char_OneChar; break; }
1078 "\\" "y" [0-9a-fA-F]{2,2} { *id = id__Char_YHex; break; }
1079 "\\" [uU]"{" [0-9a-fA-F]{1,6} "}" { *id = id__Char_UBraced; break; }
1080 "\\" { *id = id__Unknown_Backslash; break; }
1081 [\x01-\x1f] { *id = id__Char_AsciiControl; break; }
1082 [^\\'\x00-\x1f]+ { *id = id__Lit_Chars; break; }
1083 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1084
1085 */
1086 }
1087 *end_pos = p - line; /* relative */
1088}
1089
1090
1091static inline void MatchJsonStrToken(const unsigned char* line, int line_len,
1092 int start_pos, int* id, int* end_pos) {
1093 assert(start_pos <= line_len); /* caller should have checked */
1094
1095 const unsigned char* p = line + start_pos; /* modified by re2c */
1096
1097 /* Echo and History lexer apparently need this, but others don't */
1098 __attribute__((unused)) const unsigned char* YYMARKER;
1099
1100 for (;;) {
1101 /*!re2c
1102
1103 "\"" { *id = id__Right_DoubleQuote; break; }
1104 "\\" [\\"/bfnrt] { *id = id__Char_OneChar; break; }
1105 "\\" "u" [0-9a-fA-F]{4,4} { *id = id__Char_Unicode4; break; }
1106 "\\" "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; }
1107 "\\" { *id = id__Unknown_Backslash; break; }
1108 [\x01-\x1f] { *id = id__Char_AsciiControl; break; }
1109 [^\\"\x00-\x1f]+ { *id = id__Lit_Chars; break; }
1110 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1111
1112 */
1113 }
1114 *end_pos = p - line; /* relative */
1115}
1116
1117
1118static inline void MatchShNumberToken(const unsigned char* line, int line_len,
1119 int start_pos, int* id, int* end_pos) {
1120 assert(start_pos <= line_len); /* caller should have checked */
1121
1122 const unsigned char* p = line + start_pos; /* modified by re2c */
1123
1124 /* Echo and History lexer apparently need this, but others don't */
1125 __attribute__((unused)) const unsigned char* YYMARKER;
1126
1127 for (;;) {
1128 /*!re2c
1129
1130 "0" { *id = id__ShNumber_Dec; break; }
1131 [1-9][0-9]* { *id = id__ShNumber_Dec; break; }
1132 "0" [0-7]+ { *id = id__ShNumber_Oct; break; }
1133 "0" "x" [0-9A-Fa-f]+ { *id = id__ShNumber_Hex; break; }
1134 [1-9][0-9]* "#" [0-9a-zA-Z@_]+ { *id = id__ShNumber_BaseN; break; }
1135 [^\x00] { *id = id__Unknown_Tok; break; }
1136 "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; }
1137
1138 */
1139 }
1140 *end_pos = p - line; /* relative */
1141}
1142
1143
1144static inline int IsValidVarName(const unsigned char* s, int len) {
1145 const unsigned char* p = s; /* modified by re2c */
1146 const unsigned char* end = s + len;
1147
1148 /* MatchBraceRangeToken needs this, but others don't */
1149 __attribute__((unused)) const unsigned char* YYMARKER;
1150
1151 /*!re2c
1152 re2c:define:YYCTYPE = "unsigned char";
1153 re2c:define:YYCURSOR = p;
1154 [a-zA-Z_][a-zA-Z0-9_]* { return p == end; } // Match must be anchored right, like $
1155 * { return 0; }
1156 */
1157}
1158
1159
1160static inline int ShouldHijack(const unsigned char* s, int len) {
1161 const unsigned char* p = s; /* modified by re2c */
1162 const unsigned char* end = s + len;
1163
1164 /* MatchBraceRangeToken needs this, but others don't */
1165 __attribute__((unused)) const unsigned char* YYMARKER;
1166
1167 /*!re2c
1168 re2c:define:YYCTYPE = "unsigned char";
1169 re2c:define:YYCURSOR = p;
1170 "#" "!" [^\x00]* "s" "h" [ \t\r\n][^\x00]* { return p == end; } // Match must be anchored right, like $
1171 * { return 0; }
1172 */
1173}
1174
1175
1176static inline int LooksLikeInteger(const unsigned char* s, int len) {
1177 const unsigned char* p = s; /* modified by re2c */
1178 const unsigned char* end = s + len;
1179
1180 /* MatchBraceRangeToken needs this, but others don't */
1181 __attribute__((unused)) const unsigned char* YYMARKER;
1182
1183 /*!re2c
1184 re2c:define:YYCTYPE = "unsigned char";
1185 re2c:define:YYCURSOR = p;
1186 [ \t\r\n]* "-" ? [0-9]+ [ \t\r\n]* { return p == end; } // Match must be anchored right, like $
1187 * { return 0; }
1188 */
1189}
1190
1191
1192static inline int LooksLikeYshInt(const unsigned char* s, int len) {
1193 const unsigned char* p = s; /* modified by re2c */
1194 const unsigned char* end = s + len;
1195
1196 /* MatchBraceRangeToken needs this, but others don't */
1197 __attribute__((unused)) const unsigned char* YYMARKER;
1198
1199 /*!re2c
1200 re2c:define:YYCTYPE = "unsigned char";
1201 re2c:define:YYCURSOR = p;
1202 [ \t\r\n]* "-" ? [0-9]("_" ? [0-9])* [ \t\r\n]* { return p == end; } // Match must be anchored right, like $
1203 * { return 0; }
1204 */
1205}
1206
1207
1208static inline int LooksLikeYshFloat(const unsigned char* s, int len) {
1209 const unsigned char* p = s; /* modified by re2c */
1210 const unsigned char* end = s + len;
1211
1212 /* MatchBraceRangeToken needs this, but others don't */
1213 __attribute__((unused)) const unsigned char* YYMARKER;
1214
1215 /*!re2c
1216 re2c:define:YYCTYPE = "unsigned char";
1217 re2c:define:YYCURSOR = p;
1218 [ \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 $
1219 * { return 0; }
1220 */
1221}
1222
1223
1224static inline int BracketUnary(const unsigned char* s, int len) {
1225 const unsigned char* p = s; /* modified by re2c */
1226 const unsigned char* end = s + len;
1227
1228 __attribute__((unused)) const unsigned char* YYMARKER;
1229 int id;
1230
1231 for (;;) {
1232 /*!re2c
1233
1234 "-G" { id = id__BoolUnary_G; break; }
1235 "-L" { id = id__BoolUnary_L; break; }
1236 "-N" { id = id__BoolUnary_N; break; }
1237 "-O" { id = id__BoolUnary_O; break; }
1238 "-R" { id = id__BoolUnary_R; break; }
1239 "-S" { id = id__BoolUnary_S; break; }
1240 "-a" { id = id__BoolUnary_a; break; }
1241 "-b" { id = id__BoolUnary_b; break; }
1242 "-c" { id = id__BoolUnary_c; break; }
1243 "-d" { id = id__BoolUnary_d; break; }
1244 "-e" { id = id__BoolUnary_e; break; }
1245 "-f" { id = id__BoolUnary_f; break; }
1246 "-g" { id = id__BoolUnary_g; break; }
1247 "-h" { id = id__BoolUnary_h; break; }
1248 "-k" { id = id__BoolUnary_k; break; }
1249 "-n" { id = id__BoolUnary_n; break; }
1250 "-o" { id = id__BoolUnary_o; break; }
1251 "-p" { id = id__BoolUnary_p; break; }
1252 "-r" { id = id__BoolUnary_r; break; }
1253 "-s" { id = id__BoolUnary_s; break; }
1254 "-t" { id = id__BoolUnary_t; break; }
1255 "-u" { id = id__BoolUnary_u; break; }
1256 "-v" { id = id__BoolUnary_v; break; }
1257 "-w" { id = id__BoolUnary_w; break; }
1258 "-x" { id = id__BoolUnary_x; break; }
1259 "-z" { id = id__BoolUnary_z; break; }
1260 * { return id__Undefined_Tok; }
1261
1262 */
1263 }
1264 // must be an exact match
1265 return (p == end) ? id : id__Undefined_Tok;
1266}
1267
1268
1269static inline int BracketBinary(const unsigned char* s, int len) {
1270 const unsigned char* p = s; /* modified by re2c */
1271 const unsigned char* end = s + len;
1272
1273 __attribute__((unused)) const unsigned char* YYMARKER;
1274 int id;
1275
1276 for (;;) {
1277 /*!re2c
1278
1279 "!=" { id = id__BoolBinary_NEqual; break; }
1280 "-ef" { id = id__BoolBinary_ef; break; }
1281 "-eq" { id = id__BoolBinary_eq; break; }
1282 "-ge" { id = id__BoolBinary_ge; break; }
1283 "-gt" { id = id__BoolBinary_gt; break; }
1284 "-le" { id = id__BoolBinary_le; break; }
1285 "-lt" { id = id__BoolBinary_lt; break; }
1286 "-ne" { id = id__BoolBinary_ne; break; }
1287 "-nt" { id = id__BoolBinary_nt; break; }
1288 "-ot" { id = id__BoolBinary_ot; break; }
1289 "<" { id = id__Op_Less; break; }
1290 "=" { id = id__BoolBinary_Equal; break; }
1291 "==" { id = id__BoolBinary_DEqual; break; }
1292 ">" { id = id__Op_Great; break; }
1293 * { return id__Undefined_Tok; }
1294
1295 */
1296 }
1297 // must be an exact match
1298 return (p == end) ? id : id__Undefined_Tok;
1299}
1300
1301
1302static inline int BracketOther(const unsigned char* s, int len) {
1303 const unsigned char* p = s; /* modified by re2c */
1304 const unsigned char* end = s + len;
1305
1306 __attribute__((unused)) const unsigned char* YYMARKER;
1307 int id;
1308
1309 for (;;) {
1310 /*!re2c
1311
1312 "!" { id = id__KW_Bang; break; }
1313 "(" { id = id__Op_LParen; break; }
1314 ")" { id = id__Op_RParen; break; }
1315 "]" { id = id__Arith_RBracket; break; }
1316 * { return id__Undefined_Tok; }
1317
1318 */
1319 }
1320 // must be an exact match
1321 return (p == end) ? id : id__Undefined_Tok;
1322}
1323