[antlr-interest] NQOT: Grammar meta-programming
Gavin Lambert
antlr at mirality.co.nz
Fri Dec 7 12:55:00 PST 2007
At 05:02 8/12/2007, Andy Tripp wrote:
>On the other hand...one approach I've thought about would be to
>use programming-by-example.
>You feed your magic tool sets of examples: "Here is a program,
>and here is the AST that
>it should produce". If you can make your set of examples
>exhaustive (i.e. cover all language constructs), that seems like
>it might work.
>
>So the tool could store its grammar in whatever format it wants
>(ANTLR or something completely different), but you'd essentially
>define your parser not as a traditional BNF-style grammar, but
>rather as a set of example (input, AST) pairs.
That'd be pretty cool. Although I suspect in practice you'd
probably need to have an (input, token stream, AST) triplet (or
sets of input=>tokens and sets of tokens=>ASTs). Going straight
from input to AST is probably a bit too hard :)
Actually even the first half of that (input => token stream) would
be a big help in many cases. Since ANTLR doesn't have much
debugging support for lexers, it's easy to accidentally break
something in weird ways (especially if you don't have unit tests).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071208/5c3cbe82/attachment.html
More information about the antlr-interest
mailing list