ExpectedDebug
(#455)
* Ignore trailing commas in `ExpectedDebug` rust-lang/rust/pull/59076 changed the multiline Debug representation to always include a trailing comma. This change currently breaks our tests on beta and nightly, since we use this Debug representation to compare expected parsing output. We cannot simply add the trailing commas to the expected output strings, since that would break on older rustc versions we support. Instead, this commit makes it so that all trailing commas are stripped before the comparison. This workaround can be removed once rust-lang/rust/pull/59076 reaches our minimum supported rustc version. * Bump minimum Rust version to 1.31.0 That's required by the current version rustc-demangle, which is a dependency of mdbook.
LALRPOP
LALRPOP is a Rust parser generator framework with usability as its primary goal. You should be able to write compact, DRY, readable grammars. To this end, LALRPOP offers a number of nifty features:
- Nice error messages in case parser constructor fails.
- Macros that let you extract common parts of your grammar. This
means you can go beyond simple repetition like
Id*
and define things likeComma<Id>
for a comma-separated list of identifiers. - Macros can also create subsets, so that you easily do something
like
Expr<"all">
to represent the full range of expressions, butExpr<"if">
to represent the subset of expressions that can appear in anif
expression. - Builtin support for operators like
*
and?
. - Compact defaults so that you can avoid writing action code much of the time.
- Type inference so you can often omit the types of nonterminals.
Despite its name, LALRPOP in fact uses LR(1) by default (though you can opt for LALR(1)), and really I hope to eventually move to something general that can handle all CFGs (like GLL, GLR, LL(*), etc).
Documentation
The LALRPOP book covers all things LALRPOP -- or at least it intends to! Here are some tips:
- The tutorial covers the basics of setting up a LALRPOP parser.
- For the impatient, you may prefer the quick start guide section, which describes
how to add LALRPOP to your
Cargo.toml
. - The advanced setup chapter shows how to configure other aspects of LALRPOP's preprocessing.
Example Uses
- LALRPOP is itself implemented in LALRPOP.
- Gluon is a statically typed functional programming language.
- Gleam is a statically typed functional programming language for the Erlang VM.
Contributing
cargo test
does not test that lalrpop generates a correct grammar for itself by default. So if you have made a change that would modify LALRPOP's own parser (lalrpop/src/parser/lrgrammar.rs
) you need to run cargo test --all-features
after making sure that a built lalrpop binary exists with cargo build -p lalrpop
(see .travis.yml
for the exact procedure).