Module: ParseErrorHandler

Defined in:
lib/dbc/parseerrorhandler.rb

Overview

Copyright © 2004 Charles M Mills This document is licenced under The MIT Licence. THIS SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND. See included LICENCE file.

Instance Method Summary collapse

Instance Method Details

#on_error(error_token_id, error_value, value_stack) ⇒ Object

Raises:

  • (ParseError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dbc/parseerrorhandler.rb', line 7

def on_error(error_token_id, error_value, value_stack)
	token_name = token_to_str(error_token_id)
	token_name.downcase!
	token = error_value.to_s.inspect

	str = 'parse error '
	#if value_stack.length > 0
	#	str << "after '#{value_stack.join(' ')}' "
	#end
	str << 'on '
	str << token_name << ' ' unless token_name == token
	str << token
	raise ParseError, str
end