tadzik / Grammar-BNF

Parse BNF and ABNF grammars and generate Perl 6 grammars from them
MIT License
16 stars 5 forks source link

Parsing the BNF/ABNF at compile time? #14

Open zostay opened 5 years ago

zostay commented 5 years ago

So, for a large grammar, such as you will find in RFC 5322, this is too slow to be very useful. But, if we could move much of the slow to compile time, it would more reasonable (admitting that Perl 6 grammars and regexes are not very optimized yet).

Is there a way to either run this at compile time or generate a .pm6 file from a BNF/ABNF grammar? I would really like the latter because then I could hand edit it to optimize it. But it makes for a really super-nice way to go from 0 to MVP for lots of problems.

As sub guts basically does a bunch of evals, it seems like it shouldn't be too hard, but I've been struggling to find the right way to make it work with the custom .parse method.