A refined, expressive parser combinator library. Try it out!
- 📍 Minimal yet powerful APIs
- 🖨 Supports scannerless parsing and tokens parsing
- ⚙ Supports conditional control by state
- ✨ Zero dependency
The Terrario is inspired by PEG.js, Parsimmon, etc.
npm i terrario
See Website
import * as T from 'terrario';
// build a parser
const parser = T.alt([
T.token('hello'),
T.token('world'),
T.token(' '),
]).many();
// parse the input string
const input = 'hello world';
const result = parser.parse(input);
console.log(result);
// => { success: true, value: [ 'hello', ' ', 'world' ], index: 11 }
MIT License