NAME [a-zA-Z_][a-zA-Z0-9_-]* BR \r\n|\n|\r %s indented trail rules %x code start_condition options conditions action %% "/*"(.|\n|\r)*?"*/" return 'ACTION_BODY'; "//".* return 'ACTION_BODY'; "/"[^ /]*?['"{}'][^ ]*?"/" return 'ACTION_BODY'; // regexp with braces or quotes (and no spaces) \"("\\\\"|'\"'|[^"])*\" return 'ACTION_BODY'; "'"("\\\\"|"\'"|[^'])*"'" return 'ACTION_BODY'; [/"'][^{}/"']+ return 'ACTION_BODY'; [^{}/"']+ return 'ACTION_BODY'; "{" yy.depth++; return '{' "}" yy.depth == 0 ? this.begin('trail') : yy.depth--; return '}' {NAME} return 'NAME'; ">" this.popState(); return '>'; "," return ','; "*" return '*'; {BR}+ /* */ \s+{BR}+ /* */ \s+ this.begin('indented') "%%" this.begin('code'); return '%%' [a-zA-Z0-9_]+ return 'CHARACTER_LIT' {NAME} yy.options[yytext] = true {BR}+ this.begin('INITIAL') \s+{BR}+ this.begin('INITIAL') \s+ /* empty */ {NAME} return 'START_COND' {BR}+ this.begin('INITIAL') \s+{BR}+ this.begin('INITIAL') \s+ /* empty */ .*{BR}+ this.begin('rules') "{" yy.depth = 0; this.begin('action'); return '{' "%{"(.|{BR})*?"%}" this.begin('trail'); yytext = yytext.substr(2, yytext.length-4);return 'ACTION' "%{"(.|{BR})*?"%}" yytext = yytext.substr(2, yytext.length-4); return 'ACTION' .+ this.begin('rules'); return 'ACTION' "/*"(.|\n|\r)*?"*/" /* ignore */ "//".* /* ignore */ {BR}+ /* */ \s+ /* */ {NAME} return 'NAME'; \"("\\\\"|'\"'|[^"])*\" yytext = yytext.replace(/\\"/g,'"'); return 'STRING_LIT'; "'"("\\\\"|"\'"|[^'])*"'" yytext = yytext.replace(/\\'/g,"'"); return 'STRING_LIT'; "|" return '|'; "["("\\\\"|"\]"|[^\]])*"]" return 'ANY_GROUP_REGEX'; "(?:" return 'SPECIAL_GROUP'; "(?=" return 'SPECIAL_GROUP'; "(?!" return 'SPECIAL_GROUP'; "(" return '('; ")" return ')'; "+" return '+'; "*" return '*'; "?" return '?'; "^" return '^'; "," return ','; "<>" return '$'; "<" this.begin('conditions'); return '<'; "/!" return '/!'; "/" return '/'; "\\"([0-7]{1,3}|[rfntvsSbBwWdD\\*+()${}|[\]\/.^?]|"c"[A-Z]|"x"[0-9A-F]{2}|"u"[a-fA-F0-9]{4}) return 'ESCAPE_CHAR'; "\\". yytext = yytext.replace(/^\\/g,''); return 'ESCAPE_CHAR'; "$" return '$'; "." return '.'; "%options" yy.options = {}; this.begin('options'); "%s" this.begin('start_condition'); return 'START_INC'; "%x" this.begin('start_condition'); return 'START_EXC'; "%%" this.begin('rules'); return '%%'; "{"\d+(","\s?\d+|",")?"}" return 'RANGE_REGEX'; "{"{NAME}"}" return 'NAME_BRACE'; "{" return '{'; "}" return '}'; . /* ignore bad characters */ <*><> return 'EOF'; (.|{BR})+ return 'CODE'; %%