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)
-
- (Symbol) id_to_terminal(id)
Returns the Symbol of the terminal index.
-
- (Symbol) id_to_type(id)
Returns the Symbol that belongs to the stack type number.
-
- (Object) parser_error(stack_type, stack_value, token_type, token_value)
-
- (String) parser_error_message(stack_type, stack_value, token_type)
Instance Method Details
- (Symbol) id_to_terminal(id)
Returns the Symbol of the terminal index.
63 64 65 |
# File 'lib/ll/driver.rb', line 63 def id_to_terminal(id) return self.class::CONFIG.terminals[id] end |
- (Symbol) id_to_type(id)
Returns the Symbol that belongs to the stack type number.
53 54 55 |
# File 'lib/ll/driver.rb', line 53 def id_to_type(id) return ConfigurationCompiler::TYPES.invert[id] end |
- (Object) parser_error(stack_type, stack_value, token_type, token_value)
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 |
- (String) parser_error_message(stack_type, stack_value, token_type)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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" when :star = %Q{Unexpected #{token_type} for a "*" operator} when :plus = %Q{Unexpected #{token_type} for a "+" operator} when :question = %Q{Unexpected #{token_type} for a "?" operator} end return end |