[antlr-interest] Look Ahead while parsing a tree.

Trey Spiva Trey.Spiva at embarcadero.com
Fri Nov 1 07:36:28 PST 2002


I was wondering if there any way to look ahead while parsing a Tree.  I know
that in a recognizer you can use the LA(1) to test the next token,  can I do
something similar in a tree parser.
 
To give you a context I will explain my need.
 
For the java code:
 
if(m_a.doA() != null)
{
   m_b.doInterB();
}
else if(m_TestB.doB() == 1)
{
   m_a.doA();
}
else
{
   DoItSuper();
}
 
The tree will look like:
 
If
|
 -- EXPR           // The conditional test.
|
 -- { [SLIST]      // The body of the if statement
|
 -- If             // The else if part
     |
      -- EXPR      // The conditional test.
     | 
      -- { [SLIST] // The body of the if statement
     |
      -- { [SLIST  // The else part
 
When processing the tree I can tell if the SLIST is a else-if or a else.
Can any one help me understand?  I am working with the java grammar that
ships the ANTLR.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20021101/9da5db95/attachment.html


More information about the antlr-interest mailing list