All Manuals > LispWorks User Guide and Reference Manual > 45 The PARSERGEN Package

NextPrevUpTopContentsIndex

defparser

Macro
Summary

Creates a parsing function of the given name for the grammar defined.

Package

parsergen

Signature

defparser name-and-options {rule}* => parsing-function

name-and-options := name | (name [[option]]) option ::= :accept-without-eoi-p accept-without-eoi-p rule ::= normal-rule | error-rule | combined-rule normal-rule ::= ((non-terminal {grammar-symbol}*) {form}*) error-rule ::= ((non-terminal :error) {form}*) combined-rule ::= (non-terminal {combined-rule-clause}*) combined-rule-clause ::= (combined-rule-lhs {form}*) combined-rule-lhs ::= ({grammar-symbol}*) | (:error)
Arguments

name

The name of the parser.

accept-without-eoi-p
A generalized boolean.

The rules define the productions of the grammar and the associated forms define the semantic actions for the rules.

Values

parsing-function

The symbol name of the parsing function.

Description

defparser creates a parsing function of the given name for the grammar defined. The parsing function is defined as if by:

(defun <name> (lexer &optional (symbol-to-string #'identify))

The lexer parameter is a function of no arguments that returns two values: the next grammar token on the input and the associated semantic value.

The optional symbol-to-string function can be used to define a printed representation of the grammar tokens. The function should take a grammar symbol as its single argument and returns an object to be used as a print representation for the grammar token.

When accept-without-eoi-p is true, the parser accepts the input as soon as the top level rule matches completely rather than waiting for end of input (eoi). The default value of accept-without-eoi-p is false.

For a full description and examples, see The Parser Generator.


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex