[antlr-interest] Unexpected behavior - Error?

Philippe Frankson Philippe.Frankson at Frsglobal.com
Tue Mar 9 06:15:29 PST 2010


What if you replace 'source' like this:
source : (statement)* EOF

Regards 
Philippe Frankson

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Christoph Schinko
Sent: 09 March 2010 14:43
To: antlr-interest at antlr.org
Subject: [antlr-interest] Unexpected behavior - Error?

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


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list