Previous: Earley Parser, Up: Syntax Protocol
An incremental parser is created from a grammar.
Here symbol is the target symbol of the rule, and should be the name of a CLOS class.
Here var is the name of a lexical variable. The scope of the variable contains the test, all the following arguments and the body of the rule. The type is a Common Lisp type specification. The rule applies only of the type of the object contain in var is of that type. The test contains arbitrary Common Lisp code for additional checks as to the applicability of the rule.
Here, type must be a symbol typically the name of a CLOS class.
This form is an abbreviation for (
var type t)
.
Here, test must not be a symbol. This form is an abbreviation
of (
var var test)
, i.e., the name of the
variable is also the name of a type, typically a CLOS class.
This form is an abbreviation of (
var var t)
.
The body of a rule, if present, contains an expression that should have an instance (not necessarily direct) of the class named by the symbol (the left-hand-side) of the rule. It is important that this restriction be respected, since the Earley algorithm will not work otherwise.
If the body is absent, it is the same as if a body of the form
(make-instance '
symbol)
had been given.
The body can also be a sequence of forms, the first one of which must be
a symbol. These forms typically contain initargs, and will be passed as
additional arguments to (make-instance '
symbol)
.