throw new IllegalStateException();
}
Matcher replacementMatcher = REPLACEMENT_PATTERN.matcher(textileMarkup);
int lastOffset = 0;
ReplacementTokenProcessor replacementTokenProcessor = null;
final int textileMarkupLength = textileMarkup.length();
for (;;) {
if (dialect != null && (replacementTokenProcessor == null || replacementTokenProcessor.getLineStartOffset() < lastOffset)) {
replacementTokenProcessor = dialect.findReplacementToken(textileMarkup, lastOffset);
}
if (lastOffset > 0 && dialect != null) {
replacementMatcher.region(lastOffset, textileMarkupLength);
}
int offset = -1;
if (replacementMatcher.find()) {
offset = replacementMatcher.start();
}
if (replacementTokenProcessor != null) {
if (offset == -1 || replacementTokenProcessor.getLineStartOffset() < offset) {
offset = replacementTokenProcessor.getLineStartOffset();
if (lastOffset < offset) {
String t = textileMarkup.substring(lastOffset,offset);
builder.characters(t);
}
replacementTokenProcessor.setParser(this);
replacementTokenProcessor.setParserServices(services);
replacementTokenProcessor.setBuilder(builder);
replacementTokenProcessor.setTextile(state.textile);
replacementTokenProcessor.emitTokenContent();
lastOffset = replacementTokenProcessor.getLineEndOffset();
continue;
}
}
if (offset == -1) {
break;