in reply to Backus Naur Form

If you have a grammar for your BNF rules, you could use Parse::RecDescent to parse the BNF rules for you. Decide on a 'nice structure' that you would like to compile the BNF rules into, and write Parse::RecDescent rules to create that structure as Parse::RecDescent parses your BNF rules.

-Mark

Replies are listed 'Best First'.
Re^2: Backus Naur Form
by merlyn (Sage) on Apr 27, 2005 at 00:13 UTC
Re^2: Backus Naur Form
by spurperl (Priest) on Apr 27, 2005 at 05:13 UTC
    P::RD (Parse::RecDescent) uses BNF to parse text. It doesn't parse BNF. If I understood the OP correctly, he wants to parse the BNF notation itself, i.e. given a file with a BNF description, create a parse tree from it.

    Naturally, you can use P::RD it to either:

    1. Look into its source and see how it parses the BNF.
    2. Write a grammar for BNF in it
    I recommend the second technique, because it's (1) very simple, the BNF notation is trivial. (2) Will let one understand BNF as the rule descriptions of P::RD are written in it.
      P::RD doesnt *quite* use BNF, in fact its kind of a slightly mutated *Extended*BNF (EBNF). BNF itself is a lot simpler.

      C.