Skip to content
Browse files

- remove UnconsumedInput exception

That's now a parser error just like others are.
  • Loading branch information...
1 parent 086adac commit 92c5ee04a033496cda919893aaa833693736062a @kschiess committed Sep 17, 2012
Showing with 4 additions and 19 deletions.
  1. +3 −0 HISTORY.txt
  2. +0 −16 lib/parslet.rb
  3. +0 −2 lib/parslet/convenience.rb
  4. +1 −1 spec/acceptance/regression_spec.rb
View
3 HISTORY.txt
@@ -10,6 +10,9 @@
of the parse. More information in the resulting exception ensues! Thanks
again to John Mettraux for inspiration & acceptance specs.
+ NOTE that this means that the UnconsumedInput exception is gone, since the
+ unconsumed input case is nothing special anymore.
+
* This history now finally reads like the Changelog of the linux kernel.
Meaning that probably no one ever reads this.
View
16 lib/parslet.rb
@@ -83,22 +83,6 @@ def initialize(message, cause=nil)
attr_reader :cause
end
- # Raised when the parse operation didn't consume all of its input. In this
- # case, it makes only limited sense to look at the error tree. Maybe the
- # parser worked just fine, but didn't account for the characters at the tail
- # of the input?
- #
- # str('foo').parse('foobar')
- # # raises Parslet::UnconsumedInput:
- # # Don't know what to do with "bar" at line 1 char 4.
- #
- # Note that you can have parslet ignore this error:
- #
- # str('foo').parse('foobar', prefix: true) # => "foo"@0
- #
- class UnconsumedInput < ParseFailed
- end
-
module ClassMethods
# Define an entity for the parser. This generates a method of the same
# name that can be used as part of other patterns. Those methods can be
View
2 lib/parslet/convenience.rb
@@ -26,8 +26,6 @@ class Parslet::Atoms::Base
#
def parse_with_debug str, opts={}
parse str, opts
- rescue Parslet::UnconsumedInput => error
- puts error
rescue Parslet::ParseFailed => error
puts error.cause.ascii_tree
end
View
2 spec/acceptance/regression_spec.rb
@@ -212,7 +212,7 @@ def di(s)
s.strip.to_s.lines.map { |l| l.chomp.strip }.join("\n")
end
- it "should raise UnconsumedInput" do
+ it "should raise an error" do
error = catch_failed_parse {
subject.parse('123') }
di(error.ascii_tree).should == di(%q(

0 comments on commit 92c5ee0

Please sign in to comment.
Something went wrong with that request. Please try again.