PHP Class titanscss_parser

Author: Leaf Corcoran ([email protected])
Mostra file Open project: gambitph/titan-framework Class Usage Examples

Protected Properties

Property Type Description
$commentMulti
$commentMultiLeft
$commentMultiRight
$commentSingle
$operatorStr
$operators
$precedence
$whitePattern

Public Methods

Method Description
__construct ( $sourceName = null, $rootParser = true )
getLineNo ( $pos )
parse ( $buffer )
preg_quote ( $what )
throwParseError ( $msg = "parse error", $count = null )

Protected Methods

Method Description
append ( $statement, $pos = null )
argValue ( &$out )
argValues ( &$out )
argumentDef ( &$out )
argumentList ( &$out )
color ( &$out )
end ( ) consume an end of statement delimiter
expHelper ( $lhs, $minP )
expression ( &$out )
flattenList ( $value ) turn list of length 1 into value type
func ( &$func )
genericList ( &$out, $parseItem, $delim = "", $flatten = true )
interpolation ( &$out, $lookWhite = true ) $lookWhite: save information about whitespace before and after
keyword ( &$word, $eatWhitespace = null )
last ( ) last child that was appended
literal ( $what, $eatWhitespace = null )
makeOperatorStr ( $operators )
match ( $regex, &$out, $eatWhitespace = null ) try to match something on head of buffer
matchString ( array &$m, string $delim ) : boolean Match string looking for either ending delim, escape, or string interpolation
mediaExpression ( &$out )
mediaQuery ( &$out )
mediaQueryList ( &$out ) high level parsers (they return parts of ast)
mixedKeyword ( &$out )
openString ( $end, &$out, $nestingOpen = null ) an unbounded string stopped by $end
parenValue ( &$out ) value wrappen in parentheses
parseChunk ( ) : boolean Parse a single chunk off the head of the buffer and append it to the current parse environment.
peek ( $regex, &$out, $from = null )
placeholder ( &$placeholder )
popBlock ( )
progid ( &$out )
propertyName ( &$out ) returns an array of parts or a string
pushBlock ( $selectors ) tree builders
pushSpecialBlock ( $type )
seek ( $where = null )
selector ( &$out ) whitespace separated list of selectorSingle
selectorSingle ( &$out ) div[yes=no]#something.hello.world:nth-child(-2n+1)%placeholder
selectors ( &$out ) comma separated list of selectors
show ( )
spaceList ( &$out )
string ( &$out )
stripDefault ( &$value )
to ( $what, &$out, $until = false, $allowNewline = false ) $allowNewline, if string, will be used as valid char set
unit ( &$unit )
value ( &$out )
valueList ( &$out )
variable ( &$out )
whitespace ( ) match some whitespace

Method Details

__construct() public method

public __construct ( $sourceName = null, $rootParser = true )

append() protected method

protected append ( $statement, $pos = null )

argValue() protected method

protected argValue ( &$out )

argValues() protected method

protected argValues ( &$out )

argumentDef() protected method

protected argumentDef ( &$out )

argumentList() protected method

protected argumentList ( &$out )

color() protected method

protected color ( &$out )

end() protected method

consume an end of statement delimiter
protected end ( )

expHelper() protected method

protected expHelper ( $lhs, $minP )

expression() protected method

protected expression ( &$out )

flattenList() protected method

turn list of length 1 into value type
protected flattenList ( $value )

func() protected method

protected func ( &$func )

genericList() protected method

protected genericList ( &$out, $parseItem, $delim = "", $flatten = true )

getLineNo() public method

public getLineNo ( $pos )

interpolation() protected method

$lookWhite: save information about whitespace before and after
protected interpolation ( &$out, $lookWhite = true )

keyword() protected method

protected keyword ( &$word, $eatWhitespace = null )

last() protected method

last child that was appended
protected last ( )

literal() protected method

protected literal ( $what, $eatWhitespace = null )

makeOperatorStr() protected static method

protected static makeOperatorStr ( $operators )

match() protected method

try to match something on head of buffer
protected match ( $regex, &$out, $eatWhitespace = null )

matchString() protected method

{@internal This is a workaround for preg_match's 250K string match limit.}}
protected matchString ( array &$m, string $delim ) : boolean
$m array Matches (passed by reference)
$delim string Delimeter
return boolean True if match; false otherwise

mediaExpression() protected method

protected mediaExpression ( &$out )

mediaQuery() protected method

protected mediaQuery ( &$out )

mediaQueryList() protected method

high level parsers (they return parts of ast)
protected mediaQueryList ( &$out )

mixedKeyword() protected method

protected mixedKeyword ( &$out )

openString() protected method

an unbounded string stopped by $end
protected openString ( $end, &$out, $nestingOpen = null )

parenValue() protected method

value wrappen in parentheses
protected parenValue ( &$out )

parse() public method

public parse ( $buffer )

parseChunk() protected method

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.
protected parseChunk ( ) : boolean
return boolean

peek() protected method

protected peek ( $regex, &$out, $from = null )

placeholder() protected method

protected placeholder ( &$placeholder )

popBlock() protected method

protected popBlock ( )

preg_quote() static public method

static public preg_quote ( $what )

progid() protected method

protected progid ( &$out )

propertyName() protected method

returns an array of parts or a string
protected propertyName ( &$out )

pushBlock() protected method

tree builders
protected pushBlock ( $selectors )

pushSpecialBlock() protected method

protected pushSpecialBlock ( $type )

seek() protected method

protected seek ( $where = null )

selector() protected method

whitespace separated list of selectorSingle
protected selector ( &$out )

selectorSingle() protected method

div[yes=no]#something.hello.world:nth-child(-2n+1)%placeholder
protected selectorSingle ( &$out )

selectors() protected method

comma separated list of selectors
protected selectors ( &$out )

show() protected method

protected show ( )

spaceList() protected method

protected spaceList ( &$out )

string() protected method

protected string ( &$out )

stripDefault() protected method

protected stripDefault ( &$value )

throwParseError() public method

public throwParseError ( $msg = "parse error", $count = null )

to() protected method

$allowNewline, if string, will be used as valid char set
protected to ( $what, &$out, $until = false, $allowNewline = false )

unit() protected method

protected unit ( &$unit )

value() protected method

protected value ( &$out )

valueList() protected method

protected valueList ( &$out )

variable() protected method

protected variable ( &$out )

whitespace() protected method

match some whitespace
protected whitespace ( )

Property Details

$commentMulti protected_oe static_oe property

protected static $commentMulti

$commentMultiLeft protected_oe static_oe property

protected static $commentMultiLeft

$commentMultiRight protected_oe static_oe property

protected static $commentMultiRight

$commentSingle protected_oe static_oe property

protected static $commentSingle

$operatorStr protected_oe static_oe property

protected static $operatorStr

$operators protected_oe static_oe property

protected static $operators

$precedence protected_oe static_oe property

protected static $precedence

$whitePattern protected_oe static_oe property

protected static $whitePattern