sclass CCI_Substring extends CharacterClassIterator { S s; int i, l; CharacterClassIterator next; *() {} *(S *s, int start, int end) { i = start; l = end; } // no check because of method contract CharacterClassIterator acceptChar(char c) { ret ++i >= l && next != null ? next : this; } bool canEndHere() { ret i >= l; } bool canAcceptChar(char c) { ret i < l && s.charAt(i) == c; } CharRange acceptedCharRange() { ret i >= l ? null : singletonCharRange(s.charAt(i)); } }