Пример #1
0
bool LessParser::parsePropertyVariable(Selector &selector) {
  Token variable = tokenizer->getToken();

  if (tokenizer->getTokenType() != Token::OTHER ||
      variable != "@")
    return false;
  
  if (tokenizer->readNextToken() != Token::BRACKET_OPEN) 
    throw new ParseException(tokenizer->getToken(),
                             "Opening bracket following @");
  variable.append(tokenizer->getToken());
  
  if (tokenizer->readNextToken() != Token::IDENTIFIER) 
    throw new ParseException(tokenizer->getToken(),
                             "Variable inside selector (e.g.: \
@{identifier})");

  variable.append(tokenizer->getToken());
      
  if (tokenizer->readNextToken() != Token::BRACKET_CLOSED)
    throw new ParseException(tokenizer->getToken(),
                               "Closing bracket after variable.");

  variable.append(tokenizer->getToken());
  tokenizer->readNextToken();

  selector.push_back(variable);
  parseWhitespace(selector);
    
  return true;
}
Пример #2
0
void LessParser::parseMediaQueryRuleset(Token &mediatoken,
                                        LessStylesheet &stylesheet,
                                        LessRuleset &parent) {

  MediaQueryRuleset* query = parent.createMediaQuery();
  Selector selector;

  query->setReference(reference);
  
  selector.push_back(mediatoken);
  selector.push_back(Token::BUILTIN_SPACE);

  CssParser::skipWhitespace();

  while (parseAny(selector) ||
         tokenizer->getTokenType() == Token::ATKEYWORD) {
    if (tokenizer->getTokenType() == Token::ATKEYWORD) {
      selector.push_back(tokenizer->getToken());
      tokenizer->readNextToken();
      parseWhitespace(selector);
    }
  }

  query->setSelector(selector);
  
  if (tokenizer->getTokenType() != Token::BRACKET_OPEN) {
    throw new ParseException(tokenizer->getToken(),
                             "{");
  }
  tokenizer->readNextToken();
  skipWhitespace();

  parseRulesetStatements(stylesheet, *query);

  if (tokenizer->getTokenType() != Token::BRACKET_CLOSED) {
    throw new ParseException(tokenizer->getToken(),
                             "end of media query block ('}')");
  }
  tokenizer->readNextToken();
  skipWhitespace();
}