[antlr-interest] Unexpected behavior - Error?

Christoph Schinko c.schinko at cgv.tugraz.at
Tue Mar 9 05:43:18 PST 2010


Hi!

Using the grammar below we experience unexpected behavior. The parser 
accepts the following input line:

<<<<<<< .mine

without throwing an error - which it should - according to the grammar. 
The grammar has been reduced to
a toy example reproducing the error. Any thoughts on that?

Regards, Chris

------------------------------------------------------------------------

grammar JScriptDoc;

options
{
     output=AST;
     backtrack=true;
     memoize=true;
}

source
     : (statement)*
     ;

statement
     : statementEmpty
     | statementBlock
     ;

statementBlock

     : '{' (statement )* '}'
     ;

statementEmpty
     : ';'
     ;

OPERATOR_LT
     : '<'
     ;

OPERATOR_DOT
     : '.'
     ;

IDENTIFIER
     : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
      ;

NEWLINE
     : '\r'? '\n'
     {$channel=HIDDEN;}
         ;

WHITESPACE
     : ' '
     {$channel=HIDDEN;}
     ;

WHITETAB
     : '\t'
     {$channel=HIDDEN;}
     ;

-- 
Dipl.-Ing. Christoph Schinko       c.schinko at cgv.tugraz.at
Institute of Computer Graphics and Knowledge Visualization
Graz University of Technology      tel: +43 (316) 873-5416
Inffeldgasse 16c, 8010 Graz, Austria



More information about the antlr-interest mailing list