[antlr-interest] Interpreter output inconsistent for "Cstylemethod calls"

Thomas Brandon tbrandonau at gmail.com
Wed Jul 25 09:29:50 PDT 2007


On 7/26/07, Terence Parr <parrt at cs.usfca.edu> wrote:
> Oh, no backtracking...ok, i'll look.  Note that the tree will be
> different in that the root node will be different (an extra) for the
> different input.
>
> Ter
>
Yeah, the problems are deeper than that.
With the grammar below, which gives no errors, parsing "MODULUS(16,
FIRST_N_CHARACTERS(5, TO_ADDR()))" in the debugger proceeds
identically starting from start, expression or method rules (ignoring
different rules leading into method and the fact that start also
matches the EOF). Under the interpreter start parses the entire input
while expression terminates after ""MODULUS(16" while method gets
through "MODULUS(16, FIRST_N_CHARACTERS(5, TO_ADDR())" (missing the
last ')').

grammar Test;

start
	:	expression+ EOF;

method
       :       ID arguments
       ;
expression
       :       method
       |       literal
       ;
literal
       :       STRING
       |       INT
       ;
arguments
       :       LPAREN (argumentList)? RPAREN
       ;
argumentList
       :       expression (',' expression)+
       ;
LPAREN  :       '(';
RPAREN  :       ')';
ID  :   ('_'|'a'..'z'|'A'..'Z') ('_'|'a'..'z'|'A'..'Z'|'0'..'9')* ;
STRING : '"' .* '"' ;
INT :   '0'..'9'+ ;
WS	:	' '{ skip(); };


More information about the antlr-interest mailing list