The form
(defparser
name
grammar
)
defines two main functions. The function <
name
> is defined as the parsing function, and the function <
name
>
-grammar
is a parameterless function that returns the grammar, as presented to the parser generator. For example:
(defparser my-parser .. grammar .. )
(defun my-parser (lexer &optional
(symbol-to-string #'identity)) ...)
(defun my-parser-grammar () ..)
The
lexer
parameter to the parser function specifies the lexical analyzer function to be used. The optional
symbol-to-string
function may be used to define a mapping from grammar symbols to strings for printing purposes. It defaults to the identity function.
defparser
also defines functions corresponding to the individual actions of the parser.
<
parser-name
>-
action
<
index
>
<
parser-name
>-
error-action
<
index
>
parser-name here is the name as given to defparser. index is the number of the rule or error rule in the grammar.
All function names are interned in the current package when
defparser
is called.