Nud and Led Definition
----------------------
This section describes advanced features. You can skip this section
on first reading.
The "Null Denotation" (or "nud") of a token is the procedure and
arguments applying for that token when "Left", an unclaimed parsed
expression is not extant.
The "Left Denotation" (or "led") of a token is the procedure,
arguments, and lbp applying for that token when there is a "Left", an
unclaimed parsed expression.
In his paper,
Pratt, V. R. Top Down Operator Precendence. `SIGACT/SIGPLAN
Symposium on Principles of Programming Languages', Boston, 1973,
pages 41-51
the "left binding power" (or "lbp") was an independent property of
tokens. I think this was done in order to allow tokens with NUDs but
not LEDs to also be used as delimiters, which was a problem for
statically defined syntaxes. It turns out that _dynamically binding_
NUDs and LEDs allows them independence.
For the rule-defining procedures that follow, the variable TK may be a
character, string, or symbol, or a list composed of characters,
strings, and symbols. Each element of TK is treated as though the
procedure were called for each element.
Character TK arguments will match only character tokens; i.e.
characters for which no token-group is assigned. Symbols and strings
will both match token strings; i.e. tokens resulting from token groups.
- Function: prec:make-nud tk sop arg1 ...
Returns a rule specifying that SOP be called when TK is parsed.
If SOP is a procedure, it is called with TK and ARG1 ... as its
arguments; the resulting value is incorporated into the expression
being built. Otherwise, `(list SOP ARG1 ...)' is incorporated.
If no NUD has been defined for a token; then if that token is a string,
it is converted to a symbol and returned; if not a string, the token is
returned.
- Function: prec:make-led tk sop arg1 ...
Returns a rule specifying that SOP be called when TK is parsed and
LEFT has an unclaimed parsed expression. If SOP is a procedure,
it is called with LEFT, TK, and ARG1 ... as its arguments; the
resulting value is incorporated into the expression being built.
Otherwise, LEFT is incorporated.
If no LED has been defined for a token, and LEFT is set, the parser
issues a warning.