Next: lang lr1, Previous: lang grammar, Up: Lexing and Parsing
[todo: write blurb]
Return the item table for grammar g, making it if necessary.
Every grammar is given an item table: a vector of all items associated with the grammar. An item's position in this table is called the item's "index".
The extent of the table is tied to the extent of g, and the extent of items to the table. For a given production, and position, make-item (see below) will always return
eq?items from the item-table of the grammar.
Return the kernel of the starting superstate for grammar g. This is an item-set of sorts.
Only the initial items of start-symbol productions are included in this set. Compose with
item-set-closureto also obtain all items reachable by epsilon transitions.
For grammar g, with item-set is, shift symbol symbol and return the resulting (possibly empty) item-set.
Only the items which are direct successors of items in is are present in the successor kernel. To also include all items reachable by epsilon transitions, use
item-set-closure.
For grammar g, return the (possibly empty) set of all productions that can be reduced from item-set is, disregarding the context and look-ahead.
For grammar g, return the epsilon transition closure of item set is.
In the LR(0) NFA, if we are at the state:
A -> w * B vThen we are also an epsilon transition (not to be confused with an empty reduction) away from also being in the items:
B -> * u B -> * r B -> * s ...So if a superstate contains
A->w*Bv, then it should also contain the inital states ofB. This rule applies transitively.If is was returned by
item-set-start-kernel, then this procedure returns the DFA start state.If is was returned by
item-set-successor-kernel, and the IS argument toitem-set-successor-kernelwas a DFA state, then this procedure returns a DFA state.
There is also a drop-in replacement for (lang lr0) that provides
some additional debugging facilities: (lang lr0-debug).
Check production-specific invariants for obj. If there is a problem, signal error with message of the form:
supposed production INVARIANT-ERRORwhere invariant-error is one of:
- not a list
- has length not >= 2
- car not a symbol
- cadr not a list of symbols
Check item-specific variants for obj. If there is a problem, signal error with message of the form:
supposed item INVARIANT-ERRORwhere invariant-error is one of:
- not a list
- cdr CDR not a subset of the expansion EXPANSION
Check item-set-specific variants for obj. If there is a problem, signal error with message of the form:
supposed item-set INVARIANT-ERRORwhere invariant-error is one of:
Additionally, check each member of the item-set with
- not a list
VALIDATE:item.
Decorate grammar productions with nicknames and return it. For each production, call
VALIDATE:productionon it and then decorate with a string of the form "PRODUCTION-SYMBOL[ADDRESS]".
Display grammar item table table to the current output port.
Display the item-set closure isc to the current output port.
See lang debug-common, for other debugging facilities.