Git Product home page Git Product logo

pest's Introduction

# pest. Elegant, efficient grammars

Join the chat at https://gitter.im/dragostis/pest [Build Status] (https://travis-ci.org/dragostis/pest) [![Coverage Status] (https://coveralls.io/repos/github/dragostis/pest/badge.svg?branch=master)] (https://coveralls.io/github/dragostis/pest?branch=master) [Cargo Crate] (https://crates.io/crates/pest)

pest is a PEG parser generator with simplicity and speed in mind.

Documentation

Elegant

pest uses PEG syntax to enable expressive grammar creation.

impl_rdp! {
    grammar! {
      expression = _{ paren ~ expression? }
      paren      =  { ["("] ~ expression? ~ [")"] }
    }
}

let mut parser = Rdp::new(StringInput::new("(()((())())()")));

assert!(parser.expression());
assert!(parser.end());

Fast

pest generates a fast parser at compile time through the use of macros, without forcing you to use nightly. Yes, it works on stable (1.9.0+).

Parser generator Time to parse 272.5 KB of JSON pest speedup
ANTRL 4 153,000 μs (+/- 15,000) 48.12x
Bison + Flex 8,761.9 μs (+/- 697) 2.76x
pest 3,178.9 μs (+/- 40.6) 1.00x

Tests have been run on an Intel Q8200, 4GB DDR2, Linux 4.6.2 as follows:

Features

  • simple PEG grammar
  • smart error reporting with atomic and silent rules
  • precedence climbing rule
  • no generation step (one-step compilation)
  • fast macro-generated recursive descent parser
  • runs on stable Rust
  • elegant functional-style Token processing

Comparison

Short comparison with other parsing tools. Please take into consideration that pest is the youngest among them, but is continuously improving.

nom LALRPOP pest
type combinator generator generator (macros)
goals speed, extensibility usability simplicity, speed
grammar specialized LR(1) / LALR(1) PEG
steps 1 2 1
code separate / mixed mixed separate
extensibility great great little
great for binary formats any text languages
error reporting yes yes yes
GitHub additions ~10K ~500K ~6K

Roadmap

pest's People

Contributors

alexandrusebastian avatar dragostis avatar gitter-badger avatar steffengy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.