www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D grammar for ANTLR?

reply Michael Butscher <mbutscher gmx.de> writes:
Hi,

has somebody tried to create an ANTLR grammar for D or is working on it?

I found a few articles about that in the archives but no working links to 
grammars and the attachments are not stored by the web interface of the 
newsgroup.


Another interesting thing would be an ANTLR extension to create lexers/parsers 
in D. Somebody working on that?


Michael
Jun 08 2005
next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
In article <MPG.1d1154989a91cd6698968b news.digitalmars.com>, Michael Butscher
says...
Hi,

has somebody tried to create an ANTLR grammar for D or is working on it?

I found a few articles about that in the archives but no working links to 
grammars and the attachments are not stored by the web interface of the 
newsgroup.

You might try this: http://aegisknight.org/~andy/d/d.g There's some more grammar odds-and-ends here that may be of some use: http://www.prowiki.org/wiki4d/wiki.cgi?GrammarParsers jcc7
Jun 08 2005
parent Michael Butscher <mbutscher gmx.de> writes:
J C Calvarese wrote:

 You might try this: http://aegisknight.org/~andy/d/d.g
 
 There's some more grammar odds-and-ends here that may be of some use:
 http://www.prowiki.org/wiki4d/wiki.cgi?GrammarParsers
 
 jcc7
 

Thank you, exactly what I searched for. Is anybody actively working on this yet? Michael
Jun 09 2005
prev sibling parent reply Klaus Oberhofer <oberhofer ixxat.de> writes:
Michael Butscher <mbutscher gmx.de> wrote in
news:MPG.1d1154989a91cd6698968b news.digitalmars.com: 

 
 Another interesting thing would be an ANTLR extension to create
 lexers/parsers in D. Somebody working on that?
 

I've currently modified lapg (see http://lapg.sf.net) to produce D output. lapg supports lexical scanner generation and LALR(1) grammars. I've also tried to create a D grammar for lapg but there are some D constructs which are context sensitive and needs >1 lookahead. The semantic and syntactic predicates of ANTLR would be very handy for this. I had a look at the ANTLR source and mailing list but I have not found a starting point or document how to create a custom language output generator, yet. If you have more luck, let me know :-) Greets Klaus BTW creating a custom language binding for ANTLR seems to be a nontrivial task. For lapg more or less changing a text template and recompilation was needed. Langage support in ANTLR consists of two parts: a code generator and a support library (base classes and AST handling). The one(s) who create such a monster will probably be condemned to maintain it :-)
Jun 09 2005
parent Michael Butscher <mbutscher gmx.de> writes:
Klaus Oberhofer wrote:


 The semantic and syntactic predicates of ANTLR would be very handy for 
 this. I had a look at the ANTLR source and mailing list but 
 I have not found a starting point or document how to create a custom
 language output generator, yet. If you have more luck, let me know :-)

Because nobody seems to work currently on such a generator, I will try to create one, but I don't know how far I will come.
 Greets
 
 
 Klaus
 
 
 BTW creating a custom language binding for ANTLR seems to be a nontrivial
 task. For lapg more or less changing a text template and recompilation was
 needed. Langage support in ANTLR consists of two parts: a code generator 
 and a support library (base classes and AST handling). The one(s) who 
 create such a monster will probably be condemned to maintain it :-)

One nice thing with open source software is that nobody needs to be responsible forever for his/her software. At first glance the rewrite of the support library should be possible with reasonable effort because of the similarity of Java and D. Michael
Jun 10 2005