Exception: PuppetLint::LexerError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/puppet-lint/lexer.rb

Overview

Internal: A generic error thrown by the lexer when it encounters something it can’t handle.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, offset) ⇒ LexerError

Internal: Initialise a new PuppetLint::LexerError object.

code - The String manifest code being tokenised. offset - The Integer position in the code string that the tokeniser was

at when it encountered the error.


21
22
23
24
25
26
27
28
29
30
# File 'lib/puppet-lint/lexer.rb', line 21

def initialize(code, offset)
  chunk = code[0..offset]
  @line_no = chunk.scan(/(\r\n|\r|\n)/).size + 1
  if @line_no == 1
    @column = chunk.length
  else
    @column = chunk.length - chunk.rindex(/(\r\n|\r|\n)/) - 1
  end
  @column = 1 if @column == 0
end

Instance Attribute Details

#columnObject (readonly)

Internal: Get the Integer column number of the location of the error.



14
15
16
# File 'lib/puppet-lint/lexer.rb', line 14

def column
  @column
end

#line_noObject (readonly)

Internal: Get the Integer line number of the location of the error.



11
12
13
# File 'lib/puppet-lint/lexer.rb', line 11

def line_no
  @line_no
end