NextPrevUpTopContentsIndex

16.2 Grammar rules

The parser generator is accessed by the macro defparser , described below:

defparser

Macro

defparser name { rules }*

name

The name to be used for the parsing function. The remainder of the macro form specifies the reduction rules and semantic actions for the grammar.

rules

The rules specified in a defparser form are of two types, normal rules and error rules , described below.

Each normal rule corresponds to one production of the grammar to be parsed:

(( non-terminal { grammar-symbol }*) { form }*)

The non-terminal is the left-hand side of the grammar production and the list of grammar symbols defines the right-hand side of the production. (The right-hand side may be empty.) The list of forms specifies the semantic action to be taken when the reduction is made by the parser. These forms may contain references to the variables $1 ... $n , where n is the length of the right hand side of the production. When the reduction is done, these variables are bound to the semantic values corresponding to the grammar symbols of the rule.

16.2.1 Example

16.2.2 Resolving ambiguities


LispWorks User Guide - 21 Jul 2006

NextPrevUpTopContentsIndex