[antlr-interest] Interpreter output inconsistent for "C stylemethod calls"

Buck, Robert rbuck at verisign.com
Wed Jul 25 07:02:30 PDT 2007


This turns out to be a UI interpreter bug. When I run it through the
debugger, it displays consistently.

Bob

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org 
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Buck, Robert
> Sent: Wednesday, July 25, 2007 9:56 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Interpreter output inconsistent for 
> "C stylemethod calls"
> 
> 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