You are here

private function SassParser::parseDirective in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/SassParser.php \SassParser::parseDirective()

* Parses a directive *

Parameters

SassToken token to parse: * @param SassNode parent node * @return SassNode a Sass directive node

1 call to SassParser::parseDirective()
SassParser::getNode in phamlp/sass/SassParser.php
* Creates and returns the next SassNode. * The tpye of SassNode depends on the content of the SassToken. *

File

phamlp/sass/SassParser.php, line 772

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 '@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) {
          throw new SassException('Nesting not allowed beneath {what}', array(
            '{what}' => '@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;
  }
}