NAME
Parse::EBNF - Parse W3C-Style EBNF Grammars
SYNOPSIS
use Parse::EBNF;
my $parser = Parse::EBNF->new();
# parse lines into rules
$parser->parse_lines(\@lines);
# fetch all compiled rules
my $rules = $parser->rules();
# print all rules using Data::Dumper
$parser->dump_rules();
# print a named rule using Data::Dumper
$parser->dump_rule('MyProductionName');
DESCRIPTION
This module takes W3C-Style EBNF Grammar rules and converts them into an array of Parse::EBNF::Rule objects, which contain token trees. These trees are then trivial to convert into other grammar formats (like P:RD).
METHODS
new()
-
Creates a new parser.
parse_lines( $arrayref )
-
Parses a number of rule lines.
rules()
-
Returns a hashref of Parse::EBNF::Rule objects.
dump_rules()
-
Prints a Data::Dumper view of all compiled rules.
dump_rule( $rule_name )
-
Prints a Data::Dumper view of a single named rule.
BUGS
Multiline comments aren't handled correctly. Production negation isn't implemented. Only W3C style numbered rules are parsed (This could be easily fixed).
AUTHOR
Copyright (C) 2005, Cal Henderson <cal@iamcal.com>