Coder Social home page Coder Social logo

stormbrew / parslet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kschiess/parslet

1.0 2.0 0.0 1.56 MB

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

Home Page: kschiess.github.com/parslet

License: MIT License

Ruby 100.00%

parslet's Introduction

INTRODUCTION

Parslet makes developing complex parsers easy. It does so by

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

Parslet takes the long way around to make <b>your job</b> 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:
http://kschiess.github.com/parslet

SYNOPSIS

  require 'parslet'
  include Parslet

  # Constructs a parser using a Parser Expression Grammar like DSL: 
  parser =  str('"') >> 
            (
              str('\\') >> any |
              str('"').absnt? >> any
            ).repeat.as(:string) >> 
            str('"')
  
  # Parse the string and capture parts of the interpretation (:string above)        
  tree = parser.parse('"This is a \\"String\\" in which you can escape stuff"')

  tree # => {:string=>"This is a \\\"String\\\" in which you can escape stuff"}

  # Here's how you can grab results from that tree:

  transform = Parslet::Transform.new do
    rule(:string => simple(:x)) { 
      puts "String contents: #{x}" }
  end
  transform.apply(tree)

COMPATIBILITY

This library should work with most rubies. I've tested it with MRI 1.8, 1.9, 
rbx-head, jruby. Please report as a bug if you encounter issues.

STATUS 

At version 1.1 - Good basic functionality and lots of plans for extension.

(c) 2010 Kaspar Schiess

parslet's People

Contributors

floere avatar kschiess avatar rkh avatar

Stargazers

 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.