Next: , Previous: lang lr0, Up: Lexing and Parsing


41.4 LR(1) parser

[todo: write blurb]

— Scheme Procedure: parser-value-cons v vs

Return the result of adding value v to value stack vs.

— Scheme Procedure: parser-value-car vs

Return the top of the value stack vs.

— Scheme Procedure: parser-value-cdr vs

Return the rest of the value stack vs, excluding the top value.

— Scheme Procedure: parser-value-cdr-ref vs n

Return the rest of the value stack vs, excluding the first n values.

— Scheme Procedure: parser-context-cons g state context

For grammar g, return the result of adding state to the context stack.

— Scheme Procedure: parser-context-car context

Return the top of the context stack.

— Scheme Procedure: parser-context-cdr context

Return the rest of the context stack.

— Scheme Procedure: parser-context-cdr-ref context n

Return the rest of the context stack, excluding the first n states.

— Scheme Procedure: make-parser-state g is

For grammar g, return the parser state associated with item set is, creating it if necessary.

— Scheme Procedure: parser-state-item-set state

Return the item set extracted from a parser state.

— Scheme Procedure: parser-start-state g

Return the initial parser state derived from grammar g's item-set-start-kernel. Cache the return value.

— Scheme Procedure: parser-action g state token-type module

Given grammar g's state and the current token-type, determine the action to take (shift, reduce, or error) in module's environment, and return the form:

            (ACTION [DATA])

Here DATA is next state (if shifting), a list of the production functions (if reducing), or empty (if error). Cache the return value.

— Scheme Procedure: lr1-parse g lexer parse-error module

Do parsing for grammar g that uses token-providing procedure lexer and error-handling procedure parser-error, with reductions taking place in the environment of module module.

[At this time, I don't know if this procedure returns. So far, I've only tested with a throw in the reduction body. –ttn]

There is also a drop-in replacement for (lang lr1) that provides some additional debugging facilities: (lang lr1-debug).

— Scheme Procedure: VALIDATE:state-stack-entry obj

Check state-stack-entry specific invariants for obj. (Actually, at this time, no checks are done.) Return obj.

— Scheme Procedure: display-state-stack-entry state

Display state stack entry state to the current output port.

See lang debug-common, for other debugging facilities.