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 void acceptChar(char c) { ++i; } bool canEndHere() { ret i >= l && next != null && next.canEndHere(); } bool canAcceptChar(char c) { ret i >= l ? next != null && next.canAcceptChar(c) : s.charAt(i) == c; } CharRange acceptedCharRange() { ret i >= l ? next?.acceptedCharRange() : singletonCharRange(s.charAt(i)); } }