Related articles |
---|
Automatically generating ASTs with XML markup mcollado@fi.upm.es (Manuel Collado) (2004-12-29) |
Re: Automatically generating ASTs with XML markup dido@imperium.ph (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 demakov@ispras.ru (Alexey Demakov) (2004-12-30) |
Re: Automatically generating ASTs with XML markup jones@cs.ua.edu (Joel Jones) (2004-12-30) |
From: | =?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.Kahrs@vr-web.de> |
Newsgroups: | comp.compilers |
Date: | 30 Dec 2004 00:58:01 -0500 |
Organization: | Compilers Central |
References: | 04-12-149 |
Keywords: | tools, XML |
Posted-Date: | 30 Dec 2004 00:58:01 EST |
Hello Manuel,
> 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:
http://www.cs.usfca.edu/~parrt/course/652/projects-Spring-2004/xml-antlr.html
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:
http://www.scifac.ru.ac.za/coco/
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
effort.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.