ooflorent / parsly

An opinionated JavaScript port of Parslet.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

About

An opinionated JavaScript port of Parslet.

License:MIT License


Languages

Language:JavaScript 100.0%