[antlr-interest] parsing single java expressions

Sinan sinan.karasu at boeing.com
Thu Jun 13 09:42:57 PDT 2002


Vette98Man wrote:
> 


I have done this with other languages and antlr and it works.

What you have to do is , lets say you have a grammar


-------------

module:
      preamble
     ( statement )+
      end
      EOF;

statement: ....;

---------------

Now you add an orphan rule

single_statement:
     statement EOF;


now you can use the orphan rule ( once you attach the string stream to
your parser/lexer )

to return to you an AST.

You can even create a separate parser, as long as you create a context
outside of the original parser, so that you can keep track of your
variables
and pass it to the constructor of the parser.

If this is too cryptic, I can expand on it next week. Right now I don't
have the time....

sinan

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list