Prev Up Next
Go backward to Grammars
Go up to Top
Go forward to Generating a Specialized Parser

Running a Parser

Parsing with respect to a grammar does not require generating a specialized parser along with the associated overhead of compiling and loading. Essence provides general parsers which accept a grammar as input and parse "right away." This allows incremental debugging and development of attributed grammars to be used with Essence.

Essence actually comes with a number of different implementations of LR parsing. The packages.scm configuration file contains definitions for a range of structures all with the interface parser-interface. The one intended for production use is in the cps-lr structure whose implementation resides in cps/cps-lr.scm. Parser-interface describes only one binding called parse:

 

(parse  grammar lookahead method input) procedure

Parse returns the result of attribute evaluation on the parse tree induced by input. This is ultimately the result of the attribution associated with the start production.

If the grammar contains productions containing $error symbols, the parser will attempt error recovery when possible.

Parsing is not reentrant. (Actually, the cps-attrib-error structure implemented by cps/cps-attrib-error.scm does implement reentrant parsing. The parser generator does not currently use it, however.)


Mike Sperber, Peter Thiemann

Prev Up Next