[antlr-interest] CommonTree Serialization to XML

Des Hartman des at deshartman.com
Tue May 5 23:33:36 PDT 2009


I saw there was some documentation on serializing an AST (CommonTree) to
XML. This appears to be only for ANTLR v2 (see below)

Is there a similar facility in 3.1.3?

AST (XML) Serialization

 [Oliver Zeigermann olli at zeigermann.de provided the initial implementation
of this serialization.  His XTAL <http://www.zeigermann.de/xtal.html> XML
translation code is worth checking out; particularly for reading
XML-serialized ASTs back in.]

 For a variety of reasons, you may want to store an AST or pass it to
another program or computer.  Class antlr.BaseAST is Serializable using the
Java code generator, which means you can write ASTs to the disk using the
standard Java stuff.  You can also write the ASTs out in XML form using the
following methods from BaseAST:

   - public void xmlSerialize(Writer out)
   - public void xmlSerializeNode(Writer out)
   - public void xmlSerializeRootOpen(Writer out)
   - public void xmlSerializeRootClose(Writer out)



Thanks
Des
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090506/185bb937/attachment.html 


More information about the antlr-interest mailing list