[antlr-interest] Problem with AntlrWorks 1.3.1 Interpreter

shmuel siegel antlr at shmuelhome.mine.nu
Tue Feb 2 15:06:35 PST 2010


I am having inconsistent results with the antlrworks interpreter. The 
following grammar gives a mismatched token exception while processing 
the string part of

#include "abc"


The debugger works fine with this grammar. If I remove ESC_SEQ from the 
definition of STRING, the interpreter works fine. FWIW STRING was 
auto-generated from the antlrworks new grammar wizard.


grammar test;

prog:     INCLUDE STRING;
INCLUDE     :     '#include';

STRING
     :  '"' ( ESC_SEQ | ~('\\'|'"') )* '"'
     ;

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
     ;




More information about the antlr-interest mailing list