parse() 공개 메소드

Parse SassScript to a set of tokens in RPN using the Shunting Yard Algorithm.
public parse ( string $expression, SassContext $context, integer $environment = self::DEFAULT_ENV ) : array
$expression string expression to parse
$context SassContext the context in which the expression is parsed
$environment integer the environment in which the expression is parsed
리턴 array tokens in RPN
예제 #1
0
 public static function colour_stops()
 {
     $args = func_get_args();
     $list = array();
     foreach ($args as $arg) {
         if ($arg instanceof SassColour) {
             $list[] = new CompassColourStop($arg);
         } elseif ($arg instanceof SassString) {
             # We get a string as the result of concatenation
             # So we have to reparse the expression
             $colour = $stop = null;
             if (empty($parser)) {
                 $parser = new SassScriptParser();
             }
             $expr = $parser->parse($arg->value, SassScriptParser::$context);
             $x = array_pop($expr);
             if ($x instanceof SassColour) {
                 $colour = $x;
             } elseif ($x instanceof SassScriptOperation) {
                 if ($x->operator != 'concat') {
                     # This should never happen.
                     throw new SassScriptFunctionException("Couldn't parse a colour stop from: {value}", array('{value}' => $arg->value), SassScriptParser::$context->node);
                 }
                 $colour = $expr[0];
                 $stop = $expr[1];
             } else {
                 throw new SassScriptFunctionException("Couldn't parse a colour stop from: {value}", array('{value}' => $arg->value), SassScriptParser::$context->node);
             }
             $list[] = new CompassColourStop($colour, $stop);
         } else {
             throw new SassScriptFunctionException('Not a valid color stop: {arg}', array('{arg}' => $arg->value), SassScriptParser::$context->node);
         }
     }
     return new CompassList($list);
 }