Class: Dhaka::ParserRun
- Inherits:
-
Object
- Object
- Dhaka::ParserRun
- Defined in:
- lib/parser/parser_run.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(grammar, start_state, token_stream) ⇒ ParserRun
constructor
A new instance of ParserRun.
- #run ⇒ Object
Constructor Details
#initialize(grammar, start_state, token_stream) ⇒ ParserRun
Returns a new instance of ParserRun.
4 5 6 7 8 9 10 |
# File 'lib/parser/parser_run.rb', line 4 def initialize(grammar, start_state, token_stream) @grammar = grammar @node_stack = [] @state_stack = [start_state] @token_stream = token_stream @symbol_queue = [] end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/parser/parser_run.rb', line 12 def run token_stream.each do |token| @current_token = token @symbol_queue << @current_token.symbol_name error = execute_actions return error if error node_stack << ParseTreeLeafNode.new(@current_token) end ParseSuccessResult.new(node_stack[0]) end |