Joe White’s Blog

Life, .NET, and Cats


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.

8 Responses to “DGrok 0.4 released: grammar 100% done”

  1. Rob Kennedy Says:

    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]]

  2. Joe White Says:

    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.

  3. Heiko Behrens Says:

    Your download link has a typo.

  4. Joe White Says:

    Oops! Thanks, Heiko. Fixed.

  5. Shawn Oster Says:

    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.

  6. Joe White Says:

    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.

  7. Ben Says:

    Nice work. I’d love to see an equivalent project to parse SQL. (Particularly T-SQL). Any chance you’ve considered it?

  8. Joe White Says:

    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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Joe White's Blog copyright © 2004-2008. Portions of the site layout use Yahoo! YUI Reset, Fonts, and Grids.
Proudly powered by WordPress. Entries (RSS) and Comments (RSS).