48 releases

0.22.0 Oct 2, 2024
0.20.2 Feb 29, 2024
0.20.1 Oct 23, 2023
0.20.0 May 5, 2023
0.2.0 Jul 27, 2015

#4 in Parser tooling

Download history 180093/week @ 2024-08-04 181020/week @ 2024-08-11 187984/week @ 2024-08-18 188624/week @ 2024-08-25 185232/week @ 2024-09-01 186396/week @ 2024-09-08 174710/week @ 2024-09-15 195735/week @ 2024-09-22 212066/week @ 2024-09-29 208904/week @ 2024-10-06 198680/week @ 2024-10-13 209055/week @ 2024-10-20 194150/week @ 2024-10-27 192212/week @ 2024-11-03 182924/week @ 2024-11-10 191307/week @ 2024-11-17

771,273 downloads per month
Used in 863 crates (214 directly)

Apache-2.0 OR MIT

2MB
58K SLoC

LALRPOP

Join the chat at https://gitter.im/lalrpop/Lobby

Deploy

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:

  1. Nice error messages in case parser constructor fails.
  2. Macros that let you extract common parts of your grammar. This means you can go beyond simple repetition like Id* and define things like Comma<Id> for a comma-separated list of identifiers.
  3. Macros can also create subsets, so that you easily do something like Expr<"all"> to represent the full range of expressions, but Expr<"if"> to represent the subset of expressions that can appear in an if expression.
  4. Builtin support for operators like * and ?.
  5. Compact defaults so that you can avoid writing action code much of the time.
  6. 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.
  • Returning users of LALRPOP may benefit from the cheat sheet.
  • 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.
  • 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.

Dependencies

~7–15MB
~175K SLoC