lib/rley/parser/earley_parser.rb in rley-0.0.05 vs lib/rley/parser/earley_parser.rb in rley-0.0.06

- old
+ new

@@ -28,20 +28,20 @@ @next_mapping = build_next_mapping(dotted_items) end def parse(aTokenSequence) result = Parsing.new(start_dotted_item, aTokenSequence) - - (0..aTokenSequence.size).each do |i| + last_token_index = aTokenSequence.size + (0..last_token_index).each do |i| result.chart[i].each do |state| if state.complete? # parse reached end of production completion(result, state, i) else next_symbol = state.next_symbol if next_symbol.kind_of?(Syntax::NonTerminal) prediction(result, next_symbol, i) - else + elsif i < last_token_index # Expecting a terminal symbol scanning(result, next_symbol, i) end end end