DGrok 0.4 released: grammar 100% done
I’m now able to parse 100% of the Delphi grammar, as far as I can tell — and 100% of the Delphi RTL source. (Not all the source — just the RTL directory and its subdirectories — but still.) Sounds like an excellent time to do another release. DGrok 0.4 is now available.
Important caveat: I’m not yet handling {$INCLUDE}. And I know the Delphi RTL uses it, so it’s possible I’m not parsing everything — there may well be some gotchas inside those include files. {$INCLUDE} will most likely be the next thing I tackle.
For any who are curious, I didn’t make Str’s colon a general binary operator, because that broke case statements. (This is why I would never dream of writing a parser any way but test-first!) Instead, I added another expression type, ParameterExpression, that’s only used in parameter lists.
September 28th, 2007 at 7:49 am
I’m pretty sure there can be _two_ colon parameters. One for width, and one for precision. So your ParameterExpression production might need to be this instead:
Expression [’:’ Expression [’:’ Expression]]
September 28th, 2007 at 9:25 am
Ahh. Thanks, Rob. I thought I remembered something like that, but I couldn’t get it to compile with two colons. Turns out that’s because I was using an integer value; it only accepts the second colon if you’re using a float value. I’ll get this into the next release.
September 28th, 2007 at 9:26 am
Your download link has a typo.
September 28th, 2007 at 9:32 am
Oops! Thanks, Heiko. Fixed.
September 29th, 2007 at 12:30 am
Just wanted to say that this is awesome work you’re putting into this thing. There are a lot of projects out there that stalled or were half-arsed because they really needed a solid Delphi parser and instead made due with a home-grown "works for me" parser.
I know the people trying to create a solid code formatter will be happy to have this.
September 29th, 2007 at 7:38 am
It would take some work to make this usable for a code formatter (in particular, it would have to somehow keep track of comments, rather than just throwing them away).
Code formatting is actually one of the things I originally was hoping to do with a parser, but I wound up discarding the idea — for the time being, at least — just because of the extra work involved. But if someone else wants to run with it, that’d be terrific.
September 29th, 2007 at 11:37 pm
Nice work. I’d love to see an equivalent project to parse SQL. (Particularly T-SQL). Any chance you’ve considered it?
September 30th, 2007 at 5:55 am
SQL would probably be a lot easier than Delphi, but it’s not something I have any need for, so no, not likely in the foreseeable future.