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); }
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; }