Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://kschiess.github.io/parslet/
A small PEG based parser library. See the Hacking page in the Wiki as well.
https://kschiess.github.io/parslet/
Last synced: 2 months ago
JSON representation
A small PEG based parser library. See the Hacking page in the Wiki as well.
- Host: GitHub
- URL: https://kschiess.github.io/parslet/
- Owner: kschiess
- License: mit
- Created: 2010-03-15T08:14:24.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T10:10:59.000Z (over 1 year ago)
- Last Synced: 2024-10-29T12:58:33.247Z (2 months ago)
- Language: Ruby
- Homepage: kschiess.github.com/parslet
- Size: 2.47 MB
- Stars: 807
- Watchers: 16
- Forks: 95
- Open Issues: 19
-
Metadata Files:
- Readme: README
- Changelog: HISTORY.txt
- License: LICENSE
Awesome Lists containing this project
- awesome-ruby - Parslet - A small Ruby library for constructing parsers in the PEG (Parsing Expression Grammar) fashion. (Natural Language Processing)
README
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 debugParslet 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 >> quotesimple_string.
parse('"Simple Simple Simple"') # => "\"Simple Simple Simple\""@0# or by making a fuss about it
class Smalltalk < Parslet::Parser
root :smalltalkrule(: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 hackableCOMPATIBILITY
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