abstract sclass CharacterClassIterator { // move method (go to next character) // callee can assume that c is compatible with canAcceptChar // return value can be this or follow-up iterator, but not null. // Caller must, after this call, use the return value instead of the old iterator. abstract CharacterClassIterator acceptChar(char c); // query methods about next character abstract bool canEndHere(); bool canAcceptChar(char c) { ret contains(acceptedChars(), c); } // can be null abstract Collection acceptedChars(); // This character range must contain all the characters that // are accepted by canAcceptChar at the current position. // character range should be interpreted in a way compatible with an agreed-on char comparator. // Method can return null if no chars are accepted at this position. abstract CharRange acceptedCharRange(); // clone this iterator - may return same object if iterator is immutable abstract CharacterClassIterator cloneCCI(); }