voj has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to specify a simple text-based format as grammar in EBNF (or ABNF) and create a parser from this specification. The parser should just spit out an abstract syntax tree or an error message. The point is, I want the parser to be created automatically from the grammar. I have looked at Marpa, Regexp::Grammars, and Pegex but all seem to want their own custom dialect of BNF with tiny, annoying limitations and required extensions. Is there a workflow to do it just like this?:
$parser = grammar_to_parser($grammar);
say Data::Dumper::Dump( $parser->parse($input) );
I don't want no custom grammar syntax but standard BNF as defined in ISO 14977 or RFC 5234.
  • Comment on How to create a parser from an [AE]BNF grammar

Replies are listed 'Best First'.
Re: How to create a parser from an [AE]BNF grammar
by Anonymous Monk on Sep 02, 2013 at 21:25 UTC

    Yes, what you do is you write a ABNF parser using one of those grammars, then you parse your abnf into one of those grammars, and then you're done :)

    Oh look, Convert Augmented BNF (ABNF) to Regexp::Grammars

    OTOH, (I think) SLIF has a few good points about BNF

Re: How to create a parser from an [AE]BNF grammar
by clueless newbie (Curate) on Sep 03, 2013 at 13:39 UTC

    Please ignore ...