Sha256: 44bef0dfacc5ce961686b093c22d5fdb50e78f697bc54b876ff8340d7f444ca0

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

module Treetop
  module Runtime
    class CompiledParser
      def failure_message color
        o = color ? Mutter.new.clear : lambda {|i, *args| i }
        return nil unless (tf = terminal_failures) && tf.size > 0
        msg = "on line #{failure_line}: expected " + (
          tf.size == 1 ? 
            o[tf[0].expected_string, :yellow] : 
            "one of #{o[tf.map {|f| f.expected_string }.uniq * ' ', :yellow]}"
        )
        f = input[failure_index]
        got = case f
          when "\n" then o['\n',  :cyan]
          when nil  then o["EOF", :cyan]
          when ' '  then o["white-space", :cyan]
          else           o[f.chr, :yellow]
        end
        msg += " got #{got} after:\n\n#{input[index...failure_index]}\n"
      end
    end
  end
end

unless :symbol.respond_to?(:to_proc)
  class Symbol
    def to_proc
      Proc.new {|*args| args.shift.__send__(self, *args) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unboxed-less-1.2.12 lib/ext.rb