public SymbolMatch findMatch(Character startCharacter, SymbolMatcher matcher) { if (parent != null) { SymbolMatch parentMatch = parent.findMatch(startCharacter, matcher); if (parentMatch.isMatch()) return parentMatch; } for (Matchable candidate: getMatchTypes(startCharacter)) { SymbolMatch match = matcher.makeMatch(candidate); if (match.isMatch()) return match; } return SymbolMatch.noMatch; } }
public SymbolMatch findMatch(Character startCharacter, SymbolMatcher matcher) { if (parent != null) { SymbolMatch parentMatch = parent.findMatch(startCharacter, matcher); if (parentMatch.isMatch()) return parentMatch; } for (Matchable candidate: getMatchTypes(startCharacter)) { SymbolMatch match = matcher.makeMatch(candidate); if (match.isMatch()) return match; } return SymbolMatch.noMatch; } }
@Override public SymbolMatch makeMatch(Matchable candidate) { if (input.getOffset() != startPosition || !ignores(candidate)) { SymbolMatch match = candidate.makeMatch(input, symbols); if (match.isMatch()) return match; } return SymbolMatch.noMatch; } });
@Override public SymbolMatch makeMatch(Matchable candidate) { if (input.getOffset() != startPosition || !ignores(candidate)) { SymbolMatch match = candidate.makeMatch(input, symbols); if (match.isMatch()) return match; } return SymbolMatch.noMatch; } });
public Symbol makeLiteral(SymbolType terminator) { input.setOffset(next); while (!input.isEnd()) { SymbolMatch match = terminator.makeMatch(input, symbols); if (match.isMatch()) { symbols.add(new Symbol(terminator)); Symbol result = new Symbol(SymbolType.Text, input.substringFrom(next), next); next = input.getOffset() + match.getMatchLength(); return result; } input.moveNext(); } Symbol result = new Symbol(SymbolType.Text, input.substringFrom(next), next); next = input.getOffset(); symbols.add(Symbol.emptySymbol); return result; }
public Symbol makeLiteral(SymbolType terminator) { input.setOffset(next); while (!input.isEnd()) { SymbolMatch match = terminator.makeMatch(input, symbols); if (match.isMatch()) { symbols.add(new Symbol(terminator)); Symbol result = new Symbol(SymbolType.Text, input.substringFrom(next), next); next = input.getOffset() + match.getMatchLength(); return result; } input.moveNext(); } Symbol result = new Symbol(SymbolType.Text, input.substringFrom(next), next); next = input.getOffset(); symbols.add(Symbol.emptySymbol); return result; }
private Step makeNextStep(final ParseSpecification specification, final int startPosition) { input.setOffset(startPosition); int newNext = startPosition; Symbol matchSymbol = null; while (!input.isEnd()) { SymbolMatch match = specification.findMatch(input, startPosition, symbols); if (match.isMatch()) { matchSymbol = match.getSymbol(); newNext = input.getOffset() + match.getMatchLength(); break; } input.moveNext(); } if (input.getOffset() > startPosition) { SymbolMatch match = textMaker.make(specification, startPosition, input.substringFrom(startPosition)); return new Step(match.getSymbol(), startPosition + match.getMatchLength()); } if (input.isEnd()) { return new Step(Symbol.emptySymbol, input.getOffset()); } return new Step(matchSymbol, newNext); }
private Step makeNextStep(final ParseSpecification specification, final int startPosition) { input.setOffset(startPosition); int newNext = startPosition; Symbol matchSymbol = null; while (!input.isEnd()) { SymbolMatch match = specification.findMatch(input, startPosition, symbols); if (match.isMatch()) { matchSymbol = match.getSymbol(); newNext = input.getOffset() + match.getMatchLength(); break; } input.moveNext(); } if (input.getOffset() > startPosition) { SymbolMatch match = textMaker.make(specification, startPosition, input.substringFrom(startPosition)); return new Step(match.getSymbol(), startPosition + match.getMatchLength()); } if (input.isEnd()) { return new Step(Symbol.emptySymbol, input.getOffset()); } return new Step(matchSymbol, newNext); }