Crate rustemo_compiler

source ·
Expand description

This crate provides a Rustemo grammars compiler as a CLI command, and an API for usage from build.rs scripts.

When this crate is installed rcomp command is available that can be run over Rustemo grammars to produce parsers.

The entry point into API is Settings::new which provide a default settings value which can be further configured in a builder pattern style calling methods of Settings and finally executed using Settings::process_dir or Settings::process_grammar methods.

§Example

rustemo_compiler::Settings::new().force(true).in_source_tree().process_dir()

§Processing grammars

For default settings there are process_crate_dir, process_dir and process_grammar shortcut functions.

§Example

Usual pattern you can use in build.rs is:

if let Err(e) = rustemo_compiler::process_crate_dir() {
    eprintln!("{}", e);
    exit(1);
}

Re-exports§

Modules§

Macros§

  • Used in tests to calculate local file path relative to the source file. Requires call to file!() as a first parameter.
  • Used in tests for storing and comparing string representations in files.

Structs§

  • Provides parser settings information. It is the main entry point in the parser generation process. It is meant to be used from the project build.rs script. See tests crate build.rs script for examples of various configurations.

Enums§

  • The builder type used during parsing to construct the output
  • Different generated parser table variants with different trade-offs
  • The lexer type used during parsing to break the input into tokens
  • The parsing algorithm used
  • Specifies the type of the parsing table used during parsing to decide about shift/reduce/goto operations.

Functions§

  • A shortcut function which creates default Settings and use it to process the crate project directory.
  • Recursively process a given dir and generate a parser for each found grammar with default settings.
  • Generates a parser from the given grammar file with default settings.

Type Aliases§