Last update March 17, 2008

Grammar Posts



Table of contents of this page
2008   
2006   
2005   
2004   
2003   
2002   

2008    

2006    

I've heard that someone wrote D language support for ANTLR (some times ago in d.announce).

Such grammar and number of syntax tree classes are already in eclipseD project, so you may wish to use it <g>.

http://svn.dsource.org/projects/eclipseD/trunk/ddt.core/src/org/dsource/ddt/core/model/
(Now, it's at DsourceProject:ddt/browser/trunk/ddt.core/src/org/dsource/ddt/core/model -- JustinCalvarese)

2005    

It's not an LALR(1) grammar (one token lookahead), but doing LALR(1) would have compromised the look & feel I was trying to achieve. So arbitrary lookahead (LALR(n)) is needed. (A nit: it isn't a lexer problem, it's a parsing problem.) The lexer was designed from the start so that arbitrary lookahead is easy to do.

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

2004    

ANTLR is ANother Tool for Language Recognition. It's the same idea as Lex and YACC, but has (I think) better syntax, and directly supports generating re-entrant parsers in C++, C# or Java. (Python support is on the way, as I understand it. Anybody want to take a crack at D support?) You can get it at http://antlr.org

I haven't run this through the complete gauntlet just yet, but preliminary tests suggest that it handles a respectable subset of D, if not the whole thing.

http://andy.tadan.us/d/d.g (new link: http://aegisknight.org/~andy/d/d.g)

There isn't much else going on in this parser just yet, it's little more than a syntax checker, but that also means that it's easier to gut it if you want to use the grammar for something else.

2003    

2002    


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: March 17, 2008 16:37 (diff))