The simple elements of the top-level parser
The basic elements of the top-level parser are the line, the non-empty line, the comment, and the blank line.
The line in itself is a simple element; it's "anything you like" as a
regular expression, /.*/
. So why is it useful? The line is an element of
more complex rules. It is only used when the input is known not to be a
blank line or a comment, so in effect the line is a nugget of information.
The compound class is any sequence of valid class names. The character
set is /[-\w]+/
intermixed with any number of boolean logic predicates, /!.|/
, according to the cfengine rules. The actual meaning of the compound
class ("true" or "false" depending on the individual classes within and
how they are logically combined) will be determined at the time of
cfperl's command execution.
A non-empty line is anything that begins with a non-space character. It can contain anything afterwards, but the existence of a non-space character makes it non-empty.
The comment line is anything that begins with a "#" character (with or without spaces before it). Anything after the "#" character is assumed to be a comment. Note that the top-level grammar does not at this time remove comments at the end of a line. This can be done but can complicate the grammar significantly, and I've left it a later point in the development process. At first blush it seems like an easy task, but in fact catching the cases where the "#" character is part of a string is not so easy.
Blank lines are all lines with nothing but space characters between beginning and end.
View The road to better programming: Chapter 8. The top-level and compound-class parsers Discussion
Page: 1 2 3 4 5 6 7 Next Page: Sections and classes