#parser #combinator #functional

lip

Lip provides powerful parser combinators for creating reusable and flexible parsers

16 stable releases (7 major)

7.0.0 Jan 1, 2022
6.0.0 Dec 31, 2021
5.2.1-beta.0 Dec 30, 2021
5.1.1 Nov 9, 2021
0.1.2 Mar 24, 2020

#38 in Parser tooling

Download history 14/week @ 2021-09-25 32/week @ 2021-10-16 1/week @ 2021-10-23 52/week @ 2021-11-06 5/week @ 2021-11-13 10/week @ 2021-11-20 17/week @ 2021-11-27 35/week @ 2021-12-04 4/week @ 2021-12-11 1/week @ 2021-12-18 31/week @ 2021-12-25 25/week @ 2022-01-01 13/week @ 2022-01-08

70 downloads per month
Used in wordshk_tools

MIT license

1MB
3K SLoC

lip logo

Lip

Lip provides powerful parser combinators for creating reusable and flexible parsers.

Why Lip?

  • Easy to understand - uses intuitive combinators like keep and skip
  • Compact - takes less than an hour to learn this library fully
  • Flexible and composable parser combinators
  • Efficient - minimal backtracking
  • Built-in support for precise, located error messages
  • Keep track of extra states like line number and instruction index
  • Extensible - create your own combinators if needed
// Parse an (x, y) position pair
use lip::*;
let position = succeed!(|x, y| (x, y))
  .keep(int())
  .skip(token(","))
  .keep(int())
  .run("2,3", ()); // run this parser on string "2,3" without extra states
// when parsing finished, position == (2, 3)

Tutorial

Reading the parser combinator by Bodil is an excellent way to know how parser combinators work.

License

MIT

Credits

Based on Bodil's Parser Combinator Tutorial and Evan's elm/paser.

Dependencies

Ha