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

Gavin Lambert antlr at mirality.co.nz
Thu Jul 24 14:40:30 PDT 2008


At 02:21 25/07/2008, Setia, Namit wrote:
 >Does anyone know of any good tutorials on how to build an AST 
with
 >c#?

It's not really any different than building an AST for any other 
target language.  There are several examples in the examples 
download, and no doubt there are several in the ANTLR book as well 
(I don't have it myself, so I can't confirm that though).

 >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).

An ANTLR AST is always composed of tokens.  If you are getting 
individual characters, it can only be because your lexer is 
generating individual tokens for characters and not generating 
"full" tokens.



More information about the antlr-interest mailing list