mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-04-24 18:52:16 +00:00
Only the states in the beginning of a reduction are actually used, the states for all other rows will never be used (really, no zero elements will be accessed in the GOTO table so we might be able to do even better without compromising performance). By simply reordering the states so that states needed in the GOTO table occupy the lower indices we can simply avoid generating the remaining part of the GOTO table. For the LALRPOP parser itself this is a reduction of about -40% (~100kB) of the size of the parse tables (not counting the generated code)
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.
- If you have any questions join our gitter lobby.
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.
- RustPython is Python 3.5+ rewritten in Rust
- Solang is Ethereum Solidity rewritten in Rust
Contributing
You really should read CONTRIBUTING.md
if you intend to change LALRPOP's own grammar.
Description
Languages
Rust
99.8%
Shell
0.2%