Lexer and parser generators using CTFE
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Feb 29 15:41:26 PST 2012
On Wed, Feb 29, 2012 at 10:41:22AM -0600, Andrei Alexandrescu wrote:
> An efficient, integrated parser generator would lower the barrier of
> entry dramatically - if we play our cards right, even a sprintf
> specifier string could be parsed simpler and faster using an embedded
> grammar, instead of painfully writing the recognizer by hand.
I see that std.stdio.writef already parses format strings at
compile-time, though the code is somewhat ugly. :) It would be ideal if
that can be done just by a series of ENBF/regex declarations.
> Parsing config files, XML, JSON, CSV, various custom file formats and
> many others - all would all be a few lines away. Ideally a user who
> has a basic understanding of grammars should have an easier time using
> a small grammar to parse simple custom formats, than writing the
> parsing code by hand.
This is definitely something worth having. It has always been my dream
that an ideal programming language should let you write grammar rules
and pretty much autogen the code for you. There shouldn't need to be
external utilities with the associated messy build rules, auxiliary
files and other such things, esp. if you just need a one-time small
parser for a very specific task.
Why ask rhetorical questions? -- JC
More information about the Digitalmars-d