Writing a Parser

Dan murpsoft at hotmail.com
Fri Jan 4 19:34:23 PST 2008


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