You are here

private function SassParser::getNode in Sassy 7

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

* Creates and returns the next SassNode. * The tpye of SassNode depends on the content of the SassToken. *

Return value

SassNode a SassNode of the appropriate type. Null when no more * source to parse.

1 call to SassParser::getNode()
SassParser::buildTree in phamlp/sass/SassParser.php
* Builds a parse tree under the parent node. * Called recursivly until the source is parsed. *

File

phamlp/sass/SassParser.php, line 528

Class

SassParser
SassParser class. Parses {@link http://sass-lang.com/ .sass and .sccs} files. @package PHamlP @subpackage Sass

Code

private function getNode($node) {
  $token = $this
    ->getToken();
  if (empty($token)) {
    return null;
  }
  switch (true) {
    case SassDirectiveNode::isa($token):
      return $this
        ->parseDirective($token, $node);
      break;
    case SassCommentNode::isa($token):
      return new SassCommentNode($token);
      break;
    case SassVariableNode::isa($token):
      return new SassVariableNode($token);
      break;
    case SassPropertyNode::isa(array(
      'token' => $token,
      'syntax' => $this->property_syntax,
    )):
      return new SassPropertyNode($token, $this->property_syntax);
      break;
    case SassMixinDefinitionNode::isa($token):
      if ($this->syntax === SassFile::SCSS) {
        throw new SassException('Mixin {which} shortcut not allowed in SCSS', array(
          '{which}' => 'definition',
        ), $this);
      }
      return new SassMixinDefinitionNode($token);
      break;
    case SassMixinNode::isa($token):
      if ($this->syntax === SassFile::SCSS) {
        throw new SassException('Mixin {which} shortcut not allowed in SCSS', array(
          '{which}' => 'include',
        ), $this);
      }
      return new SassMixinNode($token);
      break;
    default:
      return new SassRuleNode($token);
      break;
  }

  // switch
}