The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Parse::RandGen::Condition - Base class for condition elements that contain an element (regex, subrule, literal) and a match quantifier

DESCRIPTION

There are several specific Condition classes: Subrule, Literal, CharClass, and Regexp. Literals and CharClass's are terminal Conditions.

METHODS

new

This method cannot be called directly from the Condition class (it must be called on a specific derived Condition class). The first argument (required) is the condition element. The required element type depends on the specific Condition class being constructed.

All other arguments are named pairs.

Some classes (Subrule and CharClass) support the optional arguments "min" and "max", which represent the number of times that the subrule must match for the condition to match.

The "quant" quantifier argument can also be used in place of "min" and "max". The values are the familiar '+', '?', or '*' (also can be 's', '?', or 's?', respectively).

Any unknown named arguments are treated as user-defined fields. They are stored in the Condition hash ($cond->{}).

  Parse::RandGen::Literal->new("Don't mess with Texas!");
  Parse::RandGen::Regexp->new(qr/Hello( World)?/,  userDefinedField => $example );
  Parse::RandGen::Subrule->new("match_rule", quant=>'+' );    # This indirect reference to the "match_rule" rule requires a Grammar for lookup.
  Parse::RandGen::Subrule->new($myRuleObjRef, min=>2, max=>3 );
pick

Returns random data for the Condition. Takes an optional named pair argument "match" that specifies whether the data chosen should match the Condition element or not.

  $conditionObject->pick( match=>1 );
element, min, max

Returns the Condition's attribute of the same name.

isSubrule

Returns true if the given Condition is a Subrule.

isTerminal

Returns true if the given Condition is a terminal (CharClass or Literal).

subrule

Returns a reference to the Condition's Rule object (or undef if !isSubrule()).

production

Returns the Parse::RandGen::Production object that this Condition belongs to.

rule

Returns the Parse::RandGen::Rule object that this Condition's Production belongs to (returns production()->rule()).

grammar

Returns the Parse::RandGen::Grammar object that this production belongs to (returns production()->rule()->grammar()).

SEE ALSO

Parse::RandGen, Parse::RandGen::Rule, Parse::RandGen::Production, Parse::Literal, Parse::Regexp, Parse::Subrule, and Parse::CharClass

AUTHORS

Jeff Dutton