Constructor
FOFLessParser
__construct
([type] $lessc, [string $sourceName = null])
-
[type]
$lessc: [description]
-
string
$sourceName: [description]
Append a property to the current block
void
append
([type] $prop, [[type] $pos = null])
-
[type]
$prop: [description]
-
[type]
$pos: [description]
Consume an argument definition list surrounded by () each argument is a variable name with optional value or at the end a ... or a variable named followed by ...
boolean
argumentDef
([type] &$args, [type] &$isVararg, [[type] $delim = ','])
-
[type]
&$args: [description]
-
[type]
&$isVararg: [description]
-
[type]
$delim: [description]
Consume a list of property values delimited by ; and wrapped in ()
boolean
argumentValues
([type] &$args, [[type] $delim = ','])
-
[type]
&$args: [description]
-
[type]
$delim: [description]
Consume an assignment operator Can optionally take a name that will be set to the current property name
boolean
assign
([string $name = null])
-
string
$name: [description]
a # color
boolean
color
([type] &$out)
-
[type]
&$out: [description]
Consume an end of statement delimiter
boolean
end
()
Recursively parse infix equation with $lhs at precedence $minP
string
expHelper
(type $lhs, type $minP)
-
type
$lhs: [description]
-
type
$minP: [description]
Attempt to consume an expression.
boolean
expression
(string &$out)
-
string
&$out: [description]
a list of expressions
boolean
expressionList
([type] &$exps)
-
[type]
&$exps: [description]
[fixTags description]
[type]
fixTags
([type] $tags)
-
[type]
$tags: [description]
A css function
boolean
func
([type] &$func)
-
[type]
&$func: [description]
[genericList description]
boolean
genericList
([type] &$out, [type] $parseItem, [string $delim = ""], [boolean $flatten = true])
-
[type]
&$out: [description]
-
[type]
$parseItem: [description]
-
string
$delim: [description]
-
boolean
$flatten: [description]
[guard description]
boolean
guard
([type] &$guard)
-
[type]
&$guard: [description]
A bunch of guards that are and'd together
boolean
guardGroup
([type] &$guardGroup)
-
[type]
&$guardGroup: [description]
[guards description]
boolean
guards
([type] &$guards)
-
[type]
&$guards: [description]
an import statement
boolean
import
([type] &$out)
-
[type]
&$out: [description]
[interpolation description]
boolean
interpolation
([type] &$out)
-
[type]
&$out: [description]
[isDirective description]
boolean
isDirective
(string $dirname, [type] $directives)
-
string
$dirname: [description]
-
[type]
$directives: [description]
Consume a keyword
boolean
keyword
([type] &$word)
-
[type]
&$word: [description]
[literal description]
boolean
literal
([type] $what, [[type] $eatWhitespace = null])
-
[type]
$what: [description]
-
[type]
$eatWhitespace: [description]
Try to match something on head of buffer
boolean
match
([type] $regex, [type] &$out, [[type] $eatWhitespace = null])
-
[type]
$regex: [description]
-
[type]
&$out: [description]
-
[type]
$eatWhitespace: [description]
[mediaExpression description]
boolean
mediaExpression
([type] &$out)
-
[type]
&$out: [description]
[mediaQuery description]
[type]
mediaQuery
([type] &$out)
-
[type]
&$out: [description]
[mediaQueryList description]
boolean
mediaQueryList
([type] &$out)
-
[type]
&$out: [description]
List of tags of specifying mixin path Optionally separated by > (lazy, accepts extra >)
boolean
mixinTags
([type] &$tags)
-
[type]
&$tags: [description]
An unbounded string stopped by $end
boolean
openString
([type] $end, [type] &$out, [[type] $nestingOpen = null], [[type] $rejectStrs = null])
-
[type]
$end: [description]
-
[type]
&$out: [description]
-
[type]
$nestingOpen: [description]
-
[type]
$rejectStrs: [description]
[parenValue description]
boolean
parenValue
([type] &$out)
-
[type]
&$out: [description]
Parse text
[type]
parse
(string $buffer)
-
string
$buffer: [description]
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 lessc::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 lessc::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, lessc::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.
boolean
parseChunk
()
Match something without consuming it
boolean
peek
([type] $regex, [[type] &$out = null], [[type] $from = null])
-
[type]
$regex: [description]
-
[type]
&$out: [description]
-
[type]
$from: [description]
Pop something off the stack
[type]
pop
()
Consume a list of values for a property
boolean
propertyValue
([type] &$value, [[type] $keyName = null])
-
[type]
&$value: [description]
-
[type]
$keyName: [description]
[pushBlock description]
stdClass
pushBlock
([[type] $selectors = null], [[type] $type = null])
-
[type]
$selectors: [description]
-
[type]
$type: [description]
Push a block that doesn't multiply tags
stdClass
pushSpecialBlock
([type] $type)
-
[type]
$type: [description]
Remove comments from $text
[type]
removeComments
([type] $text)
-
[type]
$text: [description]
Seek to a spot in the buffer or return where we are on no argument
boolean
seek
([[type] $where = null])
-
[type]
$where: [description]
[string description]
boolean
string
([type] &$out)
-
[type]
&$out: [description]
A single tag
boolean
tag
([type] &$tag, [boolean $simple = false])
-
[type]
&$tag: [description]
-
boolean
$simple: [description]
A bracketed value (contained within in a tag definition)
boolean
tagBracket
([type] &$value)
-
[type]
&$value: [description]
[tagExpression description]
boolean
tagExpression
([type] &$value)
-
[type]
&$value: [description]
Consume a list of tags This accepts a hanging delimiter
boolean
tags
([type] &$tags, [[type] $simple = false], [[type] $delim = ','])
-
[type]
&$tags: [description]
-
[type]
$simple: [description]
-
[type]
$delim: [description]
[throwError description]
void
throwError
([string $msg = "parse error"], [[type] $count = null])
-
string
$msg: [description]
-
[type]
$count: [description]
Advance counter to next occurrence of $what $until - don't include $what in advance $allowNewline, if string, will be used as valid char set
boolean
to
([type] $what, [type] &$out, [boolean $until = false], [boolean $allowNewline = false])
-
[type]
$what: [description]
-
[type]
&$out: [description]
-
boolean
$until: [description]
-
boolean
$allowNewline: [description]
[unit description]
boolean
unit
([type] &$unit)
-
[type]
&$unit: [description]
a single value
boolean
value
([type] &$value)
-
[type]
&$value: [description]
Consume a less variable
boolean
variable
([type] &$name)
-
[type]
&$name: [description]
Watch some whitespace
boolean
whitespace
()