Class: LL::Driver
- Inherits:
-
Object
- Object
- LL::Driver
- Defined in:
- lib/ll/driver.rb
Overview
Parser driver for generated parsers.
Direct Known Subclasses
Instance Method Summary collapse
-
#id_to_terminal(id) ⇒ Symbol
Returns the Symbol of the terminal index.
-
#id_to_type(id) ⇒ Symbol
Returns the Symbol that belongs to the stack type number.
- #parser_error(stack_type, stack_value, token_type, token_value) ⇒ Object
- #parser_error_message(stack_type, stack_value, token_type) ⇒ String
Instance Method Details
#id_to_terminal(id) ⇒ Symbol
Returns the Symbol of the terminal index.
57 58 59 |
# File 'lib/ll/driver.rb', line 57 def id_to_terminal(id) return self.class::CONFIG.terminals[id] end |
#id_to_type(id) ⇒ Symbol
Returns the Symbol that belongs to the stack type number.
47 48 49 |
# File 'lib/ll/driver.rb', line 47 def id_to_type(id) return ConfigurationCompiler::TYPES.invert[id] end |
#parser_error(stack_type, stack_value, token_type, token_value) ⇒ Object
12 13 14 15 16 |
# File 'lib/ll/driver.rb', line 12 def parser_error(stack_type, stack_value, token_type, token_value) = (stack_type, stack_value, token_type) raise ParserError, end |
#parser_error_message(stack_type, stack_value, token_type) ⇒ String
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ll/driver.rb', line 24 def (stack_type, stack_value, token_type) case id_to_type(stack_type) when :rule = "Unexpected #{token_type} for rule #{stack_value}" when :terminal expected = id_to_terminal(stack_value) = "Unexpected #{token_type}, expected #{expected} instead" when :eof = "Received #{token_type} but there's nothing left to parse" end return end |