• Stars
    star
    805
  • Rank 56,629 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 14 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small PEG based parser library. See the Hacking page in the Wiki as well.
INTRODUCTION

Parslet makes developing complex parsers easy. It does so by

* providing the best error reporting possible
* not generating reams of code for you to debug

Parslet takes the long way around to make your job easier. It allows for
incremental language construction. Often, you start out small, implementing
the atoms of your language first; _parslet_ takes pride in making this
possible.

Eager to try this out? Please see the associated web site:
https://kschiess.github.io/parslet/

SYNOPSIS

  require 'parslet'
  include Parslet

  # parslet parses strings
  str('foo').
    parse('foo') # => "foo"@0

  # it matches character sets
  match['abc'].parse('a') # => "a"@0
  match['abc'].parse('b') # => "b"@0
  match['abc'].parse('c') # => "c"@0

  # and it annotates its output
  str('foo').as(:important_bit).
    parse('foo') # => {:important_bit=>"foo"@0}

  # you can construct parsers with just a few lines
  quote = str('"')
  simple_string = quote >> (quote.absent? >> any).repeat >> quote

  simple_string.
    parse('"Simple Simple Simple"') # => "\"Simple Simple Simple\""@0

  # or by making a fuss about it 
  class Smalltalk < Parslet::Parser
    root :smalltalk

    rule(:smalltalk) { statements }
    rule(:statements) { 
      # insert smalltalk parser here (outside of the scope of this readme)
    }
  end

  # and then
  Smalltalk.new.parse('smalltalk')

FEATURES

  * Tools for every part of the parser chain
  * Transformers generate Abstract Syntax Trees
  * Accelerators transform parsers, making them quite a bit faster
  * Pluggable error reporters
  * Graphviz export for your parser
  * Rspec testing support rig
  * Simply Ruby, composable and hackable

COMPATIBILITY

This library is intended to work with Ruby variants >= 1.9. I've tested it on 
MRI 1.9, rbx-head, jruby. Please report as a bug if you encounter issues.

STATUS 

Production worthy.

(c) 2010-today Kaspar Schiess

More Repositories

1

cod

Small framework to simplify process-to-process communication.
Ruby
73
star
2

procrastinate

Framework to run tasks in separate processes.
Ruby
29
star
3

similarity_engine

A small rails plugin to compare ActiveRecord objects and to generate recommendations
Ruby
9
star
4

wt

A small language that serves as a sample to parslet. Compiles simple stuff to postscript.
Ruby
8
star
5

verneuil

Artificial Rubies. Using a fusion process.
Ruby
7
star
6

toylisp

A toy lisp interpreter
6
star
7

thin_ham

A thin slice of haml & sass to allow for fast website prototyping
Ruby
3
star
8

parslet-benchmarks

Benchmarks for parslet.
Ruby
3
star
9

blog.absurd.li

NOT ACTIVE: My very own blag - releases and snippets and programming related stuff
JavaScript
3
star
10

hens_and_eggs

Small projects that document UNIX tricks. Prevents me from searching documentation on those tricks every few years. Reuse is free, but at your own risk.
Ruby
2
star
11

zack

UNMAINTAINED - RPC via beanstalkd in Ruby
Ruby
2
star
12

ndo

Tools to execute on multiple hosts via ssh in parallel.
Ruby
2
star
13

floor_manager

Allows creation of a whole graph of objects on the fly during testing
Ruby
2
star
14

last_puppetrun

A tool to find the last successful puppet run for all your nodes.
Ruby
2
star
15

absurd.li

web business card
Ruby
1
star
16

rspec_toolshack

A small collection of things I am sick of writing again.. and again.. and again.
1
star
17

panzer

A proof of concept frankenhack assembling parslet & cod to form a HTTP (rack) server.
Ruby
1
star
18

wikileak_mirrors

How many wikileaks mirrors are there?
Ruby
1
star
19

loaded_dice

Simulation of a loaded die.
Ruby
1
star