What ist the current status of the Javascript target in antlr3? I tried to generate a parser for a simple grammar but the generated code contains lots of compiler errors. After checking the website I checked out the current antlr3.5-snapshot code and built antlr from the source with maven. The results are still the same? Is there some special version that I can use? Or is the target broken? (I found comments about the target being broken in 3.1, 3.2, working in 3.3 and nothing about 3.4 and 3.5) Hier is an example for the Javascript code that doesn't work:
// public class variables
var = ,
= ,
= ,
...
= ,
= ;
There is more of this kind of code in the generated lexer and parser files.
Any hints are greatly appreciated.
This is the very simple test grammar I used to try out javascript code generation. Almost everything was generated by antlrworks. I added the target language and the prog rule. (Please don't spend too much time editing this grammar to make it work. Antlrworks checked the grammar and the Java code generation works. So - from a user point of view - Javascript code generation should work without changing the grammar.) Thanks again for your help.
grammar TestgrammarV001;
options {
language=JavaScript;
}
prog : ID | INT;
ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
;
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
;