private function SassParser::parseDirective in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/SassParser.php \SassParser::parseDirective()
Parses a directive
Parameters
SassToken token to parse:
SassNode parent node:
Return value
SassNode a Sass directive node
1 call to SassParser::parseDirective()
- SassParser::getNode in phpsass/
SassParser.php - Creates and returns the next SassNode. The tpye of SassNode depends on the content of the SassToken.
File
- phpsass/
SassParser.php, line 852
Class
- SassParser
- SassParser class. Parses {@link http://sass-lang.com/ .sass and .sccs} files. @package PHamlP @subpackage Sass
Code
private function parseDirective($token, $parent) {
switch (SassDirectiveNode::extractDirective($token)) {
case '@extend':
return new SassExtendNode($token);
break;
case '@function':
return new SassFunctionDefinitionNode($token);
break;
case '@return':
return new SassReturnNode($token);
break;
case '@mixin':
return new SassMixinDefinitionNode($token);
break;
case '@include':
return new SassMixinNode($token);
break;
case '@import':
if ($this->syntax == SassFile::SASS) {
$i = 0;
$source = '';
while (!empty($this->source) && empty($source)) {
$source = $this->source[$i++];
}
if (!empty($source) && $this
->getLevel($source) > $token->level) {
if ($this->debug) {
throw new SassException('Nesting not allowed beneath @import directive', $token);
}
}
}
return new SassImportNode($token);
break;
case '@each':
return new SassEachNode($token);
break;
case '@for':
return new SassForNode($token);
break;
case '@if':
return new SassIfNode($token);
break;
case '@else':
// handles else and else if directives
return new SassElseNode($token);
break;
case '@do':
case '@while':
return new SassWhileNode($token);
break;
case '@debug':
return new SassDebugNode($token);
break;
case '@warn':
return new SassDebugNode($token, true);
break;
default:
return new SassDirectiveNode($token);
break;
}
}