__
/\ \__
\ \ ,_\ __ _ __ ____ __ ___
\ \ \/ /'__`\ /\`'__\/',__\ /'__`\ /'___\
\ \ \_/\ \L\.\_\ \ \//\__, `\/\ __//\ \__/
\ \__\ \__/.\_\\ \_\\/\____/\ \____\ \____\
\/__/\/__/\/_/ \/_/ \/___/ \/____/\/____/
A parser combinator library for TypeScript, inspired by Parsec.
npm install tarsec
import { str, seqR, space } from "tarsec";
// define a parser
const parser = seqR(
str("hello"),
space,
str("world")
);
// then use it
parser("hello world"); // success
parser("hello there"); // failure
- tarsec is entirely TypeScript. There's nothing to compile.
- Derived types: tarsec will generate TypeScript types for your parser
- Debug mode that prints what's happening step-by-step
- Tools to debug your parser's performance
- Partial backtracking support
- A way to make your parser more secure.
Read more about use cases for tarsec.
PRs for documentation, tests, and bug fixes are welcome.