Skip to content

Commit

Permalink
. readme simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
kschiess committed Feb 22, 2011
1 parent 0438b2e commit 68d7aa3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 2 additions & 4 deletions README
Expand Up @@ -27,17 +27,15 @@ SYNOPSIS
str('"')

# Parse the string and capture parts of the interpretation (:string above)
tree = parser.parse(%Q{
"This is a \\"String\\" in which you can escape stuff"
}.strip)
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 (method 2): #{x}" }
puts "String contents: #{x}" }
end
transform.apply(tree)

Expand Down
10 changes: 2 additions & 8 deletions example/readme.rb
Expand Up @@ -3,10 +3,7 @@

$:.unshift '../lib'

require 'pp'
require 'parslet'
include Parslet

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

Expand All @@ -19,15 +16,12 @@
str('"')

# Parse the string and capture parts of the interpretation (:string above)
tree = parser.parse(%Q{
"This is a \\"String\\" in which you can escape stuff"
}.strip)
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:

# 1)
transform = Parslet::Transform.new do
rule(:string => simple(:x)) {
puts "String contents: #{x}" }
Expand Down

0 comments on commit 68d7aa3

Please sign in to comment.