Defchar
Introduce lexing utilites from a character recognizer.
Defchar is a macro for quickly introducing character classes
and functions to read them.
General Form
(defchar basename criteria
[:prefix prefix]
[:pkg pkg]
[:parents parents]
[:short short]
[:long long])
Example
(defchar whitespace
(or (eql x #Space)
(eql x #Tab)
(eql x #Page)
(eql x #Newline)))
The basename, prefix, and pkg are each symbols which
influence the names of the new definitions and theorems we introduce. In
particular,
- The basename is the name of the main part of the new character type
you are introducing.
- The prefix is prepended to the symbol names we generate, and defaults
to the symbol 'vl-. For instance, in the above example, the
single-character recognizer will be named vl-whitespace-p.
- The pkg is used to control what package the new functions and theorems
are defined in. It defaults to 'VL::foo, so in the above example the
symbols are introduced in the VL:: package.
Finally, the criteria is some term about the variable x. You may
assume that x is an ordinary characterp, and specify what kinds of
characters you want using functions such as eql and char<=.
Calling this macro introduces the following functions:
- (PKG::PREFIX-BASENAME-P X), recognizes those characterps which
satsify criteria,
- (PKG::PREFIX-BASENAME-ECHAR-P X), recognizes those vl-echar-ps
whose character satisfies criteria,
- (PKG::PREFIX-BASENAME-LIST-P X), recognizes those
character-listps where every character satisfies criteria,
- (PKG::PREFIX-READ-WHILE-BASENAME ECHARS) splits echars into a
prefix and remainder, where prefix is the longest leading list of
characters that satisfy criteria.
It also introducs a number of theorems, enumerated in vl-read-while-ctype.
Subtopics
- Vl-read-while-ctype
- Match as many characters of some type as possible.
- Vl-ctype-p
- Generic stub for a character type recognizer.
- Vl-ctype-list-p
- (vl-ctype-list-p x) recognizes lists where every element satisfies vl-ctype-p.