[antlr-interest] Interpreter output inconsistent for "C style method calls"
Buck, Robert
rbuck at verisign.com
Wed Jul 25 06:56:02 PDT 2007
Given something like this:
MODULUS(16, FIRST_N_CHARACTERS(5, TO_ADDR()))
And running it through the interpreter using this grammar:
grammar test;
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'+ ;
When I compare the results of running the expression through 'method',
and through 'expression, I get different results:
> expression method MODULUS arguments ( argumentList expression literal
16
> method MODULUS arguments ( argumentList expression literal 16 ,
expression method FIRST_N_CHARACTERS arguments
( argumentList expression literal 5 , expression method TO_ADDR
arguments ( )
Now, as both have as a stem in their output 'method', I do not quite
understand why the interpreter produces different results in each case.
Am I missing something here?
Bob
More information about the antlr-interest
mailing list