Exception: Bade::Parser::SyntaxError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, file, line, lineno, column) ⇒ SyntaxError

Returns a new instance of SyntaxError.



11
12
13
14
15
16
17
# File 'lib/bade/parser.rb', line 11

def initialize(error, file, line, lineno, column)
  @error = error
  @file = file || '(__TEMPLATE__)'
  @line = line.to_s
  @lineno = lineno
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



9
10
11
# File 'lib/bade/parser.rb', line 9

def column
  @column
end

#errorObject (readonly)

Returns the value of attribute error.



9
10
11
# File 'lib/bade/parser.rb', line 9

def error
  @error
end

#fileObject (readonly)

Returns the value of attribute file.



9
10
11
# File 'lib/bade/parser.rb', line 9

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



9
10
11
# File 'lib/bade/parser.rb', line 9

def line
  @line
end

#linenoObject (readonly)

Returns the value of attribute lineno.



9
10
11
# File 'lib/bade/parser.rb', line 9

def lineno
  @lineno
end

Instance Method Details

#to_sObject



19
20
21
22
23
24
25
26
27
# File 'lib/bade/parser.rb', line 19

def to_s
  line = @line.lstrip
  column = @column + line.size - @line.size
  %{#{error}
  #{file}, Line #{lineno}, Column #{@column}
  #{line}
  #{' ' * column}^
}
end