/* Common stuff */ /*!re2c re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = p; re2c:yyfill:enable = 0; // generated code doesn't ask for more input */ static inline void MatchOshToken(int lex_mode, const unsigned char* line, int line_len, int start_pos, int* id, int* end_pos) { assert(start_pos <= line_len); /* caller should have checked */ const unsigned char* p = line + start_pos; /* modified by re2c */ //printf("p: %p q: %p\n", p, q); const unsigned char* YYMARKER; /* why do we need this? */ switch (lex_mode) { case lex_mode__Comment: for (;;) { /*!re2c [^\n\x00]* { *id = id__Ignored_Comment; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__ShCommand: for (;;) { /*!re2c [a-zA-Z_][a-zA-Z0-9_]* "+" ? "=" { *id = id__Lit_VarLike; break; } [a-zA-Z_][a-zA-Z0-9_]* "[" { *id = id__Lit_ArrayLhsOpen; break; } "]" "+" ? "=" { *id = id__Lit_ArrayLhsClose; break; } "((" { *id = id__Op_DLeftParen; break; } "[" { *id = id__Lit_LBracket; break; } "]" { *id = id__Lit_RBracket; break; } "*" { *id = id__Lit_Star; break; } "?" { *id = id__Lit_QMark; break; } "{" { *id = id__Lit_LBrace; break; } "}" { *id = id__Lit_RBrace; break; } "," { *id = id__Lit_Comma; break; } "=" { *id = id__Lit_Equals; break; } "@" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Lit_Splice; break; } [0-9]? [0-9]? "<" { *id = id__Redir_Less; break; } [0-9]? [0-9]? ">" { *id = id__Redir_Great; break; } [0-9]? [0-9]? "<" "<" { *id = id__Redir_DLess; break; } [0-9]? [0-9]? "<" "<" "<" { *id = id__Redir_TLess; break; } [0-9]? [0-9]? ">" ">" { *id = id__Redir_DGreat; break; } [0-9]? [0-9]? "<" "<" "-" { *id = id__Redir_DLessDash; break; } [0-9]? [0-9]? ">" "&" { *id = id__Redir_GreatAnd; break; } [0-9]? [0-9]? "<" "&" { *id = id__Redir_LessAnd; break; } [0-9]? [0-9]? "<" ">" { *id = id__Redir_LessGreat; break; } [0-9]? [0-9]? ">" "|" { *id = id__Redir_Clobber; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" { *id = id__Redir_Less; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" { *id = id__Redir_Great; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "<" { *id = id__Redir_DLess; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "<" "<" { *id = id__Redir_TLess; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" ">" { *id = id__Redir_DGreat; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "<" "-" { *id = id__Redir_DLessDash; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" "&" { *id = id__Redir_GreatAnd; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" "&" { *id = id__Redir_LessAnd; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" "<" ">" { *id = id__Redir_LessGreat; break; } "{" [a-zA-Z_][a-zA-Z0-9_]* "}" ">" "|" { *id = id__Redir_Clobber; break; } "&>" { *id = id__Redir_AndGreat; break; } "&>>" { *id = id__Redir_AndDGreat; break; } "[[" { *id = id__KW_DLeftBracket; break; } "!" { *id = id__KW_Bang; break; } "for" { *id = id__KW_For; break; } "while" { *id = id__KW_While; break; } "until" { *id = id__KW_Until; break; } "do" { *id = id__KW_Do; break; } "done" { *id = id__KW_Done; break; } "in" { *id = id__KW_In; break; } "case" { *id = id__KW_Case; break; } "esac" { *id = id__KW_Esac; break; } "if" { *id = id__KW_If; break; } "fi" { *id = id__KW_Fi; break; } "then" { *id = id__KW_Then; break; } "else" { *id = id__KW_Else; break; } "elif" { *id = id__KW_Elif; break; } "function" { *id = id__KW_Function; break; } "time" { *id = id__KW_Time; break; } "const" { *id = id__KW_Const; break; } "var" { *id = id__KW_Var; break; } "setvar" { *id = id__KW_SetVar; break; } "setref" { *id = id__KW_SetRef; break; } "set" { *id = id__KW_Set; break; } "setlocal" { *id = id__KW_SetLocal; break; } "setglobal" { *id = id__KW_SetGlobal; break; } "proc" { *id = id__KW_Proc; break; } "pass" { *id = id__KW_Pass; break; } "func" { *id = id__KW_Func; break; } "break" { *id = id__ControlFlow_Break; break; } "continue" { *id = id__ControlFlow_Continue; break; } "return" { *id = id__ControlFlow_Return; break; } "exit" { *id = id__ControlFlow_Exit; break; } "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "\"" { *id = id__Left_DoubleQuote; break; } "'" { *id = id__Left_SingleQuoteRaw; break; } "$\"" { *id = id__Left_DollarDoubleQuote; break; } "$'" { *id = id__Left_SingleQuoteC; break; } "<(" { *id = id__Left_ProcSubIn; break; } ">(" { *id = id__Left_ProcSubOut; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } [a-zA-Z0-9_/.\-]+ { *id = id__Lit_Chars; break; } "~" [a-zA-Z0-9_.\-]* { *id = id__Lit_TildeLike; break; } "#" { *id = id__Lit_Pound; break; } [ \t\r]+ { *id = id__WS_Space; break; } "\n" { *id = id__Op_Newline; break; } "&" { *id = id__Op_Amp; break; } "|" { *id = id__Op_Pipe; break; } "|&" { *id = id__Op_PipeAmp; break; } "&&" { *id = id__Op_DAmp; break; } "||" { *id = id__Op_DPipe; break; } ";" { *id = id__Op_Semi; break; } ";;" { *id = id__Op_DSemi; break; } "(" { *id = id__Op_LParen; break; } ")" { *id = id__Op_RParen; break; } [^\x00] { *id = id__Lit_Other; break; } "@(" { *id = id__ExtGlob_At; break; } "*(" { *id = id__ExtGlob_Star; break; } "+(" { *id = id__ExtGlob_Plus; break; } "?(" { *id = id__ExtGlob_QMark; break; } "!(" { *id = id__ExtGlob_Bang; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__Backtick: for (;;) { /*!re2c "`" { *id = id__Backtick_Right; break; } "\\" [$`"\\] { *id = id__Backtick_Quoted; break; } [^`\\\x00]+ { *id = id__Backtick_Other; break; } [^\x00] { *id = id__Backtick_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__DBracket: for (;;) { /*!re2c "]]" { *id = id__Lit_DRightBracket; break; } "!" { *id = id__KW_Bang; break; } "<" { *id = id__Op_Less; break; } ">" { *id = id__Op_Great; break; } "-z" { *id = id__BoolUnary_z; break; } "-n" { *id = id__BoolUnary_n; break; } "-o" { *id = id__BoolUnary_o; break; } "-t" { *id = id__BoolUnary_t; break; } "-v" { *id = id__BoolUnary_v; break; } "-R" { *id = id__BoolUnary_R; break; } "-a" { *id = id__BoolUnary_a; break; } "-b" { *id = id__BoolUnary_b; break; } "-c" { *id = id__BoolUnary_c; break; } "-d" { *id = id__BoolUnary_d; break; } "-e" { *id = id__BoolUnary_e; break; } "-f" { *id = id__BoolUnary_f; break; } "-g" { *id = id__BoolUnary_g; break; } "-h" { *id = id__BoolUnary_h; break; } "-k" { *id = id__BoolUnary_k; break; } "-L" { *id = id__BoolUnary_L; break; } "-p" { *id = id__BoolUnary_p; break; } "-r" { *id = id__BoolUnary_r; break; } "-s" { *id = id__BoolUnary_s; break; } "-S" { *id = id__BoolUnary_S; break; } "-u" { *id = id__BoolUnary_u; break; } "-w" { *id = id__BoolUnary_w; break; } "-x" { *id = id__BoolUnary_x; break; } "-O" { *id = id__BoolUnary_O; break; } "-G" { *id = id__BoolUnary_G; break; } "-N" { *id = id__BoolUnary_N; break; } "=" { *id = id__BoolBinary_GlobEqual; break; } "==" { *id = id__BoolBinary_GlobDEqual; break; } "!=" { *id = id__BoolBinary_GlobNEqual; break; } "=~" { *id = id__BoolBinary_EqualTilde; break; } "-ef" { *id = id__BoolBinary_ef; break; } "-nt" { *id = id__BoolBinary_nt; break; } "-ot" { *id = id__BoolBinary_ot; break; } "-eq" { *id = id__BoolBinary_eq; break; } "-ne" { *id = id__BoolBinary_ne; break; } "-gt" { *id = id__BoolBinary_gt; break; } "-ge" { *id = id__BoolBinary_ge; break; } "-lt" { *id = id__BoolBinary_lt; break; } "-le" { *id = id__BoolBinary_le; break; } "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "\"" { *id = id__Left_DoubleQuote; break; } "'" { *id = id__Left_SingleQuoteRaw; break; } "$\"" { *id = id__Left_DollarDoubleQuote; break; } "$'" { *id = id__Left_SingleQuoteC; break; } "<(" { *id = id__Left_ProcSubIn; break; } ">(" { *id = id__Left_ProcSubOut; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } [a-zA-Z0-9_/.\-]+ { *id = id__Lit_Chars; break; } "~" [a-zA-Z0-9_.\-]* { *id = id__Lit_TildeLike; break; } "#" { *id = id__Lit_Pound; break; } [ \t\r]+ { *id = id__WS_Space; break; } "\n" { *id = id__Op_Newline; break; } "&" { *id = id__Op_Amp; break; } "|" { *id = id__Op_Pipe; break; } "|&" { *id = id__Op_PipeAmp; break; } "&&" { *id = id__Op_DAmp; break; } "||" { *id = id__Op_DPipe; break; } ";" { *id = id__Op_Semi; break; } ";;" { *id = id__Op_DSemi; break; } "(" { *id = id__Op_LParen; break; } ")" { *id = id__Op_RParen; break; } [^\x00] { *id = id__Lit_Other; break; } "@(" { *id = id__ExtGlob_At; break; } "*(" { *id = id__ExtGlob_Star; break; } "+(" { *id = id__ExtGlob_Plus; break; } "?(" { *id = id__ExtGlob_QMark; break; } "!(" { *id = id__ExtGlob_Bang; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__SQ_Raw: for (;;) { /*!re2c [^'\x00]+ { *id = id__Lit_Chars; break; } "'" { *id = id__Right_SingleQuote; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__DQ: for (;;) { /*!re2c "\\" [$`"\\] { *id = id__Lit_EscapedChar; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } [^$`"\x00\\]+ { *id = id__Lit_Chars; break; } "\"" { *id = id__Right_DoubleQuote; break; } [^\x00] { *id = id__Lit_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__SQ_C: for (;;) { /*!re2c "\\" "x" [0-9a-fA-F]{1,2} { *id = id__Char_Hex; break; } "\\" "u" [0-9a-fA-F]{1,4} { *id = id__Char_Unicode4; break; } "\\" "U" [0-9a-fA-F]{1,8} { *id = id__Char_Unicode8; break; } "\\" [0abeEfrtnv\\] { *id = id__Char_OneChar; break; } "\\\n" { *id = id__Char_Literals; break; } "\\" { *id = id__Char_BadBackslash; break; } "\\" [0-7]{1,3} { *id = id__Char_Octal3; break; } "\\'" { *id = id__Char_OneChar; break; } "\\\"" { *id = id__Char_OneChar; break; } [^\\'\x00]+ { *id = id__Char_Literals; break; } "'" { *id = id__Right_SingleQuote; break; } "\\\x00" { *id = id__Unknown_Tok; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__Arith: for (;;) { /*!re2c "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } "\"" { *id = id__Left_DoubleQuote; break; } "'" { *id = id__Left_SingleQuoteRaw; break; } "$\"" { *id = id__Left_DollarDoubleQuote; break; } "$'" { *id = id__Left_SingleQuoteC; break; } "<(" { *id = id__Left_ProcSubIn; break; } ">(" { *id = id__Left_ProcSubOut; break; } [ \t\r\n]+ { *id = id__Ignored_Space; break; } [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Lit_ArithVarLike; break; } [0-9]+ { *id = id__Lit_Digits; break; } "@" { *id = id__Lit_At; break; } "#" { *id = id__Lit_Pound; break; } ";" { *id = id__Arith_Semi; break; } "," { *id = id__Arith_Comma; break; } "+" { *id = id__Arith_Plus; break; } "-" { *id = id__Arith_Minus; break; } "*" { *id = id__Arith_Star; break; } "/" { *id = id__Arith_Slash; break; } "%" { *id = id__Arith_Percent; break; } "++" { *id = id__Arith_DPlus; break; } "--" { *id = id__Arith_DMinus; break; } "**" { *id = id__Arith_DStar; break; } "(" { *id = id__Arith_LParen; break; } ")" { *id = id__Arith_RParen; break; } "[" { *id = id__Arith_LBracket; break; } "]" { *id = id__Arith_RBracket; break; } "}" { *id = id__Arith_RBrace; break; } "?" { *id = id__Arith_QMark; break; } ":" { *id = id__Arith_Colon; break; } "<=" { *id = id__Arith_LessEqual; break; } "<" { *id = id__Arith_Less; break; } ">=" { *id = id__Arith_GreatEqual; break; } ">" { *id = id__Arith_Great; break; } "==" { *id = id__Arith_DEqual; break; } "!=" { *id = id__Arith_NEqual; break; } "&&" { *id = id__Arith_DAmp; break; } "||" { *id = id__Arith_DPipe; break; } "!" { *id = id__Arith_Bang; break; } ">>" { *id = id__Arith_DGreat; break; } "<<" { *id = id__Arith_DLess; break; } "&" { *id = id__Arith_Amp; break; } "|" { *id = id__Arith_Pipe; break; } "^" { *id = id__Arith_Caret; break; } "~" { *id = id__Arith_Tilde; break; } "=" { *id = id__Arith_Equal; break; } "+=" { *id = id__Arith_PlusEqual; break; } "-=" { *id = id__Arith_MinusEqual; break; } "*=" { *id = id__Arith_StarEqual; break; } "/=" { *id = id__Arith_SlashEqual; break; } "%=" { *id = id__Arith_PercentEqual; break; } ">>=" { *id = id__Arith_DGreatEqual; break; } "<<=" { *id = id__Arith_DLessEqual; break; } "&=" { *id = id__Arith_AmpEqual; break; } "|=" { *id = id__Arith_PipeEqual; break; } "^=" { *id = id__Arith_CaretEqual; break; } "\\\n" { *id = id__Ignored_LineCont; break; } [^\x00] { *id = id__Unknown_Tok; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__ExtGlob: for (;;) { /*!re2c "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "\"" { *id = id__Left_DoubleQuote; break; } "'" { *id = id__Left_SingleQuoteRaw; break; } "$\"" { *id = id__Left_DollarDoubleQuote; break; } "$'" { *id = id__Left_SingleQuoteC; break; } "<(" { *id = id__Left_ProcSubIn; break; } ">(" { *id = id__Left_ProcSubOut; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } "@(" { *id = id__ExtGlob_At; break; } "*(" { *id = id__ExtGlob_Star; break; } "+(" { *id = id__ExtGlob_Plus; break; } "?(" { *id = id__ExtGlob_QMark; break; } "!(" { *id = id__ExtGlob_Bang; break; } [^\\$`"'|)@*+!?\x00]+ { *id = id__Lit_Chars; break; } "|" { *id = id__Op_Pipe; break; } ")" { *id = id__Op_RParen; break; } [^\x00] { *id = id__Lit_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__VSub_1: for (;;) { /*!re2c [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_Name; break; } [0-9]+ { *id = id__VSub_Number; break; } "!" { *id = id__VSub_Bang; break; } "@" { *id = id__VSub_At; break; } "#" { *id = id__VSub_Pound; break; } "$" { *id = id__VSub_Dollar; break; } "*" { *id = id__VSub_Star; break; } "-" { *id = id__VSub_Hyphen; break; } "?" { *id = id__VSub_QMark; break; } "}" { *id = id__Right_DollarBrace; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "\n" { *id = id__Unknown_Tok; break; } [^\x00] { *id = id__Unknown_Tok; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__VSub_2: for (;;) { /*!re2c ":-" { *id = id__VTest_ColonHyphen; break; } "-" { *id = id__VTest_Hyphen; break; } ":=" { *id = id__VTest_ColonEquals; break; } "=" { *id = id__VTest_Equals; break; } ":?" { *id = id__VTest_ColonQMark; break; } "?" { *id = id__VTest_QMark; break; } ":+" { *id = id__VTest_ColonPlus; break; } "+" { *id = id__VTest_Plus; break; } "@Q" { *id = id__VOp0_Q; break; } "@E" { *id = id__VOp0_E; break; } "@P" { *id = id__VOp0_P; break; } "@A" { *id = id__VOp0_A; break; } "@a" { *id = id__VOp0_a; break; } "%" { *id = id__VOp1_Percent; break; } "%%" { *id = id__VOp1_DPercent; break; } "#" { *id = id__VOp1_Pound; break; } "##" { *id = id__VOp1_DPound; break; } "^" { *id = id__VOp1_Caret; break; } "^^" { *id = id__VOp1_DCaret; break; } "," { *id = id__VOp1_Comma; break; } ",," { *id = id__VOp1_DComma; break; } "/" { *id = id__VOp2_Slash; break; } ":" { *id = id__VOp2_Colon; break; } "[" { *id = id__VOp2_LBracket; break; } "]" { *id = id__VOp2_RBracket; break; } "@" { *id = id__VOp3_At; break; } "*" { *id = id__VOp3_Star; break; } "}" { *id = id__Right_DollarBrace; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "\n" { *id = id__Unknown_Tok; break; } [^\x00] { *id = id__Unknown_Tok; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__VSub_ArgUnquoted: for (;;) { /*!re2c "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "/" { *id = id__Lit_Slash; break; } "#" { *id = id__Lit_Pound; break; } "%" { *id = id__Lit_Percent; break; } "}" { *id = id__Right_DollarBrace; break; } "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "\"" { *id = id__Left_DoubleQuote; break; } "'" { *id = id__Left_SingleQuoteRaw; break; } "$\"" { *id = id__Left_DollarDoubleQuote; break; } "$'" { *id = id__Left_SingleQuoteC; break; } "<(" { *id = id__Left_ProcSubIn; break; } ">(" { *id = id__Left_ProcSubOut; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } [^$`/}"'\x00\\#%<>]+ { *id = id__Lit_Chars; break; } [^\x00] { *id = id__Lit_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__VSub_ArgDQ: for (;;) { /*!re2c "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; } "\\\n" { *id = id__Ignored_LineCont; break; } "/" { *id = id__Lit_Slash; break; } "#" { *id = id__Lit_Pound; break; } "%" { *id = id__Lit_Percent; break; } "}" { *id = id__Right_DollarBrace; break; } "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } [^$`/}"\x00\\#%]+ { *id = id__Lit_Chars; break; } "\"" { *id = id__Left_DoubleQuote; break; } "$'" { *id = id__Left_SingleQuoteC; break; } [^\x00] { *id = id__Lit_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__BashRegex: for (;;) { /*!re2c "`" { *id = id__Left_Backtick; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$((" { *id = id__Left_DollarDParen; break; } "$[" { *id = id__Left_DollarBracket; break; } "\"" { *id = id__Left_DoubleQuote; break; } "'" { *id = id__Left_SingleQuoteRaw; break; } "$\"" { *id = id__Left_DollarDoubleQuote; break; } "$'" { *id = id__Left_SingleQuoteC; break; } "<(" { *id = id__Left_ProcSubIn; break; } ">(" { *id = id__Left_ProcSubOut; break; } "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } [a-zA-Z0-9_/\-]+ { *id = id__Lit_Chars; break; } [ \t\r]+ { *id = id__WS_Space; break; } "\\" [*+?.^$[\]] { *id = id__Lit_RegexMeta; break; } "\\" [^\n\x00] { *id = id__Lit_EscapedChar; break; } "\\\n" { *id = id__Ignored_LineCont; break; } [^\x00] { *id = id__Lit_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__PrintfOuter: for (;;) { /*!re2c "\\" "x" [0-9a-fA-F]{1,2} { *id = id__Char_Hex; break; } "\\" "u" [0-9a-fA-F]{1,4} { *id = id__Char_Unicode4; break; } "\\" "U" [0-9a-fA-F]{1,8} { *id = id__Char_Unicode8; break; } "\\" [0abeEfrtnv\\] { *id = id__Char_OneChar; break; } "\\\n" { *id = id__Char_Literals; break; } "\\" { *id = id__Char_BadBackslash; break; } "\\" [0-7]{1,3} { *id = id__Char_Octal3; break; } [^%\\\x00]+ { *id = id__Char_Literals; break; } "%%" { *id = id__Format_EscapedPercent; break; } "%" { *id = id__Format_Percent; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__PrintfPercent: for (;;) { /*!re2c [\- +#] { *id = id__Format_Flag; break; } "0" { *id = id__Format_Zero; break; } [1-9][0-9]* { *id = id__Format_Num; break; } "*" { *id = id__Format_Star; break; } "." { *id = id__Format_Dot; break; } [disqbcouxXeEfFgG] { *id = id__Format_Type; break; } "(" [^()]* ")" "T" { *id = id__Format_Time; break; } [^\x00] { *id = id__Unknown_Tok; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; case lex_mode__Expr: for (;;) { /*!re2c "$" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__VSub_DollarName; break; } "$" [0-9] { *id = id__VSub_Number; break; } "$!" { *id = id__VSub_Bang; break; } "$@" { *id = id__VSub_At; break; } "$#" { *id = id__VSub_Pound; break; } "$$" { *id = id__VSub_Dollar; break; } "$*" { *id = id__VSub_Star; break; } "$-" { *id = id__VSub_Hyphen; break; } "$?" { *id = id__VSub_QMark; break; } "$(" { *id = id__Left_DollarParen; break; } "${" { *id = id__Left_DollarBrace; break; } "$[" { *id = id__Left_DollarBracket; break; } "%(" { *id = id__Expr_Reserved; break; } "%{" { *id = id__Expr_Reserved; break; } "%[" { *id = id__Expr_Reserved; break; } "\"" { *id = id__Left_DoubleQuote; break; } "'" { *id = id__Left_SingleQuoteRaw; break; } "r'" { *id = id__Left_SingleQuoteRaw; break; } "c'" { *id = id__Left_SingleQuoteC; break; } "$'" { *id = id__Left_SingleQuoteC; break; } "@(" { *id = id__Left_AtParen; break; } "@[" { *id = id__Left_AtBracket; break; } "@{" { *id = id__Expr_Reserved; break; } ";" { *id = id__Op_Semi; break; } "(" { *id = id__Op_LParen; break; } ")" { *id = id__Op_RParen; break; } "[" { *id = id__Op_LBracket; break; } "]" { *id = id__Op_RBracket; break; } "{" { *id = id__Op_LBrace; break; } "}" { *id = id__Op_RBrace; break; } "null" { *id = id__Expr_Null; break; } "true" { *id = id__Expr_True; break; } "false" { *id = id__Expr_False; break; } "div" { *id = id__Expr_Div; break; } "mod" { *id = id__Expr_Mod; break; } "xor" { *id = id__Expr_Xor; break; } "and" { *id = id__Expr_And; break; } "or" { *id = id__Expr_Or; break; } "not" { *id = id__Expr_Not; break; } "for" { *id = id__Expr_For; break; } "is" { *id = id__Expr_Is; break; } "in" { *id = id__Expr_In; break; } "if" { *id = id__Expr_If; break; } "else" { *id = id__Expr_Else; break; } "func" { *id = id__Expr_Func; break; } "\\" [0rtn\\"'] { *id = id__Char_OneChar; break; } "\\" "x" [0-9a-fA-F]{2,2} { *id = id__Char_Hex; break; } "\\" "u" [0-9a-fA-F]{4,4} { *id = id__Char_Unicode4; break; } "\\" "U" [0-9a-fA-F]{8,8} { *id = id__Char_Unicode8; break; } "0" { *id = id__Expr_DecInt; break; } [1-9]("_" ? [0-9])* { *id = id__Expr_DecInt; break; } "0" [bB]("_" ? [01])+ { *id = id__Expr_BinInt; break; } "0" [oO]("_" ? [0-7])+ { *id = id__Expr_OctInt; break; } "0" [xX]("_" ? [0-9a-fA-F])+ { *id = id__Expr_HexInt; break; } [0-9]+ ("." [0-9]* )? ([eE][+\-]? [0-9]+ )? { *id = id__Expr_Float; break; } [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Expr_Name; break; } "%" [a-zA-Z_][a-zA-Z0-9_]* { *id = id__Expr_Symbol; break; } "," { *id = id__Arith_Comma; break; } ":" { *id = id__Arith_Colon; break; } "?" { *id = id__Arith_QMark; break; } "+" { *id = id__Arith_Plus; break; } "-" { *id = id__Arith_Minus; break; } "*" { *id = id__Arith_Star; break; } "^" { *id = id__Arith_Caret; break; } "/" { *id = id__Arith_Slash; break; } "<" { *id = id__Arith_Less; break; } ">" { *id = id__Arith_Great; break; } "<=" { *id = id__Arith_LessEqual; break; } ">=" { *id = id__Arith_GreatEqual; break; } "==" { *id = id__Arith_DEqual; break; } "!=" { *id = id__Arith_NEqual; break; } "&" { *id = id__Arith_Amp; break; } "|" { *id = id__Arith_Pipe; break; } ">>" { *id = id__Arith_DGreat; break; } "<<" { *id = id__Arith_DLess; break; } "~" { *id = id__Arith_Tilde; break; } "!~" { *id = id__Expr_NotTilde; break; } "=" { *id = id__Arith_Equal; break; } "+=" { *id = id__Arith_PlusEqual; break; } "-=" { *id = id__Arith_MinusEqual; break; } "*=" { *id = id__Arith_StarEqual; break; } "/=" { *id = id__Arith_SlashEqual; break; } "%=" { *id = id__Arith_PercentEqual; break; } "&=" { *id = id__Arith_AmpEqual; break; } "|=" { *id = id__Arith_PipeEqual; break; } "^=" { *id = id__Arith_CaretEqual; break; } ">>=" { *id = id__Arith_DGreatEqual; break; } "<<=" { *id = id__Arith_DLessEqual; break; } "." { *id = id__Expr_Dot; break; } "::" { *id = id__Expr_DColon; break; } "->" { *id = id__Expr_RArrow; break; } "$" { *id = id__Expr_Dollar; break; } "<-" { *id = id__Expr_Reserved; break; } "=>" { *id = id__Expr_RDArrow; break; } "..." { *id = id__Expr_Ellipsis; break; } "//" { *id = id__Expr_Reserved; break; } "///" { *id = id__Expr_Reserved; break; } "@" { *id = id__Expr_At; break; } "@@" { *id = id__Expr_DoubleAt; break; } "\n" { *id = id__Op_Newline; break; } "#" [^\n\x00]* { *id = id__Ignored_Comment; break; } [ \t\r]+ { *id = id__Ignored_Space; break; } "\\\n" { *id = id__Ignored_LineCont; break; } [^\x00] { *id = id__Unknown_Tok; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } break; default: assert(0); } *end_pos = p - line; /* relative */ } static inline void MatchEchoToken(const unsigned char* line, int line_len, int start_pos, int* id, int* end_pos) { assert(start_pos <= line_len); /* caller should have checked */ const unsigned char* p = line + start_pos; /* modified by re2c */ /* Echo and History lexer apparently need this, but others don't */ const unsigned char* YYMARKER; for (;;) { /*!re2c "\\" "x" [0-9a-fA-F]{1,2} { *id = id__Char_Hex; break; } "\\" "u" [0-9a-fA-F]{1,4} { *id = id__Char_Unicode4; break; } "\\" "U" [0-9a-fA-F]{1,8} { *id = id__Char_Unicode8; break; } "\\" [0abeEfrtnv\\] { *id = id__Char_OneChar; break; } "\\\n" { *id = id__Char_Literals; break; } "\\" { *id = id__Char_BadBackslash; break; } "\\" "0" [0-7]{1,3} { *id = id__Char_Octal4; break; } "\\c" { *id = id__Char_Stop; break; } [^\\\x00]+ { *id = id__Char_Literals; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } *end_pos = p - line; /* relative */ } static inline void MatchGlobToken(const unsigned char* line, int line_len, int start_pos, int* id, int* end_pos) { assert(start_pos <= line_len); /* caller should have checked */ const unsigned char* p = line + start_pos; /* modified by re2c */ /* Echo and History lexer apparently need this, but others don't */ const unsigned char* YYMARKER; for (;;) { /*!re2c "*" { *id = id__Glob_Star; break; } "?" { *id = id__Glob_QMark; break; } "!" { *id = id__Glob_Bang; break; } "^" { *id = id__Glob_Caret; break; } "[" { *id = id__Glob_LBracket; break; } "]" { *id = id__Glob_RBracket; break; } "\\" [^\x00] { *id = id__Glob_EscapedChar; break; } "\\" { *id = id__Glob_BadBackslash; break; } [a-zA-Z0-9_]+ { *id = id__Glob_CleanLiterals; break; } [^\x00] { *id = id__Glob_OtherLiteral; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } *end_pos = p - line; /* relative */ } static inline void MatchPS1Token(const unsigned char* line, int line_len, int start_pos, int* id, int* end_pos) { assert(start_pos <= line_len); /* caller should have checked */ const unsigned char* p = line + start_pos; /* modified by re2c */ /* Echo and History lexer apparently need this, but others don't */ const unsigned char* YYMARKER; for (;;) { /*!re2c "\\" [0-7]{1,3} { *id = id__PS_Octal3; break; } "\\" [adehHjlnrstT@AuvVwW!#$\\] { *id = id__PS_Subst; break; } "\\[" { *id = id__PS_LBrace; break; } "\\]" { *id = id__PS_RBrace; break; } [^\\\x00]+ { *id = id__PS_Literals; break; } "\\" { *id = id__PS_BadBackslash; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } *end_pos = p - line; /* relative */ } static inline void MatchHistoryToken(const unsigned char* line, int line_len, int start_pos, int* id, int* end_pos) { assert(start_pos <= line_len); /* caller should have checked */ const unsigned char* p = line + start_pos; /* modified by re2c */ /* Echo and History lexer apparently need this, but others don't */ const unsigned char* YYMARKER; for (;;) { /*!re2c "!" [!*^$] { *id = id__History_Op; break; } "!" "-" ? [0-9]+ { *id = id__History_Num; break; } "!" "?" ? [a-zA-Z_/.][0-9a-zA-Z_/.]+ [ \t\r\n] { *id = id__History_Search; break; } "#" [^\x00]* { *id = id__History_Other; break; } "'" [^'\x00]* "'" ? { *id = id__History_Other; break; } [^!\\'#\x00]+ { *id = id__History_Other; break; } "\\" [^\x00] { *id = id__History_Other; break; } [^\x00] { *id = id__History_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } *end_pos = p - line; /* relative */ } static inline void MatchBraceRangeToken(const unsigned char* line, int line_len, int start_pos, int* id, int* end_pos) { assert(start_pos <= line_len); /* caller should have checked */ const unsigned char* p = line + start_pos; /* modified by re2c */ /* Echo and History lexer apparently need this, but others don't */ const unsigned char* YYMARKER; for (;;) { /*!re2c "-" ? [0-9]+ { *id = id__Range_Int; break; } [a-zA-Z] { *id = id__Range_Char; break; } "." "." { *id = id__Range_Dots; break; } [^\x00] { *id = id__Range_Other; break; } "\x00" { *id = id__Eol_Tok; *end_pos = start_pos; return; } */ } *end_pos = p - line; /* relative */ } static inline void MatchOption(const unsigned char* s, int len, int* id) { const unsigned char* p = s; /* modified by re2c */ const unsigned char* end = s + len; const unsigned char* YYMARKER; //fprintf(stderr, "*** s = %s\n", s); for (;;) { /*!re2c "errexit" { *id = 1; break; } "nounset" { *id = 2; break; } "hashall" { *id = 3; break; } "pipefail" { *id = 4; break; } "noexec" { *id = 5; break; } "xtrace" { *id = 6; break; } "verbose" { *id = 7; break; } "noglob" { *id = 8; break; } "noclobber" { *id = 9; break; } "posix" { *id = 10; break; } "vi" { *id = 11; break; } "emacs" { *id = 12; break; } "interactive" { *id = 13; break; } "failglob" { *id = 14; break; } "nullglob" { *id = 15; break; } "inherit_errexit" { *id = 16; break; } "strict_argv" { *id = 17; break; } "strict_arith" { *id = 18; break; } "strict_array" { *id = 19; break; } "strict_control_flow" { *id = 20; break; } "strict_echo" { *id = 21; break; } "strict_errexit" { *id = 22; break; } "strict_eval_builtin" { *id = 23; break; } "strict_nameref" { *id = 24; break; } "strict_word_eval" { *id = 25; break; } "strict_backslash" { *id = 26; break; } "strict_glob" { *id = 27; break; } "simple_word_eval" { *id = 28; break; } "dashglob" { *id = 29; break; } "more_errexit" { *id = 30; break; } "simple_test_builtin" { *id = 31; break; } "parse_at" { *id = 32; break; } "parse_brace" { *id = 33; break; } "parse_index_expr" { *id = 34; break; } "parse_paren" { *id = 35; break; } "parse_rawc" { *id = 36; break; } "parse_ignored" { *id = 37; break; } "parse_unimplemented" { *id = 38; break; } "parse_set" { *id = 39; break; } "parse_equals" { *id = 40; break; } "expand_aliases" { *id = 41; break; } "extglob" { *id = 42; break; } "lastpipe" { *id = 43; break; } "progcomp" { *id = 44; break; } "histappend" { *id = 45; break; } "hostcomplete" { *id = 46; break; } "cmdhist" { *id = 47; break; } "assoc_expand_once" { *id = 48; break; } "autocd" { *id = 49; break; } "cdable_vars" { *id = 50; break; } "cdspell" { *id = 51; break; } "checkhash" { *id = 52; break; } "checkjobs" { *id = 53; break; } "checkwinsize" { *id = 54; break; } "complete_fullquote" { *id = 55; break; } "direxpand" { *id = 56; break; } "dirspell" { *id = 57; break; } "dotglob" { *id = 58; break; } "execfail" { *id = 59; break; } "extdebug" { *id = 60; break; } "extquote" { *id = 61; break; } "force_fignore" { *id = 62; break; } "globasciiranges" { *id = 63; break; } "globstar" { *id = 64; break; } "gnu_errfmt" { *id = 65; break; } "histreedit" { *id = 66; break; } "histverify" { *id = 67; break; } "huponexit" { *id = 68; break; } "interactive_comments" { *id = 69; break; } "lithist" { *id = 70; break; } "localvar_inherit" { *id = 71; break; } "localvar_unset" { *id = 72; break; } "login_shell" { *id = 73; break; } "mailwarn" { *id = 74; break; } "no_empty_cmd_completion" { *id = 75; break; } "nocaseglob" { *id = 76; break; } "nocasematch" { *id = 77; break; } "progcomp_alias" { *id = 78; break; } "promptvars" { *id = 79; break; } "restricted_shell" { *id = 80; break; } "shift_verbose" { *id = 81; break; } "sourcepath" { *id = 82; break; } "xpg_echo" { *id = 83; break; } * { *id = 0; return; } */ } if (p != end) { //fprintf(stderr, "EXTRA CHARS\n", s); *id = 0; // Not an exact match } } static inline void MatchBuiltin(const unsigned char* s, int len, int* id) { const unsigned char* p = s; /* modified by re2c */ const unsigned char* end = s + len; const unsigned char* YYMARKER; //fprintf(stderr, "*** s = %s\n", s); for (;;) { /*!re2c ":" { *id = 1; break; } "." { *id = 2; break; } "exec" { *id = 3; break; } "eval" { *id = 4; break; } "set" { *id = 5; break; } "shift" { *id = 6; break; } "times" { *id = 7; break; } "trap" { *id = 8; break; } "unset" { *id = 9; break; } "builtin" { *id = 10; break; } "readonly" { *id = 11; break; } "local" { *id = 12; break; } "declare" { *id = 13; break; } "typeset" { *id = 14; break; } "export" { *id = 15; break; } "test" { *id = 16; break; } "[" { *id = 17; break; } "true" { *id = 18; break; } "false" { *id = 19; break; } "read" { *id = 20; break; } "echo" { *id = 21; break; } "printf" { *id = 22; break; } "cd" { *id = 23; break; } "pushd" { *id = 24; break; } "popd" { *id = 25; break; } "dirs" { *id = 26; break; } "pwd" { *id = 27; break; } "source" { *id = 28; break; } "umask" { *id = 29; break; } "wait" { *id = 30; break; } "jobs" { *id = 31; break; } "fg" { *id = 32; break; } "bg" { *id = 33; break; } "shopt" { *id = 34; break; } "complete" { *id = 35; break; } "compgen" { *id = 36; break; } "compopt" { *id = 37; break; } "compadjust" { *id = 38; break; } "getopts" { *id = 39; break; } "command" { *id = 40; break; } "type" { *id = 41; break; } "hash" { *id = 42; break; } "help" { *id = 43; break; } "history" { *id = 44; break; } "alias" { *id = 45; break; } "unalias" { *id = 46; break; } "bind" { *id = 47; break; } "push" { *id = 48; break; } "append" { *id = 49; break; } "write" { *id = 50; break; } "getline" { *id = 51; break; } "json" { *id = 52; break; } "repr" { *id = 53; break; } "use" { *id = 54; break; } "opts" { *id = 55; break; } * { *id = 0; return; } */ } if (p != end) { //fprintf(stderr, "EXTRA CHARS\n", s); *id = 0; // Not an exact match } } static inline int IsValidVarName(const unsigned char* s, int len) { const unsigned char* p = s; /* modified by re2c */ const unsigned char* end = s + len; /* MatchBraceRangeToken needs this, but others don't */ const unsigned char* YYMARKER; /*!re2c re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = p; [a-zA-Z_][a-zA-Z0-9_]* { return p == end; } // Match must be anchored right, like $ * { return 0; } */ } static inline int IsPlainWord(const unsigned char* s, int len) { const unsigned char* p = s; /* modified by re2c */ const unsigned char* end = s + len; /* MatchBraceRangeToken needs this, but others don't */ const unsigned char* YYMARKER; /*!re2c re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = p; [a-zA-Z0-9\-_./]+ { return p == end; } // Match must be anchored right, like $ * { return 0; } */ } static inline int ShouldHijack(const unsigned char* s, int len) { const unsigned char* p = s; /* modified by re2c */ const unsigned char* end = s + len; /* MatchBraceRangeToken needs this, but others don't */ const unsigned char* YYMARKER; /*!re2c re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = p; "#" "!" .* "s" "h" [ \t\r\n][^\x00]* { return p == end; } // Match must be anchored right, like $ * { return 0; } */ }