CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
scss_parser Class Reference

SCSS parser. More...

## Public Member Functions
| __construct ($sourceName=null, $rootParser=true)
| Constructor. More...
| parse ($buffer)
| Parser buffer. More...
| valueList (&$out)
| Parse list. More...
| throwParseError ($msg="parse error", $count=null)
| getLineNo ($pos)

## Static Public Member Functions
static | preg_quote ($what)

## Protected Member Functions
| parseChunk ()
| Parse a single chunk off the head of the buffer and append it to the current parse environment. More...
| stripDefault (&$value)
| literal ($what, $eatWhitespace=null)
| pushBlock ($selectors)
| pushSpecialBlock ($type)
| popBlock ()
| append ($statement, $pos=null)
| last ()
| mediaQueryList (&$out)
| mediaQuery (&$out)
| mediaExpression (&$out)
| argValues (&$out)
| argValue (&$out)
| spaceList (&$out)
| genericList (&$out, $parseItem, $delim="", $flatten=true)
| expression (&$out)
| expHelper ($lhs, $minP)
| value (&$out)
| parenValue (&$out)
| progid (&$out)
| func (&$func)
| argumentList (&$out)
| argumentDef (&$out)
| color (&$out)
| unit (&$unit)
| string (&$out)
| mixedKeyword (&$out)
| openString ($end, &$out, $nestingOpen=null)
| interpolation (&$out, $lookWhite=true)
| propertyName (&$out)
| selectors (&$out)
| selector (&$out)
| selectorSingle (&$out)
| variable (&$out)
| keyword (&$word, $eatWhitespace=null)
| placeholder (&$placeholder)
| end ()
| to ($what, &$out, $until=false, $allowNewline=false)
| matchString (&$m, $delim)
| Match string looking for either ending delim, escape, or string interpolation. More...
| match ($regex, &$out, $eatWhitespace=null)
| whitespace ()
| peek ($regex, &$out, $from=null)
| seek ($where=null)
| show ()
| flattenList ($value)

## Static Protected Member Functions
static | makeOperatorStr ($operators)

## Static Protected Attributes
static | $precedence
static | $operators
static | $operatorStr
static | $whitePattern
static | $commentMulti
static | $commentSingle = "//"
static | $commentMultiLeft = "/*"
static | $commentMultiRight = "*/"

## Detailed Description

SCSS parser.

Author
  Leaf Corcoran leafo.nosp@m.t@gm.nosp@m.ail.c.nosp@m.om

Definition at line 2659 of file scssc.php.

## Constructor & Destructor Documentation

scss_parser::__construct | ( |  | $sourceName = `null`,
|  |  | $rootParser = `true`
| ) |  |

Constructor.

Parameters

  string | $sourceName |
  boolean | $rootParser |

Definition at line 2696 of file scssc.php.

References $commentMultiLeft, $commentMultiRight, $commentSingle, makeOperatorStr(), and preg_quote().

## Member Function Documentation

scss_parser::append | ( |  | $statement,
|  |  | $pos = `null`
| ) |  |
| protected

Definition at line 3151 of file scssc.php.

Referenced by parseChunk(), and whitespace().

Here is the caller graph for this function:

scss_parser::argumentDef | ( | & | $out | ) |
| protected

Definition at line 3507 of file scssc.php.

References genericList(), literal(), seek(), throwParseError(), and variable().

Referenced by parseChunk().

Here is the caller graph for this function:

scss_parser::argumentList | ( | & | $out | ) |
| protected

Definition at line 3476 of file scssc.php.

References expression(), keyword(), literal(), and seek().

Referenced by func().

Here is the caller graph for this function:

scss_parser::argValue | ( | & | $out | ) |
| protected

Definition at line 3228 of file scssc.php.

References genericList(), literal(), seek(), and variable().

scss_parser::argValues | ( | & | $out | ) |
| protected

Definition at line 3220 of file scssc.php.

References genericList().

Referenced by func(), and parseChunk().

Here is the caller graph for this function:

scss_parser::color | ( | & | $out | ) |
| protected

Definition at line 3547 of file scssc.php.

References match().

Referenced by value().

Here is the caller graph for this function:

scss_parser::end | ( |  | ) |
| protected

Definition at line 4014 of file scssc.php.

References literal().

Referenced by openString(), parseChunk(), and stripDefault().

Here is the caller graph for this function:

scss_parser::expHelper | ( |  | $lhs,
|  |  | $minP
| ) |  |
| protected

Definition at line 3316 of file scssc.php.

References match(), peek(), seek(), and value().

Referenced by expression().

Here is the caller graph for this function:

scss_parser::expression | ( | & | $out | ) |
| protected

Definition at line 3292 of file scssc.php.

References expHelper(), literal(), seek(), value(), and valueList().

Referenced by argumentList(), mediaExpression(), parenValue(), and parseChunk().

Here is the caller graph for this function:

scss_parser::flattenList | ( |  | $value | ) |
| protected

Definition at line 4159 of file scssc.php.

Referenced by stripDefault().

Here is the caller graph for this function:

scss_parser::func | ( | & | $func | ) |
| protected

Definition at line 3439 of file scssc.php.

References argumentList(), argValues(), keyword(), literal(), openString(), and seek().

Referenced by value().

Here is the caller graph for this function:

scss_parser::genericList | ( | & | $out,
|  |  | $parseItem,
|  |  | $delim = `""`,
|  |  | $flatten = `true`
| ) |  |
| protected

Definition at line 3268 of file scssc.php.

References literal(), and seek().

Referenced by argumentDef(), argValue(), argValues(), mediaQuery(), mediaQueryList(), spaceList(), and valueList().

Here is the caller graph for this function:

scss_parser::getLineNo | ( |  | $pos | ) |

Definition at line 4057 of file scssc.php.

Referenced by throwParseError().

Here is the caller graph for this function:

scss_parser::interpolation | ( | & | $out,
|  |  | $lookWhite = `true`
| ) |  |
| protected

Definition at line 3723 of file scssc.php.

References literal(), seek(), valueList(), and whitespace().

Referenced by mixedKeyword(), openString(), propertyName(), selectorSingle(), string(), and value().

Here is the caller graph for this function:

scss_parser::keyword | ( | & | $word,
|  |  | $eatWhitespace = `null`
| ) |  |
| protected

Definition at line 3995 of file scssc.php.

References match().

Referenced by argumentList(), func(), mixedKeyword(), parseChunk(), propertyName(), selectorSingle(), value(), and variable().

Here is the caller graph for this function:

scss_parser::last | ( |  | ) |
| protected

Definition at line 3160 of file scssc.php.

Referenced by parseChunk().

Here is the caller graph for this function:

scss_parser::literal | ( |  | $what,
|  |  | $eatWhitespace = `null`
| ) |  |
| protected

Definition at line 3102 of file scssc.php.

References match(), and preg_quote().

Referenced by argumentDef(), argumentList(), argValue(), end(), expression(), func(), genericList(), interpolation(), mediaExpression(), mediaQuery(), parenValue(), parseChunk(), progid(), selectors(), selectorSingle(), string(), value(), and variable().

Here is the caller graph for this function:

static scss_parser::makeOperatorStr | ( |  | $operators | ) |
| static protected

Definition at line 2711 of file scssc.php.

References $operators.

Referenced by __construct().

Here is the caller graph for this function:

scss_parser::match | ( |  | $regex,
|  | & | $out,
|  |  | $eatWhitespace = `null`
| ) |  |
| protected

Definition at line 4104 of file scssc.php.

References whitespace().

Referenced by color(), expHelper(), keyword(), literal(), openString(), placeholder(), propertyName(), selector(), selectorSingle(), to(), and unit().

Here is the caller graph for this function:

scss_parser::matchString | ( | & | $m,
|  |  | $delim
| ) |  |
| protected

Match string looking for either ending delim, escape, or string interpolation.

{

Definition at line 4071 of file scssc.php.

Referenced by string().

Here is the caller graph for this function:

scss_parser::mediaExpression | ( | & | $out | ) |
| protected

Definition at line 3203 of file scssc.php.

References expression(), literal(), and seek().

scss_parser::mediaQuery | ( | & | $out | ) |
| protected

Definition at line 3172 of file scssc.php.

References genericList(), literal(), mixedKeyword(), and seek().

scss_parser::mediaQueryList | ( | & | $out | ) |
| protected

Definition at line 3168 of file scssc.php.

References genericList().

Referenced by parseChunk().

Here is the caller graph for this function:

scss_parser::mixedKeyword | ( | & | $out | ) |
| protected

Definition at line 3628 of file scssc.php.

References interpolation(), keyword(), seek(), and whitespace().

Referenced by mediaQuery(), and selectorSingle().

Here is the caller graph for this function:

scss_parser::openString | ( |  | $end,
|  | & | $out,
|  |  | $nestingOpen = `null`
| ) |  |
| protected

Definition at line 3663 of file scssc.php.

References end(), interpolation(), and match().

Referenced by func(), parseChunk(), progid(), and selectorSingle().

Here is the caller graph for this function:

scss_parser::parenValue | ( | & | $out | ) |
| protected

Definition at line 3401 of file scssc.php.

References expression(), literal(), and seek().

Referenced by value().

Here is the caller graph for this function:

scss_parser::parse | ( |  | $buffer | ) |

Parser buffer.

Parameters

  string | $buffer,; |

Returns

Definition at line 2723 of file scssc.php.

References parseChunk(), pushBlock(), throwParseError(), and whitespace().

scss_parser::parseChunk | ( |  | ) |
| protected

Parse a single chunk off the head of the buffer and append it to the current parse environment.

Returns false when the buffer is empty, or when there is an error.

This function is called repeatedly until the entire document is parsed.

This parser is most similar to a recursive descent parser. Single functions represent discrete grammatical rules for the language, and they are able to capture the text that represents those rules.

Consider the function scssc::keyword(). (All parse functions are structured the same.)

The function takes a single reference argument. When calling the function it will attempt to match a keyword on the head of the buffer. If it is successful, it will place the keyword in the referenced argument, advance the position in the buffer, and return true. If it fails then it won't advance the buffer and it will return false.

All of these parse functions are powered by scssc::match(), which behaves the same way, but takes a literal regular expression. Sometimes it is more convenient to use match instead of creating a new function.

Because of the format of the functions, to parse an entire string of grammatical rules, you can chain them together using &&.

But, if some of the rules in the chain succeed before one fails, then the buffer position will be left at an invalid state. In order to avoid this, scssc::seek() is used to remember and set buffer positions.

Before parsing a chain, use $s = $this->seek() to remember the current position into $s. Then if a chain fails, use $this->seek($s) to go back where we started.

Returns
  boolean

Definition at line 2790 of file scssc.php.

References append(), argumentDef(), argValues(), end(), expression(), keyword(), last(), literal(), mediaQueryList(), openString(), popBlock(), propertyName(), pushBlock(), pushSpecialBlock(), seek(), selectors(), stripDefault(), valueList(), and variable().

Referenced by parse().

Here is the caller graph for this function:

scss_parser::peek | ( |  | $regex,
|  | & | $out,
|  |  | $from = `null`
| ) |  |
| protected

Definition at line 4132 of file scssc.php.

Referenced by expHelper(), show(), and throwParseError().

Here is the caller graph for this function:

scss_parser::placeholder | ( | & | $placeholder | ) |
| protected

Definition at line 4005 of file scssc.php.

References match().

Referenced by selectorSingle().

Here is the caller graph for this function:

scss_parser::popBlock | ( |  | ) |
| protected

Definition at line 3140 of file scssc.php.

References throwParseError().

Referenced by parseChunk().

Here is the caller graph for this function:

static scss_parser::preg_quote | ( |  | $what | ) |
| static

Definition at line 4147 of file scssc.php.

Referenced by __construct(), and literal().

Here is the caller graph for this function:

scss_parser::progid | ( | & | $out | ) |
| protected

Definition at line 3420 of file scssc.php.

References literal(), openString(), and seek().

Referenced by value().

Here is the caller graph for this function:

scss_parser::propertyName | ( | & | $out | ) |
| protected

Definition at line 3753 of file scssc.php.

References interpolation(), keyword(), match(), seek(), and whitespace().

Referenced by parseChunk().

Here is the caller graph for this function:

scss_parser::pushBlock | ( |  | $selectors | ) |
| protected

Definition at line 3123 of file scssc.php.

Referenced by parse(), parseChunk(), and pushSpecialBlock().

Here is the caller graph for this function:

scss_parser::pushSpecialBlock | ( |  | $type | ) |
| protected

Definition at line 3134 of file scssc.php.

References pushBlock().

Referenced by parseChunk().

Here is the caller graph for this function:

scss_parser::seek | ( |  | $where = `null` | ) |
| protected

Definition at line 4141 of file scssc.php.

Referenced by argumentDef(), argumentList(), argValue(), expHelper(), expression(), func(), genericList(), interpolation(), mediaExpression(), mediaQuery(), mixedKeyword(), parenValue(), parseChunk(), progid(), propertyName(), selectors(), selectorSingle(), string(), value(), and variable().

Here is the caller graph for this function:

scss_parser::selector | ( | & | $out | ) |
| protected

Definition at line 3812 of file scssc.php.

References match(), selectorSingle(), and whitespace().

Referenced by selectors().

Here is the caller graph for this function:

scss_parser::selectors | ( | & | $out | ) |
| protected

Definition at line 3793 of file scssc.php.

References literal(), seek(), and selector().

Referenced by parseChunk().

Here is the caller graph for this function:

scss_parser::selectorSingle | ( | & | $out | ) |
| protected

Definition at line 3839 of file scssc.php.

References scssc\$selfSelector, interpolation(), keyword(), literal(), match(), mixedKeyword(), openString(), placeholder(), seek(), and unit().

Referenced by selector().

Here is the caller graph for this function:

scss_parser::show | ( |  | ) |
| protected

Definition at line 4151 of file scssc.php.

References peek().

scss_parser::spaceList | ( | & | $out | ) |
| protected

Definition at line 3263 of file scssc.php.

References genericList().

scss_parser::string | ( | & | $out | ) |
| protected

Definition at line 3582 of file scssc.php.

References interpolation(), literal(), matchString(), and seek().

scss_parser::stripDefault | ( | & | $value | ) |
| protected

Definition at line 3087 of file scssc.php.

References end(), and flattenList().

Referenced by parseChunk().

Here is the caller graph for this function:

scss_parser::throwParseError | ( |  | $msg = `"parse error"`,
|  |  | $count = `null`
| ) |  |

Definition at line 4039 of file scssc.php.

References getLineNo(), and peek().

Referenced by argumentDef(), parse(), and popBlock().

Here is the caller graph for this function:

scss_parser::to | ( |  | $what,
|  | & | $out,
|  |  | $until = `false`,
|  |  | $allowNewline = `false`
| ) |  |
| protected

Definition at line 4027 of file scssc.php.

References match().

scss_parser::unit | ( | & | $unit | ) |
| protected

Definition at line 3574 of file scssc.php.

References match().

Referenced by selectorSingle(), and value().

Here is the caller graph for this function:

scss_parser::value | ( | & | $out | ) |
| protected

Definition at line 3350 of file scssc.php.

References color(), func(), interpolation(), keyword(), literal(), parenValue(), progid(), seek(), unit(), variable(), and whitespace().

Referenced by expHelper(), and expression().

Here is the caller graph for this function:

scss_parser::valueList | ( | & | $out | ) |

Parse list.

Parameters

  string | $out |

Returns
  boolean

Definition at line 3258 of file scssc.php.

References genericList().

Referenced by expression(), interpolation(), and parseChunk().

Here is the caller graph for this function:

scss_parser::variable | ( | & | $out | ) |
| protected

Definition at line 3985 of file scssc.php.

References keyword(), literal(), and seek().

Referenced by argumentDef(), argValue(), parseChunk(), and value().

Here is the caller graph for this function:

scss_parser::whitespace | ( |  | ) |
| protected

Definition at line 4117 of file scssc.php.

References append().

Referenced by interpolation(), match(), mixedKeyword(), parse(), propertyName(), selector(), and value().

Here is the caller graph for this function:

## Member Data Documentation

scss_parser::$commentMulti
| static protected

Definition at line 2684 of file scssc.php.

scss_parser::$commentMultiLeft = "/*"
| static protected

Definition at line 2687 of file scssc.php.

Referenced by __construct().

scss_parser::$commentMultiRight = "*/"
| static protected

Definition at line 2688 of file scssc.php.

Referenced by __construct().

scss_parser::$commentSingle = "//"
| static protected

Definition at line 2686 of file scssc.php.

Referenced by __construct().

scss_parser::$operators
| static protected

Initial value:
= array("+", "-", "*", "/", "%",
"==", "!=", "<=", ">=", "<", ">", "and", "or")

Definition at line 2679 of file scssc.php.

Referenced by makeOperatorStr().

scss_parser::$operatorStr
| static protected

Definition at line 2682 of file scssc.php.

scss_parser::$precedence
| static protected

Initial value:
= array(
"or" => 0,
"and" => 1,
'==' => 2,
'!=' => 2,
'<=' => 2,
'>=' => 2,
'=' => 2,
'<' => 3,
'>' => 2,
'+' => 3,
'-' => 3,
'*' => 4,
'/' => 4,
'%' => 4,
)

Definition at line 2660 of file scssc.php.

scss_parser::$whitePattern
| static protected

Definition at line 2683 of file scssc.php.

The documentation for this class was generated from the following file:

- lib/ScoutLib/scssc.php