All Projects → susisu → loquat

susisu / loquat

Licence: Apache-2.0 license
Monadic parser combinators for JavaScript / TypeScript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to loquat

Parser Combinators From Scratch
Code that accompanies the series
Stars: ✭ 56 (+19.15%)
Mutual labels:  parsing, parser-combinators
Combine
A parser combinator library for Elixir projects
Stars: ✭ 174 (+270.21%)
Mutual labels:  parsing, parser-combinators
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (+53.19%)
Mutual labels:  parsing, parser-combinators
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (+1840.43%)
Mutual labels:  parsing, parser-combinators
metal
A Java library for parsing binary data formats, using declarative descriptions.
Stars: ✭ 13 (-72.34%)
Mutual labels:  parsing, parser-combinators
Lug
Parsing expression grammar (PEG) embedded domain specific language and parsing machine for C++17
Stars: ✭ 44 (-6.38%)
Mutual labels:  parsing, parser-combinators
Parjs
JavaScript parser-combinator library
Stars: ✭ 145 (+208.51%)
Mutual labels:  parsing, parser-combinators
Pom
PEG parser combinators using operator overloading without macros.
Stars: ✭ 310 (+559.57%)
Mutual labels:  parsing, parser-combinators
Syntax
Write value-driven parsers quickly in Swift with an intuitive SwiftUI-like DSL
Stars: ✭ 134 (+185.11%)
Mutual labels:  parsing, parser-combinators
autumn
A Java parser combinator library written with an unmatched feature set.
Stars: ✭ 112 (+138.3%)
Mutual labels:  parsing, parser-combinators
Scala Parser Combinators
simple combinator-based parsing for Scala. formerly part of the Scala standard library, now a separate community-maintained module
Stars: ✭ 523 (+1012.77%)
Mutual labels:  parsing, parser-combinators
Ramble
A R parser based on combinatory parsers.
Stars: ✭ 19 (-59.57%)
Mutual labels:  parsing, parser-combinators
Pidgin
C#'s fastest parser combinator library
Stars: ✭ 469 (+897.87%)
Mutual labels:  parsing, parser-combinators
Pyparsing
Python library for creating PEG parsers
Stars: ✭ 1,052 (+2138.3%)
Mutual labels:  parsing, parser-combinators
Angstrom
Parser combinators built for speed and memory efficiency
Stars: ✭ 434 (+823.4%)
Mutual labels:  parsing, parser-combinators
Pegtl
Parsing Expression Grammar Template Library
Stars: ✭ 1,295 (+2655.32%)
Mutual labels:  parsing, parser-combinators
parser-combinators
Lightweight package providing commonly useful parser combinators
Stars: ✭ 41 (-12.77%)
Mutual labels:  parsing, parser-combinators
Funcparserlib
Recursive descent parsing library for Python based on functional combinators
Stars: ✭ 250 (+431.91%)
Mutual labels:  parsing, parser-combinators
ParsecSharp
The faster monadic parser combinator library for C#
Stars: ✭ 23 (-51.06%)
Mutual labels:  parsing, parser-combinators
parser-lang
A parser combinator library with declarative superpowers
Stars: ✭ 25 (-46.81%)
Mutual labels:  parsing, parser-combinators

loquat

CI

Monadic parser combinators for JavScript, inspired by Parsec.

import * as lq from "@loquat/simple";

const nat = lq.digit.manyChars1().map(str => parseInt(str, 10));
const op = lq.choice([
  lq.char("+").return((a, b) => a + b),
  lq.char("-").return((a, b) => a - b),
]);
const expr =
  nat.bind(a =>
    op.bind(f =>
      nat.map(b =>
        f(a, b)
      )
    )
  );

const res = expr.parse("", "14+28"); // { success: true, value: 42 }

Packages

If you are not familiar with loquat, or you are using TypeScript, @loquat/simple is recommended.

For a more flexible and extensible framework, use @loquat/framework.

The core features and extensions are provided as separate packages.

For extension development, a chai plugin and some test helpers are available.

License

Copyright 2019 Susisu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].