Skip to content

terrario-js/terrario

Repository files navigation

Terrario

Test License: MIT

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.

Installation

npm i terrario

Documentation

See Website

Basic Example

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 }

Examples

License

MIT License