Declaration* CssParser::parseDeclaration () { Declaration* declaration = NULL; TokenList property; if (!parseProperty(&property)) return NULL; skipWhitespace(); declaration = new Declaration(property.toString()); if (tokenizer->getTokenType() != Token::COLON) { throw new ParseException(tokenizer->getToken()->str, "colon following property(':')"); } tokenizer->readNextToken(); skipWhitespace(); TokenList* value = parseValue(); if (value == NULL) { throw new ParseException(tokenizer->getToken()->str, "value for property"); } declaration->setValue(value); return declaration; }
void LessDeclaration::process(Ruleset &r, void* context) const { Declaration *d = r.createDeclaration(); d->setProperty(property); d->setValue(value); ((ProcessingContext*)context)->interpolate(d->getProperty()); ((ProcessingContext*)context)->processValue(d->getValue()); // If the `important` flag is set, append '!important' if(((ProcessingContext*)context)->isImportant()) { if (d->getValue().size() < 3 || d->getValue().back() == "important") { d->getValue().push_back(Token::BUILTIN_SPACE); d->getValue().push_back(Token::BUILTIN_IMPORTANT); } } }