Next: Grammar Rule Definition, Previous: Token definition, Up: Precedence Parsing [Contents][Index]
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.
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.
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.
Next: Grammar Rule Definition, Previous: Token definition, Up: Precedence Parsing [Contents][Index]