Sha256: 22f4a47f16fb4f11419c14b707da2343f955f55f4b883aae1e7ea7e75575cb9e

Contents?: true

Size: 646 Bytes

Versions: 21

Compression:

Stored size: 646 Bytes

Contents

class Language
  class Parser
    class Interuption < StandardError
      def initialize(parser, atom = Atom.new)
        @parser = parser
        @atom = atom
      end

      def message
        "\n#{line}#{" " * column_index}^\n"
      end

      def line
        l = input.lines[line_index]
        l += "\n" if l[-1] != "\n"
        l
      end

      def line_index
        input[...cursor].count("\n")
      end

      def column_index
        cursor - input.lines[...line_index].map(&:size).sum
      end

      private

      def cursor
        @parser.cursor
      end

      def input
        @parser.input
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
template-ruby-0.5.6 lib/language/parser/interuption.rb
language-ruby-0.5.6 lib/language/parser/interuption.rb
code-ruby-0.5.6 lib/language/parser/interuption.rb
template-ruby-0.5.5 lib/language/parser/interuption.rb
language-ruby-0.5.5 lib/language/parser/interuption.rb
code-ruby-0.5.5 lib/language/parser/interuption.rb
template-ruby-0.5.4 lib/language/parser/interuption.rb
language-ruby-0.5.4 lib/language/parser/interuption.rb
code-ruby-0.5.4 lib/language/parser/interuption.rb
template-ruby-0.5.3 lib/language/parser/interuption.rb
language-ruby-0.5.3 lib/language/parser/interuption.rb
code-ruby-0.5.3 lib/language/parser/interuption.rb
template-ruby-0.5.2 lib/language/parser/interuption.rb
language-ruby-0.5.2 lib/language/parser/interuption.rb
code-ruby-0.5.2 lib/language/parser/interuption.rb
language-ruby-0.5.1 lib/language/parser/interuption.rb
template-ruby-0.5.1 lib/language/parser/interuption.rb
code-ruby-0.5.1 lib/language/parser/interuption.rb
template-ruby-0.5.0 lib/language/parser/interuption.rb
language-ruby-0.5.0 lib/language/parser/interuption.rb