A grammar is built by one or more calls to
The rules are appended to *syn-defs*. The value of
*syn-defs* is the grammar suitable for passing as an argument to
Is a nearly empty grammar with whitespace characters set to group 0,
which means they will not be made into tokens. Most rulesets will want
to start with
In order to start defining a grammar, either
(set! *syn-defs* '())
(set! *syn-defs* *syn-ignore-whitespace*)
Appends rule1 … to *syn-defs*.
prec:define-grammar is used to define both the character classes
and rules for tokens.
Once your grammar is defined, save the value of
*syn-defs* in a
variable (for use when calling
(define my-ruleset *syn-defs*)
The ruleset argument must be a list of rules as constructed by
prec:define-grammar and extracted from *syn-defs*.
The token delim may be a character, symbol, or string. A character delim argument will match only a character token; i.e. a character for which no token-group is assigned. A symbol or string will match only a token string; i.e. a token resulting from a token group.
prec:parse reads a ruleset grammar expression delimited
by delim from the given input port.
returns the next object parsable from the given input port,
updating port to point to the first character past the end of the
external representation of the object.
For the purpose of reporting problems in error messages, this package
keeps track of the current column. Its initial value is passed
as the third argument to
If an end of file is encountered in the input before any characters are
found that can begin an object, then an end of file object is returned.
If a delimiter (such as delim) is found before any characters are
found that can begin an object, then
#f is returned.
The port argument may be omitted, in which case it defaults to the
value returned by
current-input-port. It is an error to parse
from a closed port.