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.

## Member Function Documentation

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

Definition at line 3151 of file scssc.php.

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

Definition at line 3507 of file scssc.php.

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

Definition at line 3476 of file scssc.php.

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

Definition at line 3228 of file scssc.php.

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

Definition at line 3220 of file scssc.php.

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

Definition at line 3547 of file scssc.php.

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

Definition at line 4014 of file scssc.php.

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

Definition at line 3316 of file scssc.php.

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

Definition at line 3292 of file scssc.php.

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

Definition at line 4159 of file scssc.php.

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

Definition at line 3439 of file scssc.php.

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

Definition at line 3268 of file scssc.php.

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

Definition at line 4057 of file scssc.php.

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

Definition at line 3723 of file scssc.php.

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

Definition at line 3995 of file scssc.php.

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

Definition at line 3160 of file scssc.php.

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

Definition at line 3102 of file scssc.php.

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

Definition at line 2711 of file scssc.php.

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

Definition at line 4104 of file scssc.php.

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.

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

Definition at line 3203 of file scssc.php.

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

Definition at line 3172 of file scssc.php.

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

Definition at line 3168 of file scssc.php.

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

Definition at line 3628 of file scssc.php.

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

Definition at line 3663 of file scssc.php.

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

Definition at line 3401 of file scssc.php.

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

Parser buffer.

Parameters

  string | $buffer,; |

Returns

Definition at line 2723 of file scssc.php.

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.

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

Definition at line 4132 of file scssc.php.

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

Definition at line 4005 of file scssc.php.

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

Definition at line 3140 of file scssc.php.

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

Definition at line 4147 of file scssc.php.

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

Definition at line 3420 of file scssc.php.

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

Definition at line 3753 of file scssc.php.

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

Definition at line 3123 of file scssc.php.

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

Definition at line 3134 of file scssc.php.

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

Definition at line 4141 of file scssc.php.

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

Definition at line 3812 of file scssc.php.

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

Definition at line 3793 of file scssc.php.

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

Definition at line 3839 of file scssc.php.

References scssc\$selfSelector.

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

Definition at line 4151 of file scssc.php.

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

Definition at line 3263 of file scssc.php.

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

Definition at line 3582 of file scssc.php.

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

Definition at line 3087 of file scssc.php.

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

Definition at line 4039 of file scssc.php.

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

Definition at line 4027 of file scssc.php.

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

Definition at line 3574 of file scssc.php.

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

Definition at line 3350 of file scssc.php.

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

Parse list.

Parameters

  string | $out |

Returns
  boolean

Definition at line 3258 of file scssc.php.

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

Definition at line 3985 of file scssc.php.

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

Definition at line 4117 of file scssc.php.

## 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.

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

Definition at line 2688 of file scssc.php.

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

Definition at line 2686 of file scssc.php.

scss_parser::$operators
| static protected

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

Definition at line 2679 of file scssc.php.

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