ParserLang
ParserLang is parser combinator library. It lets you make parsers by combining other parsers.
Its primary superpower is the ability to define parsers declaratively with template literals:
; let calc = lang` num = /[0-9]+/ > ; addExpr = num '+' multExpr > | num ; multExpr = addExpr '*' multExpr > | addExpr ; calc = multExpr ;`; calc;// 3
It's monadic and stuff but don't get too hung up on that. It tries to be very friendly.
Installing
npm install parser-lang
Documentation
Related Projects/Papers
- Parsimmon - a JavaScript parser combinator library. ParserLang is heavily inspired by Parsimmon. Parsimmon is more coupled to parsing strings (ParserLang uses the Context protocol to support a variety of input types) but also supports a wider variety of JavaScript runtimes.
- Parsec - a Haskell parser combinator library
- Monadic Parser Combinators - one of the seminal papers describing parser combinators