Crates.io | ielr |
lib.rs | ielr |
version | 0.1.1 |
source | src |
created_at | 2023-04-14 09:02:41.690377 |
updated_at | 2023-05-06 17:33:54.849653 |
description | Table generation backend for LR parser generators |
homepage | |
repository | https://gitlab.com/arnaudgolfouse/ielr |
max_upload_size | |
id | 839052 |
size | 379,671 |
This is an implementation of the IELR algorithm, described in a paper by Joel E.Denny and Brian A.Malloy: The IELR(1) algorithm for generating minimal LR(1) parser tables for non-LR(1) grammars with conflict resolution.
use ielr::{input, compute_table, Algorithm};
const START_NODE: input::Node = input::Node(0);
let grammar = input::Grammar::new();
// ...
// add grammar productions
// ...
let table = match compute_table(
Algorithm::Lalr(std::num::NonZeroU8::new(1).unwrap()),
&grammar,
[START_NODE],
) {
Ok((table, _statistics)) => table,
Err(_) => unimplemented!("handle error"),
};
For more complete examples, see the examples directory.
This crate is meant to be used by a parser generator. It builds the LR(1) table for a grammar, using an efficient and minimal algorithm.
Note that this crate does not include:
grammar.add_rule(left, right);
)At the moment, two algorithms are provided: LALR(1) and LR(1).
In the future, I would like to implement the following features: