[antlr-interest] Antlr missing getTree() method? C#

Setia, Namit namit.setia at lehman.com
Thu Jul 24 07:21:51 PDT 2008


Thanks for the help.

Does anyone know of any good tutorials on how to build an AST with c#?
When I get the top level tree, it's children are the individual
characters of the string I passed in.  I'm not quite sure what the
approach should be to get it to parse into an AST (Maybe my
understanding is wrong, but I'm trying to get a tree like what you see
in the antlrworks interpreter).

I've been trying to find some good examples for the latest version of
antlr, but none of the csharp samples I could find work.

namit

-----Original Message-----
From: Gavin Lambert [mailto:antlr at mirality.co.nz] 
Sent: Wednesday, July 23, 2008 6:01 PM
To: Setia, Namit; antlr-interest at antlr.org
Subject: Re: [antlr-interest] Antlr missing getTree() method? C#

At 08:28 24/07/2008, Setia, Namit wrote:
 >For some reason, I don't see any methods to extract the AST  >tree
from the parser (i.e., from the "qpar" variable).  I've  >seen in other
posts people calling qpar.getTree() or  >qpar.program().  Am I missing
something critical from my grammar?

You need to call the top-level rule in your parser.  Which in your case
appears to be 'qexprlist'.  So call qpar.qexprlist() and it'll either
return the tree directly or the tree will be one of the members of the
structure it returns.  (Things vary a little depending on target and
grammar structure, but it's not hard to work out.)

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

This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein.


More information about the antlr-interest mailing list