Writing a Parser

Christoph Singewald chrisrtoph at singewald.at
Thu Jan 10 06:21:22 PST 2008


Here you can find some parsergenerators:

http://www.prowiki.org/wiki4d/wiki.cgi?GrammarParsers

I use lemonde as parsergenerator and re2c as lexer. Using re2c in most cases you have only to replace 'unsigned int' with 'uint' in the resulting code.


regards
cs

Dan Wrote:

> 
> I've been messing with how to write a parser, and so far I've played with numerous patterns before eventually wanting to cry.
> 
> At the moment, I'm trying recursive descent parsing.
> 
> The problem is that I've realized I'm duplicating huge volumes of code to cope with the tristate decision of { unexpected, allow, require } for any given token.
> 
> For example, to consume a for loop, you consume something similar to
> /for\s*\((.*?)\)\s*\{(.*?)\}/
> 
> I have it doing that, but my soul feels heavy with the masses of looped switches it's doing.  Is there any way to ease the pain?
> 
> Regards,
> Dan



More information about the Digitalmars-d-learn mailing list