Socket
Socket
Sign inDemoInstall

parser-lang

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parser-lang

A parser combinator library for JavaScript with declarative superpowers


Version published
Weekly downloads
12
increased by500%
Maintainers
1
Weekly downloads
 
Created
Source

npm version Build Status Contributor Covenant

ParserLang

ParserLang is parser combinator library. It lets you make parsers by combining other parsers.

Its primary superpower is the ability to define parsers declaratively with template literals:

import { lang } from 'parser-lang';

let { calc } = lang`
  num = /[0-9]+/ > ${ch => parseInt(ch, 10)};

  addExpr = num '+' multExpr > ${([left, op, right]) => left + right}
          | num ;

  multExpr = addExpr '*' multExpr > ${([left, op, right]) => left * right}
           | addExpr ;
  
  calc = multExpr ;
`;

calc.tryParse('1+1*2');
// 3

It's monadic and stuff but don't get too hung up on that. It tries to be very friendly.

Installing

npm install parser-lang

Documentation

  • Parsimmon - a JavaScript parser combinator library. ParserLang is heavily inspired by Parsimmon. Parsimmon is more coupled to parsing strings (ParserLang uses the Context protocol to support a variety of input types) but also supports a wider variety of JavaScript runtimes.
  • Parsec - a Haskell parser combinator library
  • Monadic Parser Combinators - one of the seminal papers describing parser combinators

Keywords

FAQs

Package last updated on 29 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc