[antlr-interest] AST->XML

Stuart Watt SWatt at infobal.com
Fri Jan 18 06:47:55 PST 2008


I wrote an odd hack solution to this for the C runtime, which I can send,
but it does depend on a nasty test to see which tokens are AST tokens and
which aren't, and this was not immediately obviously testable in the
generated files. 

However, I didn't convert the AST from its textual representation, just
wrote it directly. I did this because I was getting in a muddle with the
Lisp-style AST, where it was not immediately clear when a token was a token
and when it was text, i.e., parsing a macro "MACRO" could get confused in my
ASTs with an empty MACRO token type with no body. Yes, I know this was all
my bad coding, and could easily have been avoided, but switching to XML gave
me *much* faster parsing of the ASTs, and as I don't need to tree-walk but
to search for grammar patterns, XPath on the ASTs has worked like a charm
for me, and saved me a lot of tedious work. 

All the best
Stuart

-----Original Message-----
From: Vaclav Barta [mailto:vbar at comp.cz]
Sent: Friday, January 18, 2008 4:56 AM
To: Michele Bortolato
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] AST->XML


Michele Bortolato wrote:
 > Has antlr(works) a tool to convert ast to XML?
Not as far as I'm aware. The last suggestion for your problem I've seen 
on this list was to use some package converting object trees to XML 
(whose choice will obviously depend on your language and other 
preferences) and use that.

	Bye
		Vasek
--
http://www.mangrove.cz/
Open Source integration


More information about the antlr-interest mailing list