NAME
Parse::RandGen::Rule - Grammatical Rule object
DESCRIPTION
A Rule matches if any one of its Productions match the input text. In BNF notation, the relationship of Rules and Productions is:
rule1: production1
| production2
| production3
For example:
perlFuncCall: /&?/ identifier '(' argument(s?) ')'
| scalar '->' identifier '(' argument(s?) ')'
The two productions in this example could respectively match:
"func()", "func(x, y)", or "&func(x)"
"$obj->member()"
METHODS
new
Creates a new Rule. The Rule name is the only required argument. Productions are optional.
Parse::RandGen::Rule->new (
name => "perlFuncCall", # Rule name (optional if an anonymous rule)
# "prod" specifies a new Production object on this Rule
prod => [ name => "staticFuncCall", # Production name is optional
cond => qr/&?/, # Regexp Condition - 0 or 1 '&' characters
cond => "indentifier", # Subrule Condition - exactly 1 "identifier" rule
cond => q{'('}, # Literal Condition - single '(' character
cond => "argument(s?)", # Subrule Condition - 0 or more "argument" rules
cond => q{')'}, ], # Literal Condition - single ')' character
prod => [ name => "objectFuncCall", # Rule's second production
cond => "scalar",
cond => q{'->'},
cond => "indentifier",
cond => q{'('},
cond => "argument(s?)",
cond => q{')'}, ],
);
name
Return the name of the Rule.
grammar
Returns a reference to the Grammar that the Rule belongs to.
pick
Takes a "match" boolean argument. The function returns random text that would match (or not match) the given rule.
SEE ALSO
Parse::RandGen, Parse::RandGen::Grammar, Parse::RandGen::Production, and Parse::RandGen::Condition
AUTHORS
Jeff Dutton
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 210:
You forgot a '=back' before '=head1'
- Around line 247:
=back without =over