Represents a CSS comment.
Author: Chris Yates
Inheritance: extends SassNode
示例#1
0
 /**
  * Creates and returns the next SassNode.
  * The tpye of SassNode depends on the content of the SassToken.
  * @return SassNode a SassNode of the appropriate type. Null when no more
  * source to parse.
  */
 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($token, $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
 }
示例#2
0
 /**
  * Creates and returns the next SassNode.
  * The tpye of SassNode depends on the content of the SassToken.
  * @return SassNode a SassNode of the appropriate type. Null when no more
  * source to parse.
  */
 public function getNode($node)
 {
     $token = $this->getToken();
     if (empty($token)) {
         return null;
     }
     switch (true) {
         case SassDirectiveNode::isa($token):
             return $this->parseDirective($token, $node);
         case SassCommentNode::isa($token):
             return new SassCommentNode($token);
         case SassVariableNode::isa($token):
             return new SassVariableNode($token);
         case SassPropertyNode::isa(array('token' => $token, 'syntax' => $this->property_syntax)):
             return new SassPropertyNode($token, $this->property_syntax);
         case SassFunctionDefinitionNode::isa($token):
             return new SassFunctionDefinitionNode($token);
         case SassMixinDefinitionNode::isa($token):
             if ($this->syntax === SassFile::SCSS) {
                 if ($this->debug) {
                     throw new SassException('Mixin definition shortcut not allowed in SCSS', $this);
                 }
                 return;
             } else {
                 return new SassMixinDefinitionNode($token);
             }
         case SassMixinNode::isa($token):
             if ($this->syntax === SassFile::SCSS) {
                 if ($this->debug) {
                     throw new SassException('Mixin include shortcut not allowed in SCSS', $this);
                 }
                 return;
             } else {
                 return new SassMixinNode($token);
             }
         default:
             return new SassRuleNode($token);
             break;
     }
     // switch
 }
示例#3
0
 /**
  * Parses a comment line and its child lines.
  * @param string line to parse
  * @param array remaining lines
  * @return mixed SassCommentNode object for CSS comments, null for Sass comments
  * @throws Exception if the comment type is unrecognised
  */
 private function parseComment($line, &$lines)
 {
     switch ($line['source'][1]) {
         case SassCommentNode::Sass_COMMENT:
             $node = null;
             while ($this->hasChild($line, $lines, true)) {
                 array_shift($lines);
                 $this->lineNumber++;
             }
             break;
         case SassCommentNode::CSS_COMMENT:
             $matches = SassCommentNode::match($line);
             $node = new SassCommentNode($matches[SassCommentNode::COMMENT]);
             while ($this->hasChild($line, $lines, true)) {
                 $node->addline(ltrim(array_shift($lines)));
                 $this->lineNumber++;
             }
             break;
         default:
             throw new SassException("Illegal comment type.\nLine {$line['number']}: " . (is_array($line['file']) ? join(DIRECTORY_SEPARATOR, $line['file']) : ''));
             break;
     }
     // switch
     return $node;
 }