Fix bug causing the last character not to be matched.

This commit is contained in:
Danila Fedorin 2017-07-24 21:00:35 -07:00
parent c86e192d2e
commit 42db6b3c2f
1 changed files with 2 additions and 4 deletions

View File

@ -6,7 +6,6 @@ import org.nwapw.abacus.lexing.pattern.Pattern;
import org.nwapw.abacus.lexing.pattern.PatternNode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@ -31,10 +30,9 @@ public class Lexer<T> {
for(Pattern<T> pattern : patterns){
pattern.getHead().addInto(currentSet);
}
while(!currentSet.isEmpty() && index < from.length()){
char currentChar = from.charAt(index);
while(!currentSet.isEmpty()){
for(PatternNode<T> node : currentSet){
if(node.matches(currentChar)) {
if(index < from.length() && node.matches(from.charAt(index))) {
node.addOutputsInto(futureSet);
} else if(node instanceof EndNode){
matches.add(new Match<>(startAt, index, ((EndNode<T>) node).getPatternId()));