Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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
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 (Friar) on Sep 03, 2013 at 13:39 UTC

    Please ignore ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1051980]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-09-30 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (381 votes), past polls