@Override
public void scan(StringScanner source, Encoder encoder, Map<String, Object> options) {
State state = State.initial;
String string_delimiter = null;
TokenType package_name_expected = null;
boolean class_name_follows = false;
boolean last_token_dot = false;
while (source.hasMore()) {
MatchResult m = null;
switch (state) {
case initial:
if ((m = source.scan(SPACE)) != null) {
encoder.textToken(m.group(), TokenType.space);
continue;
} else if ((m = source.scan(COMMENT)) != null) {
encoder.textToken(m.group(), TokenType.comment);
continue;
} else if (package_name_expected != null && (m = source.scan(PACKAGE)) != null) {
encoder.textToken(m.group(), package_name_expected);
} else if ((m = source.scan(IDENT_OR_ARRAY_TYPE)) != null) {
String match = m.group();
TokenType kind = IDENT_KIND.lookup(match);
if (last_token_dot) {
kind = TokenType.ident;
} else if (class_name_follows) {
kind = TokenType.class_;
class_name_follows = false;