diff --git a/src/org/nwapw/abacus/lexing/Lexer.java b/src/org/nwapw/abacus/lexing/Lexer.java index 22ed298..94457a1 100644 --- a/src/org/nwapw/abacus/lexing/Lexer.java +++ b/src/org/nwapw/abacus/lexing/Lexer.java @@ -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 { for(Pattern pattern : patterns){ pattern.getHead().addInto(currentSet); } - while(!currentSet.isEmpty() && index < from.length()){ - char currentChar = from.charAt(index); + while(!currentSet.isEmpty()){ for(PatternNode 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) node).getPatternId()));