Exception: Trenni::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/trenni/scanner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, scanner, positions = nil) ⇒ ParseError

Returns a new instance of ParseError.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/trenni/scanner.rb', line 27

def initialize(message, scanner, positions = nil)
	super(message)
	
	@path = scanner.path
	
	@locations = []
	
	if positions
		positions.each do |position|
			@locations << Location.new(scanner.string, position)
		end
	else
		@locations = [Location.new(scanner.string, scanner.pos)]
	end
	
	@location = @locations.first
	
	@input_name = nil
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



48
49
50
# File 'lib/trenni/scanner.rb', line 48

def location
  @location
end

#locationsObject (readonly)

Returns the value of attribute locations.



47
48
49
# File 'lib/trenni/scanner.rb', line 47

def locations
  @locations
end

#pathObject (readonly)

Returns the value of attribute path.



50
51
52
# File 'lib/trenni/scanner.rb', line 50

def path
  @path
end

Instance Method Details

#to_sObject



52
53
54
# File 'lib/trenni/scanner.rb', line 52

def to_s
	"#{@path}#{@location}: #{super}\n#{location.line_text}"
end