NAME

Parse::EBNF::Rule - An EBNF production rule

SYNOPSIS

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();

DESCRIPTION

This module parses a single EBNF production into a tree of Parse::EBNF::Token objects.

METHODS

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.

AUTHOR

Copyright (C) 2005, Cal Henderson <cal@iamcal.com>

SEE ALSO

Parse::EBNF, Parse::EBNF::Token