1
package GenTest::Grammar::Rule;
6
use constant RULE_NAME => 0;
7
use constant RULE_COMPONENTS => 1;
11
'components' => RULE_COMPONENTS
16
my $rule = bless ([], $class);
18
my $max_arg = (scalar(@_) / 2) - 1;
20
foreach my $i (0..$max_arg) {
21
if (exists $args{$_[$i * 2]}) {
22
$rule->[$args{$_[$i * 2]}] = $_[$i * 2 + 1];
24
warn("Unkown argument '$_[$i * 2]' to ".$class.'->new()');
31
return $_[0]->[RULE_NAME];
35
return $_[0]->[RULE_COMPONENTS];
39
$_[0]->[RULE_COMPONENTS] = $_[1];
44
my $components = $rule->components();
45
return $rule->name().":\n\t".join(" |\n\t", map { join('', @$_) } @$components).";";