From 68d7aa3707f40a8091c3c77de3d9eccf8ed40f09 Mon Sep 17 00:00:00 2001 From: Kaspar Schiess Date: Tue, 22 Feb 2011 07:09:08 +0100 Subject: [PATCH] . readme simplification --- README | 6 ++---- example/readme.rb | 10 ++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README b/README index ca956eb..8d8fac7 100644 --- a/README +++ b/README @@ -27,9 +27,7 @@ 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"} @@ -37,7 +35,7 @@ SYNOPSIS transform = Parslet::Transform.new do rule(:string => simple(:x)) { - puts "String contents (method 2): #{x}" } + puts "String contents: #{x}" } end transform.apply(tree) diff --git a/example/readme.rb b/example/readme.rb index 35741f1..a8be624 100644 --- a/example/readme.rb +++ b/example/readme.rb @@ -3,10 +3,7 @@ $:.unshift '../lib' -require 'pp' -require 'parslet' -include Parslet - +# cut here ------------------------------------------------------------------- require 'parslet' include Parslet @@ -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}" }