|Automatically generating ASTs with XML markup email@example.com (Manuel Collado) (2004-12-29)|
|Re: Automatically generating ASTs with XML markup firstname.lastname@example.org (Rafael 'Dido' Sevilla) (2004-12-30)|
|Re: Automatically generating ASTs with XML markup Juergen.Kahrs@vr-web.de (=?ISO-8859-1?Q?J=FCrgen_Kahrs?=) (2004-12-30)|
|Re: Automatically generating ASTs with XML markup email@example.com (Alexey Demakov) (2004-12-30)|
|Re: Automatically generating ASTs with XML markup firstname.lastname@example.org (Joel Jones) (2004-12-30)|
|Date:||30 Dec 2004 00:58:01 -0500|
|Posted-Date:||30 Dec 2004 00:58:01 EST|
> I'm trying to grab the abstract syntax of several code samples in
> several different languages by using an XML representation.
Terence Parr has tried this in a project with ANTLR:
But as far as I understood it, he also has no
was of automatically converting syntactical
elements into XML markup blocks.
> Perhaps this could be done by an automatic tool just by writing the
> appropriate grammar (EBNF or similar):
> <program> ::= MODULE <name>; <import>* <declaration>* <body>
> <import> ::= IMPORT <name>;
> <body> ::= BEGIN (<assign>|<call>|<if>|...)* END <name> .
> <call> ::= <name> [ "(" <expression>, <expression>* ")" ]
If you already have an EBNF grammar, the best tool
for you probably is CoCo/R:
You can find an example on the web page. With CoCo/R you have to add
about one line to each EBNF rule to get XML output. The complexity of
this work should be at the student-homework-level.
Once you have a program's source code converted to XML, you can build
a compiler in XSL or XMLgawk. But I wonder if the advantage of having
the intermediate trees of the compiler in XML is really worth the
Return to the
Search the comp.compilers archives again.