lexer grammar BDF_Lexer; //Keep it in sync with the static block down. Should be replaced with reflections?? tokens { BEGIN; BENCHMARK; CODE_PAGE; DCLFORM; DCLRAND; DCLTRANS; DCLUSER; END; NULL; SET_ENCODING; SILK_PERFORMER_RECORDER; TINIT; TMAIN; THINK_TIME; TRANSACTION; TRANSACTIONS; USE; USER; VAR; VUSER; WEB_BROWSER; WEB_COOKIE_SET; WEB_CUSTOM_REQUEST; WEB_FORM_GET; WEB_FORM_POST; WEB_MODIFY_HTTP_HEADER; WEB_SET_BROWSER; WEB_URL; WEB_URL_BEGIN_PAGE; WEB_URL_END_PAGE; } @lexer::members { private static java.util.HashMap commandMemory = new java.util.HashMap(); static { commandMemory.put("begin", new Integer(BEGIN) ); commandMemory.put("benchmark", new Integer(BENCHMARK) ); commandMemory.put("codepage", new Integer(CODE_PAGE) ); commandMemory.put("dclform", new Integer(DCLFORM) ); commandMemory.put("dclrand", new Integer(DCLRAND) ); commandMemory.put("dcltrans", new Integer(DCLTRANS) ); commandMemory.put("dcluser", new Integer(DCLUSER) ); commandMemory.put("end", new Integer(END) ); commandMemory.put("NULL", new Integer(NULL) ); commandMemory.put("SetEncoding", new Integer(SET_ENCODING) ); commandMemory.put("SilkPerformerRecorder", new Integer(SILK_PERFORMER_RECORDER) ); commandMemory.put("ThinkTime", new Integer(THINK_TIME) ); commandMemory.put("TInit", new Integer(TINIT) ); commandMemory.put("TMain", new Integer(TMAIN) ); commandMemory.put("transaction", new Integer(TRANSACTION) ); commandMemory.put("transactions", new Integer(TRANSACTIONS) ); commandMemory.put("use", new Integer(USE) ); commandMemory.put("user", new Integer(USER) ); commandMemory.put("var", new Integer(VAR) ); commandMemory.put("VUser", new Integer(VUSER) ); commandMemory.put("WEB_BROWSER_MSIE7", WEB_BROWSER ); commandMemory.put("WebCookieSet", new Integer(WEB_COOKIE_SET) ); commandMemory.put("WebCustomRequest", new Integer(WEB_CUSTOM_REQUEST) ); commandMemory.put("WebFormGet", new Integer(WEB_FORM_GET) ); commandMemory.put("WebFormPost", new Integer(WEB_FORM_POST) ); commandMemory.put("WebModifyHttpHeader", new Integer(WEB_MODIFY_HTTP_HEADER) ); commandMemory.put("WebSetBrowser", new Integer(WEB_SET_BROWSER) ); commandMemory.put("WebUrl", new Integer(WEB_URL) ); commandMemory.put("WebUrlBeginPage", new Integer(WEB_URL_BEGIN_PAGE) ); commandMemory.put("WebUrlEndPage", new Integer(WEB_URL_END_PAGE) ); } } INT : '0'..'9'+ ; FLOAT : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? | '.' ('0'..'9')+ EXPONENT? | ('0'..'9')+ EXPONENT ; COMMENT : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;} ; WS : ( ' ' | '\t' | '\r' | '\n' ) {$channel=HIDDEN;} ; STRING : '"' ( ESC_SEQ | ~('\\'|'"') )* '"' ; CHAR: '\'' ( ESC_SEQ | ~('\''|'\\') ) '\'' ; fragment EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ; fragment HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ; fragment ESC_SEQ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | UNICODE_ESC | OCTAL_ESC ; fragment OCTAL_ESC : '\\' ('0'..'3') ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ; fragment UNICODE_ESC : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ; COMMA : ','; AT_SYMBOL : '@'; COLON : ':'; SEMI : ';'; LPAREN : '('; RPAREN : ')'; EQUAL : '='; LT : '<'; GT : '>'; IDENTIFIER : ( ('A'..'Z') | ('a'..'z' ) ) ( ('A'..'Z') | ('a'..'z') | ('0'..'9') | '_' )* { if( commandMemory.get( $text ) != null ) $type = commandMemory.get( $text ); } ;