The group section parser
The parser for the
section will define classes based on other classes' existence. For
instance, "a = ( b )" will define "a" only if "b" has already been
defined. The group-based class definition abilities of cfengine/cfperl
are very powerful.
As with all other cfperl parsers, this one has an
input() method. Here,
input() can only do one thing: define groups. Remember that with the
Parse::RecDescent module, all rules are also methods, which is why we regard
input() as a method.
define_group rule is based on the class and
class_definition rules. The class can only be a word made up of what Perl considers word (
characters, but we can change that definition if we have to. For
instance, we could have "word: /[\w-]+/" as a rule if we wanted hyphens
to also be valid class characters.
class_definition rule is made up of at least one class name. Thus, "groupname = ()" would not be a valid line in the
section in cfperl. If we wanted to allow that, we could use
"class_definition: class(s?)" in the rule. But we don't, because it
makes no sense to have that.
define_group rule uses
to build a group definition action. It is more liberal than cfengine's
group definition rule, which requires that the parentheses be
surrounded with space, so "groupname = (linux)" is invalid. Cfperl will
parse that line happily. If you wanted to force cfengine's behavior,
you could use the following:
That stricter behavior, however, is unnecessary in my opinion.
define_group rule uses the
Parse::RecDescent data structures to build the two parameters to the external
define_group() function. Note that the external
define_group() function is global, as denoted by the two colons before its name.