Re: Re: SIDE NOTE: CIL Schema
Frank Raiser <frank.raiser-jNDFPZUTrfQgVUaW7OllY/[email protected]> Mon, 10 Jan 2005 12:39:18 +0100
| Newsgroups | gmane.text.xml.o-xml |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Jan 09, 2005 at 05:56:51PM +0000, Martin Klang wrote: > It's going to require work. I'm currently playing around with the Antlr > parser generator, and its Java grammar in particular - I'm looking at > ways of making it generate XML output from its AST. That would take > care of Java -> MLML. Unfortunately I don't have much time to play > around with stuff... I'm not sure if you have seen it already, so I'll just keep this posting short: Take a look at the parser-java module of SrcML. The java.g[1] and java.tree.g[2] are the enhanced Antlr java grammar (and tree parser) which produce our SrcML output. The generated parser relies on some classes of the parser-shared module and it currently only works for java 1.3 (I have not yet invested time into 1.4 compliance, but from what I know it should only be the assert keyword which is trivial to add). Also comment handling is a bit on the magical side as it is of course impossible to tell what a commment actually belongs to. Right now the parser assumes a simple 'comment belongs to the next statement' heuristic most of the times. But other than that you should be able to quickly make the neccessary changes from SrcML to MLML. In case you have already looked into that and decided to go into a different solution I'd be pleased to hear your arguments on the decision. Of course the process is also possible using a java.g grammar only, however we found the use of a tree grammar to be very advantageous as you don't run into the problem of when to open which tag. This is rather difficult to decide in those cases were java.g is still in the process of looking ahead to find out what actually happens there in the code. Also the resulting tree grammar turned out to be nice for maintaining due to its simple structure (for a grammar at least ;) [1] http://cvs.sourceforge.net/viewcvs.py/srcml/parser-java/java.g?view=markup [2] http://cvs.sourceforge.net/viewcvs.py/srcml/parser-java/java.tree.g?view=markup With kind regards, -- Raiser, Frank Student @ University of Ulm (www.uni-ulm.de) The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)