PHP Class SassScriptParser

Parses SassScript. SassScript is lexed into {@link http://en.wikipedia.org/wiki/Reverse_Polish_notation Reverse Polish notation} by the SassScriptLexer and the calculated result returned.
显示文件 Open project: richthegeek/phpsass Class Usage Examples

Public Properties

Property Type Description
$context Used for error reporting
$instance Hold a copy of a parser available to the general public.
$lexer the lexer object

Public Methods

Method Description
__construct ( ) : SassScriptParser SassScriptParser constructor.
evaluate ( string $expression, SassContext $context, integer $environment = self::DEFAULT_ENV ) : SassLiteral Evaluate a SassScript.
interpolate ( string $string, SassContext $context ) : string Replace interpolated SassScript contained in '#{}' with the parsed value.
makeSingular ( $operands ) Reduces a set down to a singular form
parse ( string $expression, SassContext $context, integer $environment = self::DEFAULT_ENV ) : array Parse SassScript to a set of tokens in RPN using the Shunting Yard Algorithm.

Method Details

__construct() public method

SassScriptParser constructor.
public __construct ( ) : SassScriptParser
return SassScriptParser

evaluate() public method

Evaluate a SassScript.
public evaluate ( string $expression, SassContext $context, integer $environment = self::DEFAULT_ENV ) : SassLiteral
$expression string expression to parse
$context SassContext the context in which the expression is evaluated
$environment integer the environment in which the expression is evaluated
return SassLiteral parsed value

interpolate() public method

Replace interpolated SassScript contained in '#{}' with the parsed value.
public interpolate ( string $string, SassContext $context ) : string
$string string the text to interpolate
$context SassContext the context in which the string is interpolated
return string the interpolated text

makeSingular() public static method

Reduces a set down to a singular form
public static makeSingular ( $operands )

parse() public method

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
return array tokens in RPN

Property Details

$context public_oe static_oe property

Used for error reporting
public static $context

$instance public_oe static_oe property

Hold a copy of a parser available to the general public.
public static $instance

$lexer public_oe property

the lexer object
public $lexer