%component abstract_regex
%helper

%extern "Symbol symbol(short)"
%extern "Symbol symbol(short, Object)"
%extern "void error(String) throws Scanner.Exception"

Digit = [0-9]
HexDigit = {Digit} | [a-fA-F]
//TODO-AC: "a backslash followed by any other unicode character that stands for this character."
EscapeSequence = \\ ( [nrtfb] | x {HexDigit} {HexDigit} | u {HexDigit} {HexDigit} {HexDigit} {HexDigit} | [0-3] [0-7] [0-7] | [\|\(\)\{\}\[\]\<\>\\\.\*\+\?\^\$\/\.\"\~\!])

Quote = \"

NonMeta = [^\|\(\)\{\}\[\]\<\>\\\.\*\+\?\^\$\/\.\"\~\!]

%%

\( {: return symbol(LPAREN); :}
\) {: return symbol(RPAREN); :}
\[ {: return symbol(LSQUARE); :}
\] {: return symbol(RSQUARE); :}

\^ {: return symbol(BEGINNING_OF_LINE); :}
\$ {: return symbol(END_OF_LINE); :}

\! {: return symbol(NOT); :}
\~ {: return symbol(UPTO); :}

\* {: return symbol(STAR); :}
\+ {: return symbol(PLUS); :}
\? {: return symbol(OPT); :}

\- {: return symbol(DASH); :}

\/ {: return symbol(SLASH); :}
\| {: return symbol(ALT); :}

\. {: return symbol(DOT); :}

"=" {: return symbol(ASSIGN); :}

"<<ANY>>" {: return symbol(ANY_PATTERN); :}
"<<EOF>>" {: return symbol(EOF_PATTERN); :}

{EscapeSequence} {: return symbol(ESCAPE_SEQUENCE, yytext()); :}
\\ {: error("Invalid escape sequence"); :}

{Quote} {: :} START_STRING

//safe fallback for patterns
{NonMeta} {: return symbol(NON_META, yytext()); :}