PHP Class LightnCandy\Parser

Inheritance: extends Token
显示文件 Open project: zordius/lightncandy Class Usage Examples

Public Methods

Method Description
getBlockParams ( arrayinteger | array> &$vars ) : array | null Get block params and fix the variable list
getPartialBlock ( arrayinteger | array> &$vars ) : integer Get partial block id and fix the variable list
getPartialName ( arrayinteger | array> &$vars, integer $pos ) : array | null Get partial name from "foo" or [foo] or \'foo\'
isSubExp ( arrayinteger | array> $var ) : boolean Check a parsed result is a subexpression or not
parse ( array &$token, array\arraystring | integer> &$context ) : arrayinteger | array> Parse the token and return parsed result.
subexpression ( string $expression, array\arraystring | integer> &$context ) : arrayinteger | array> Parse a subexpression then return parsed result.

Protected Methods

Method Description
advancedVariable ( arrayinteger | array> $vars, array\arraystring | integer> &$context, string $token ) : arrayinteger | array> Analyze parsed token for advanved variables.
analyze ( string $token, array\arraystring | integer> &$context ) : arrayinteger | array> Analyze a token string and return parsed result.
getExpression ( string $v, array\arraystring | integer> &$context, integer $pos ) : string>\array Return array presentation for an expression
getLiteral ( string $name, boolean $asis, boolean $quote = false ) : array Return array presentation for a literal

Method Details

advancedVariable() protected static method

Analyze parsed token for advanved variables.
protected static advancedVariable ( arrayinteger | array> $vars, array\arraystring | integer> &$context, string $token ) : arrayinteger | array>
$vars arrayinteger | array>
$context array\arraystring | integer>
$token string original token
return arrayinteger | array>

analyze() protected static method

Analyze a token string and return parsed result.
protected static analyze ( string $token, array\arraystring | integer> &$context ) : arrayinteger | array>
$token string preg_match results
$context array\arraystring | integer>
return arrayinteger | array>

getBlockParams() public static method

Get block params and fix the variable list
public static getBlockParams ( arrayinteger | array> &$vars ) : array | null
$vars arrayinteger | array>
return array | null

getExpression() protected static method

Return array presentation for an expression
protected static getExpression ( string $v, array\arraystring | integer> &$context, integer $pos ) : string>\array
$v string analyzed expression names.
$context array\arraystring | integer>
$pos integer expression position
return string>\array

getLiteral() protected static method

Return array presentation for a literal
protected static getLiteral ( string $name, boolean $asis, boolean $quote = false ) : array
$name string variable name.
$asis boolean keep the name as is or not
$quote boolean add single quote or not
return array

getPartialBlock() public static method

Get partial block id and fix the variable list
public static getPartialBlock ( arrayinteger | array> &$vars ) : integer
$vars arrayinteger | array>
return integer Return partial block id

getPartialName() public static method

Get partial name from "foo" or [foo] or \'foo\'
public static getPartialName ( arrayinteger | array> &$vars, integer $pos ) : array | null
$vars arrayinteger | array>
$pos integer position of partial name
return array | null

isSubExp() public static method

Check a parsed result is a subexpression or not
public static isSubExp ( arrayinteger | array> $var ) : boolean
$var arrayinteger | array>
return boolean return true when input is a subexpression

parse() public static method

Parse the token and return parsed result.
public static parse ( array &$token, array\arraystring | integer> &$context ) : arrayinteger | array>
$token array
$context array\arraystring | integer>
return arrayinteger | array>

subexpression() public static method

Parse a subexpression then return parsed result.
public static subexpression ( string $expression, array\arraystring | integer> &$context ) : arrayinteger | array>
$expression string the full string of a sub expression
$context array\arraystring | integer>
return arrayinteger | array>