Skip to content
Latest commit 07a2834 @kschiess Fixes load path in example
Failed to load latest commit information.
output Parslet accelerators
big.erb Parslet accelerators
boolean_algebra.rb . improves layout to match code guidelines
calc.rb . cleanup
capture.rb Documentation for the scoping
comments.rb + prsnt? -> present?, absnt? -> absent?
deepest_errors.rb + Implementation of a deepest error
documentation.rb + Cleaning up txus patch
email_parser.rb refactored getting input in email parser example
empty.rb + Cleaning up txus patch
erb.rb + prsnt? -> present?, absnt? -> absent?
ignore.rb . refactor: postfix -> consume_all
ip_address.rb + Cleaning up txus patch
json.rb - cleanup: error tree is completely gone
local.rb + prsnt? -> present?, absnt? -> absent?
mathn.rb ! Fixes interaction with mathn
minilisp.rb + prsnt? -> present?, absnt? -> absent?
modularity.rb + A few ways of making parlset parsers modular.
nested_errors.rb + Implementation of a deepest error
optimized_erb.rb Fixes load path in example
parens.rb + Cleaning up txus patch
prec_calc.rb Small bugfixes to infix parser
readme.rb + prsnt? -> present?, absnt? -> absent?
scopes.rb Documentation for the scoping
seasons.rb + Cleaning up txus patch
sentence.rb ! Fixes issue #38: IO is now read using gets(nil, len)
simple.lit ! Fixes the missing recursive flatten
simple_xml.rb + prsnt? -> present?, absnt? -> absent?
string_parser.rb + prsnt? -> present?, absnt? -> absent?
test.lit . Reorg into a real project structure


# The example from the readme. With this, I am making sure that the readme 
# 'works'. Is this too messy?

$:.unshift File.dirname(__FILE__) + "/../lib"

# cut here -------------------------------------------------------------------
require 'parslet'
include Parslet

# Constructs a parser using a Parser Expression Grammar like DSL: 
parser =  str('"') >> 
            str('\\') >> any |
            str('"').absent? >> any
          ) >> 
# 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 = do
  rule(:string => simple(:x)) { 
    puts "String contents: #{x}" }

Something went wrong with that request. Please try again.