void parse(lString16 basePath, const lString8 & css) { _state = 0; _basePath = basePath; lString8 token; char insideQuotes = 0; for (int i=0; i<css.length(); i++) { char ch = css[i]; if (insideQuotes || _state == 13) { if (ch == insideQuotes || (_state == 13 && ch == ')')) { onQuotedText(token); insideQuotes = 0; if (_state == 13) onToken(ch); } else { if (_state == 13 && token.empty() && (ch == '\'' || ch=='\"')) { insideQuotes = ch; } else if (ch != ' ' || _state != 13) token << ch; } continue; } if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') { onToken(token); } else if (ch == '@' || ch=='-' || ch=='_' || ch=='.' || ch>='a' && ch <='z' || ch>='A' && ch <='Z' || ch>='0' && ch <='9') { token << ch; } else if (ch == ':' || ch=='{' || ch == '}' || ch=='(' || ch == ')' || ch == ';') { onToken(token); onToken(ch); } else if (ch == '\'' || ch == '\"') { onToken(token); insideQuotes = ch; } } }
static lString16 decodeText(lString8 text) { if (text.empty()) return lString16::empty_str; lString8 buf; bool lastControl = false; for (int i=0; i<text.length(); i++) { char ch = buf[i]; if (lastControl) { switch (ch) { case 'r': buf.append(1, '\r'); break; case 'n': buf.append(1, '\n'); break; case 't': buf.append(1, '\t'); break; default: buf.append(1, ch); break; } lastControl = false; continue; } if (ch == '\\') { lastControl = true; continue; } buf.append(1, ch); } return Utf8ToUnicode(buf); }
bool pop() { if (level_==0) { return true; } prefix_ = prefix_.substr(0,prefix_.length()-1); level_--; update_candidates(); return false; }