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

Buck, Robert rbuck at verisign.com
Wed Jul 25 08:00:18 PDT 2007


If you "Display as Graph" in the interpreter and run the input through
'expression' and 'method' you get different graphs showing up. The
graphs should ordinarily look identical to what shows up under the
debugger, and in one case it is identical. But this is a bug, so it
would appear.

Bob 

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org 
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Thomas Brandon
> Sent: Wednesday, July 25, 2007 10:17 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Interpreter output inconsistent 
> for "Cstylemethod calls"
> 
> On 7/26/07, Buck, Robert <rbuck at verisign.com> wrote:
> > 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?
> The interpreter shows a parse tree, showing all rules that 
> were used to parse the output, not the AST. If you look at 
> the Parse Tree in the debugger you should see something 
> similar to the interpreter with the different start rule 
> producing a different parse tree. If you look at the AST in 
> the debugger then the output will be the same for both start rules.
> 
> Tom.
> > >
> > > Bob
> > >
> > >
> >
> 


More information about the antlr-interest mailing list