All Projects → zesterer → Parze

zesterer / Parze

Licence: other
A clean, efficient parser combinator

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Parze

Swiftparsec
A parser combinator library written in the Swift programming language.
Stars: ✭ 192 (+69.91%)
Mutual labels:  parser-combinators, parser
Arcsecond
✨Zero Dependency Parser Combinator Library for JS Based on Haskell's Parsec
Stars: ✭ 317 (+180.53%)
Mutual labels:  parser-combinators, parser
Goparsec
Parser combinator in Go. If there are any cross platform issues or backward compatibility issues, please reach out.
Stars: ✭ 198 (+75.22%)
Mutual labels:  parser-combinators, parser
Parjs
JavaScript parser-combinator library
Stars: ✭ 145 (+28.32%)
Mutual labels:  parser-combinators, parser
Cppcmb
A generic C++17 parser-combinator library with a natural grammar notation.
Stars: ✭ 108 (-4.42%)
Mutual labels:  parser-combinators, parser
Baby
Create models from a JSON file, even a Baby can do it.
Stars: ✭ 214 (+89.38%)
Mutual labels:  parser-combinators, parser
Parsica
Parsica - PHP Parser Combinators - The easiest way to build robust parsers.
Stars: ✭ 223 (+97.35%)
Mutual labels:  parser-combinators, parser
Dev Blog
翻译、开发心得或学习笔记
Stars: ✭ 3,929 (+3376.99%)
Mutual labels:  parser-combinators, parser
Chthollylang
A simple implementation of Yet another script language Chtholly
Stars: ✭ 19 (-83.19%)
Mutual labels:  parser-combinators, parser
Nom
Rust parser combinator framework
Stars: ✭ 5,987 (+5198.23%)
Mutual labels:  parser-combinators, parser
Parsley
An exceptionally fast parser combinator library for Scala
Stars: ✭ 31 (-72.57%)
Mutual labels:  parser-combinators, parser
Combine
A parser combinator library for Rust
Stars: ✭ 906 (+701.77%)
Mutual labels:  parser-combinators, parser
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (-36.28%)
Mutual labels:  parser-combinators, parser
Pynlp
A pythonic wrapper for Stanford CoreNLP.
Stars: ✭ 103 (-8.85%)
Mutual labels:  parser
Forge
Functional style JSON parsing in Kotlin
Stars: ✭ 106 (-6.19%)
Mutual labels:  parser
Nodable
a node-able bidirectionnal expression editor.
Stars: ✭ 103 (-8.85%)
Mutual labels:  parser
Yamldotnet
YamlDotNet is a .NET library for YAML
Stars: ✭ 1,382 (+1123.01%)
Mutual labels:  parser
Sywac
🚫 🐭 Asynchronous, single package CLI framework for Node
Stars: ✭ 109 (-3.54%)
Mutual labels:  parser
Rdflib
RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
Stars: ✭ 1,584 (+1301.77%)
Mutual labels:  parser
D Yaml
YAML parser and emitter for the D programming language
Stars: ✭ 101 (-10.62%)
Mutual labels:  parser

crates.io crates.io

Parze

Parze is a clean, efficient parser combinator written in Rust.

Example

A parser capable of parsing all valid Brainfuck code into an AST.

use parze::prelude::*;

#[derive(Clone, Debug, PartialEq)]
enum Instr { Add, Sub, Left, Right, In, Out, Loop(Vec<Instr>) }

parsers! {
    bf = {
        ( '+' -> { Instr::Add }
        | '-' -> { Instr::Sub }
        | '<' -> { Instr::Left }
        | '>' -> { Instr::Right }
        | ',' -> { Instr::In }
        | '.' -> { Instr::Out }
        | '[' -& bf &- ']' => { |i| Instr::Loop(i) }
        ) *
    }
}

Features

  • [x] All the usual parser combinator operations
  • [x] Macro for simple rule and parser declaration
  • [x] Support for recursive parser definitions
  • [x] Custom error types - define your own!
  • [x] Prioritised / merged failure for more useful errors
  • [x] No dependencies - fast compilation!
  • [x] no_std support

Why Parze?

Parze is fast and lightweight, acting as a bare-bones framework upon which more verbose and interesting parsers can be constructed (see the custom_error example).

Nightly

Parze's declaration macro currently requires a nightly Rust compiler to work. You may use the explicit declaration form (as shown below) with stable by disabling the nightly feature, however.

This can be done like so in your Cargo.toml:

[dependencies.parze]
version = "x.y.z"
default-features = false

Performance

Here are the results of a JSON parsing test when compared with pom. More performance metrics to come later.

test parze ... bench:   3,696,323 ns/iter (+/- 358,597)
test pom   ... bench:  18,538,775 ns/iter (+/- 1,149,589)

Explicit Form

While Parze encourages use of macros for much of its declarative notation, it is possible (and often useful) to make use of the more explicit rust-y notation.

Here is the Brainfuck parser given above, declared in explicit form.

let bf: Parser<_, _> = recursive(|bf| (
        sym('+').to(Instr::Add)
    .or(sym('-').to(Instr::Sub))
    .or(sym('<').to(Instr::Left))
    .or(sym('>').to(Instr::Right))
    .or(sym(',').to(Instr::In))
    .or(sym('.').to(Instr::Out))
    .or(sym('[').delimiter_for(bf).delimited_by(sym(']')).map(|i| Instr::Loop(i)))
).repeat(..));

License

Parze is distributed under either of:

at the discretion of the user.

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].