Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

How to create a parser from an [AE]BNF grammar

by voj (Acolyte)
on Sep 02, 2013 at 20:36 UTC ( #1051980=perlquestion: print w/replies, xml ) Need Help??
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 (Chaplain) on Sep 03, 2013 at 13:39 UTC

    Please ignore ...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1051980]
Approved by Old_Gray_Bear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2018-04-19 21:53 GMT
Find Nodes?
    Voting Booth?