parsly

3.0.0 • Public • Published

Parsly

A small PEG based parser library.
An opinionated JavaScript port of Parslet.

NPM version Build Status

Install

npm install --save parsly

Usage

// There is 2 ways to access Parsly APIs.
 
// Parser API:
import {Parser} from 'parsly'
import {alt, seq, match, str, any, custom, lazy} from 'parsly/parser'
 
// Transform API:
import {Transformer} from 'parsly'
import Transformer, {simple, sequence, subtree} from 'parsly/transformer'

Parser API

Atoms

  • alt(...parsers)
  • seq(...parsers)
  • match(expr)
  • str(string)
  • any()
  • custom(fn)
  • lazy(fn)

Chain

  • as(name)
  • maybe()
  • many()
  • times(n)
  • repeat(min, max)

Transform API

  • Transform
  • Node
  • simple(node)
  • sequence(node)
  • subtree(node)

Transform class

  • Transform(rules)
  • Transform#rule(matchFn, transformFn)
  • Transform#run(ast, context)

Readme

Keywords

Package Sidebar

Install

npm i parsly

Weekly Downloads

0

Version

3.0.0

License

MIT

Last publish

Collaborators

  • ooflorent