[antlr-interest] XML output .

Pete Forman pete.forman at westerngeco.com
Thu Jan 30 00:40:39 PST 2003


At 2003-01-29 21:18 +0000, cintyram <cintyram at yahoo.com> wrote:
>  this post actually addresses two related issues , so i did not post
>them in seperate mails
>
>i am trying to visualise the ast constructed by my parser,
>and the easiest way i felt was to output it in xml and view it in a
>browser;
>
>1. i wanted the outpout in a string istead of in a strem , so i
>modified the method  in baseast.cpp as follows  ;
>  actually i wanted to put the token names but i dont know how to
>access them from the baseast class ; they are available to the parser
>and tree parser ; since wanting to know the token names from the ast
>or from any where a token is available seems to me to be a useful
>feature, what would be a standard way to do it?
>[eg: put a static pointer to the table in Token class , and provide
>methods to assign to it when ever we need names? ]


I published a way to output XML such that the elements correspond to
tokens in http://groups.yahoo.com/group/antlr-interest/message/3808


Ter, in that message there was a small patch to BaseAST.java to add a
getTokenNames() method.  Any chance of adding that to 2.7.3?


Back to the original question, there is no need to rewrite BaseAST.
Just call xmlSerialize on a StringWriter.


>2. in my method xml out put like
>
>  <tag>
>  <
></tag>
>is not being accepted as valid by the browser ;

Presumably the solitary "<" is a typo in your message.

I found no problem using IE to interpret the XML generated by ANTLR.
Make sure that you call the file something.xml.

-- 
Pete Forman                -./\.-  Disclaimer: This post is originated
WesternGeco                  -./\.-   by myself and does not represent
pete.forman at westerngeco.com    -./\.-   opinion of Schlumberger, Baker
http://petef.port5.com           -./\.-   Hughes or their divisions.


 

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



More information about the antlr-interest mailing list