Parse::EBNF::Rule - An EBNF production rule
use Parse::EBNF::Rule; my $input = "[1] MyRule ::= 'foo' | 'bar'"; # parse a rule my $rule = Parse::EBNF::Rule->new(); $rule->parse($input); ..OR.. my $rule = Parse::EBNF::Rule->new($input); # check if parsing succeed die $rule->error() if $rule->has_error(); # get the root token for this rule my $token = $rule->base_token();
This module parses a single EBNF production into a tree of Parse::EBNF::Token objects.
new( [$input] )
Creates a new rule object, and optionally parses the input.
parse( $input )
Parses input into a token tree.
has_error()
Returns 1 if an error occured during the last parse, 0 if not.
error()
Returns the error string from the last parse failure.
base_token()
Returns the root Parse::EBNF::Token object for the rule.
Copyright (C) 2005, Cal Henderson <cal@iamcal.com>
Parse::EBNF, Parse::EBNF::Token
To install Parse::EBNF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::EBNF
CPAN shell
perl -MCPAN -e shell install Parse::EBNF
For more information on module installation, please visit the detailed CPAN module installation guide.