# File lib/parslet/atoms/base.rb, line 45 def parse_traditional(io) source = Parslet::Source.new(io) context = Parslet::Atoms::Context.new result = nil value = apply(source, context) # If we didn't succeed the parse, raise an exception for the user. # Stack trace will be off, but the error tree should explain the reason # it failed. if value.error? @last_cause = value.message @last_cause.raise end # assert: value is a success answer # If we haven't consumed the input, then the pattern doesn't match. Try # to provide a good error message (even asking down below) unless source.eof? # Do we know why we stopped matching input? If yes, that's a good # error to fail with. Otherwise just report that we cannot consume the # input. if cause # NOTE We don't overwrite last_cause here. raise Parslet::UnconsumedInput, "Unconsumed input, maybe because of this: #{cause}" else old_pos = source.pos @last_cause = source.error( "Don't know what to do with #{source.read(100)}", old_pos) @last_cause.raise(Parslet::UnconsumedInput) end end return flatten(value.result) end