initialState = State.valueOf(String.valueOf(options.get(OPTION_START_STATE)));
}
state.push(initialState);
while (source.hasMore()) {
MatchResult m = null;
if ((m = source.scan(SPACE)) != null) {
encoder.textToken(m.group(), TokenType.space);
}
else if (media_blocks(source, encoder, value_expected, state)) {
}
else if ((m = source.scan(COMMENT)) != null) {
encoder.textToken(m.group(), TokenType.comment);
}
else if ((m = source.scan(BRACKET_OPEN)) != null) {
value_expected = false;
encoder.textToken(m.group(), TokenType.operator);
state.push(State.block);
}
else if ((m = source.scan(BRACKET_CLOSE)) != null) {
value_expected = false;
encoder.textToken(m.group(), TokenType.operator);
if (state.peek() == State.block || state.peek() == State.media) {
state.pop();
}
}
else if ((m = source.scan(STRING)) != null) {
encoder.beginGroup(TokenType.string);
encoder.textToken(m.group().substring(0, 1), TokenType.delimiter);
if (m.group().length() > 2) {
encoder.textToken(m.group().substring(1, m.group().length() - 1), TokenType.content);
}
if (m.group().length() >= 2) {
encoder.textToken(m.group().substring(m.group().length() - 1), TokenType.delimiter);
}
encoder.endGroup(TokenType.string);
}
else if ((m = source.scan(FUNCTION)) != null) {
encoder.beginGroup(TokenType.function);
Matcher functionMatcher = FUNCTION_NAME.matcher(m.group());
functionMatcher.lookingAt();
String start = functionMatcher.group();
encoder.textToken(start, TokenType.delimiter);
if (PARENTHESES_END.matcher(m.group().substring(m.group().length() - 1)).matches()) {
if (m.group().length() > start.length() + 1) {
encoder.textToken(m.group().substring(start.length(), m.group().length() - 1), TokenType.content);
encoder.textToken(")", TokenType.delimiter);
}
}
else if (m.group().length() > start.length()) {
encoder.textToken(m.group().substring(start.length(), m.group().length() - 1), TokenType.content);
}
encoder.endGroup(TokenType.function);
}
else if ((m = source.scan(FLOAT)) != null) {
encoder.textToken(m.group(), TokenType.float_);
}
else if ((m = source.scan(HEX_COLOR)) != null) {
encoder.textToken(m.group(), TokenType.color);
}
else if ((m = source.scan(IMPORTANT)) != null) {
encoder.textToken(m.group(), TokenType.important);
}
else if ((m = source.scan(COLOR)) != null) {
encoder.textToken(m.group(), TokenType.color);
}
else if ((m = source.scan(AT_KEYWORD)) != null) {
encoder.textToken(m.group(), TokenType.directive);
}
else if ((m = source.scan(OPERATOR)) != null) {
if (":".equals(m.group())) {
value_expected = true;
}
else if (";".equals(m.group())) {
value_expected = false;
}
encoder.textToken(m.group(), TokenType.operator);
}
else {
encoder.textToken(source.next(), TokenType.error);
}
}