Exception: Language::Parser::Interuption

Inherits:
StandardError
  • Object
show all
Defined in:
lib/language/parser/interuption.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser, atom = Atom.new) ⇒ Interuption

Returns a new instance of Interuption.



6
7
8
9
# File 'lib/language/parser/interuption.rb', line 6

def initialize(parser, atom = Atom.new)
  @parser = parser
  @atom = atom
end

Instance Method Details

#column_indexObject



25
26
27
# File 'lib/language/parser/interuption.rb', line 25

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

#lineObject



15
16
17
18
19
# File 'lib/language/parser/interuption.rb', line 15

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

#line_indexObject



21
22
23
# File 'lib/language/parser/interuption.rb', line 21

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

#messageObject



11
12
13
# File 'lib/language/parser/interuption.rb', line 11

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