Expand description

This module implements a zero-copy version of the runtime parser that uses the LR statemachine generated by rustlr. It will (for now), live side along with the original parser implemented as crate::RuntimeParser. Since Version 0.2.3, this module can now generate a basic lexical scanner based on crate::RawToken and crate::StrTokenizer.

This module implements the parsing routines that uses the state machine generated by rustlr. The main structure here is ZCParser. All parsing functions are organized around the ZCParser::parse_core function, which implements the basic LR parsing algorithm. This function expects dynamic Tokenizer and ErrReporter trait-objects. This module provides generic parsing and parser-training routines that use stdio for interface, but the ErrReporter trait allows custom user interfaces to be build separately.

Structs

these structures are what’s on the parse stack. When writing a grammar rule such as E --> E:a + E:b, the variables a and b will be bound to values of this type, and thus inside the semantic actions one would need to use a.value to extract the value, which is of the declared ‘absyntype’ of the grammar. Alternatively, one can use a pattern: E:@a@ + E:@b@ to bind a and b directly to the values.

this is the structure created by the generated parser. The generated parser program will contain a make_parser function that returns this structure. Most of the pub items are, however, only exported to support the operation of the parser, and should not be accessed directly. Only the functions ZCParser::parse, ZCParser::report, ZCParser::abort and ZCParser::error_occurred should be called directly from user programs. Only the field ZCParser::exstate should be accessed by user programs.

this structure is only exported because it is required by the generated parsers. There is no reason to use it in other programs. Replaces crate::RProduction for new parsers since version 0.2.0

Traits

A trait object that implements ErrReporter is expected by the ZCParser::parse_core function, which implements the basic LR parsing algorithm using the generated state machine. The struct StandardReporter is provided as the default ErrReporter that uses standard I/O as interface and has the ability to train the parser. But other implementations of the trait can be created that use different interfaces, such as a graphical IDE.