PHP 클래스 PhpCss\Parser

파일 보기 프로젝트 열기: ThomasWeinert/PhpCss 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_tokens array(Scanner\Token) List of tokens from scanner

공개 메소드들

메소드 설명
__construct ( array &$tokens ) Construct a parser object taking the token list to operate on as argument
parse ( ) : Ast Execute the parsing process on the provided token stream

보호된 메소드들

메소드 설명
delegate ( string $parserClass ) : Ast Delegate the parsing process to a subparser
endOfTokens ( integer $position ) : boolean Validate if the of the token stream is reached. The position parameter may be provided to look forward.
ignore ( array | integer | string $expectedTokens ) : boolean Try to read any of the $expectedTokens from the token stream and remove them from it.
lookahead ( array | integer | string $expectedTokens, integer $position, boolean $allowEndOfTokens = FALSE ) : Token | null Try to match any of the $expectedTokens against the given token stream position and return the matching one.
matchToken ( integer $position, integer $type ) : boolean Match a token on the token stream against a token type.
read ( array | integer | string $expectedTokens ) : Token Try to read any of the $expectedTokens from the token list and return the matching one.

비공개 메소드들

메소드 설명
handleMismatch ( array() $expectedTokens, integer $position ) : Exception Handle the case if none of the expected tokens could be found.

메소드 상세

__construct() 공개 메소드

Construct a parser object taking the token list to operate on as argument
public __construct ( array &$tokens )
$tokens array

delegate() 보호된 메소드

The result of the subparser is returned Only the name of the subparser is expected here, the method takes care of providing the current token stream as well as instantiating the subparser.
protected delegate ( string $parserClass ) : Ast
$parserClass string
리턴 Ast

endOfTokens() 보호된 메소드

Validate if the of the token stream is reached. The position parameter may be provided to look forward.
protected endOfTokens ( integer $position ) : boolean
$position integer
리턴 boolean

ignore() 보호된 메소드

This method tries to match the current token list against all of the provided tokens. Matching tokens are removed from the list until a non matching token is found or the token list ends. The $expectedTokens parameter may be an array of tokens or a scalar value, which is handled the same way an array with only one entry would be. The special Token Scanner\Token::ANY is not valid here. The method return TRUE if tokens were removed, otherwise FALSE.
protected ignore ( array | integer | string $expectedTokens ) : boolean
$expectedTokens array | integer | string
리턴 boolean

lookahead() 보호된 메소드

This method tries to match the current token stream at the provided lookahead position against all of the provided tokens. If a match is found it simply returned. The token stream remains unchanged. If no match can be found a PhpCssParserException will thrown indicating what has been expected and what was found. The $expectedTokens parameter may be an array of tokens or a scalar value, which is handled the same way an array with only one entry would be. The special Token Scanner\Token::ANY may be used to indicate everything is valid and may be matched. However if it is used no other token may be specified, which does not make any sense, anyway. The position parameter may be provided to enforce a match on an arbitrary token stream position. Therefore unlimited lookahead is provided.
protected lookahead ( array | integer | string $expectedTokens, integer $position, boolean $allowEndOfTokens = FALSE ) : Token | null
$expectedTokens array | integer | string
$position integer
$allowEndOfTokens boolean
리턴 PhpCss\Scanner\Token | null

matchToken() 보호된 메소드

Returns true if the token at the given position exists and the provided token type matches type of the token at this position, false otherwise.
protected matchToken ( integer $position, integer $type ) : boolean
$position integer
$type integer
리턴 boolean

parse() 추상적인 공개 메소드

This method is supposed to handle all the steps needed to parse the current subsegment of the token stream. It is supposed to return a valid PhpCssAst. If the parsing process can't be completed because of invalid input a PhpCssParserException needs to be thrown. The methods protected methods read and lookahead should be used to operate on the token stream. They will throw PhpCssParserExceptions automatically in case they do not succeed.
abstract public parse ( ) : Ast
리턴 Ast

read() 보호된 메소드

This method tries to match the current token list against all of the provided tokens. If a match is found it is removed from the token list and returned. If no match can be found a PhpCssParserException will thrown indicating what has been expected and what was found. The $expectedTokens parameter may be an array of tokens or a scalar value, which is handled the same way an array with only one entry would be. The special Token Scanner\Token::ANY may be used to indicate everything is valid and may be matched. However if it is used no other token may be specified, which does not make any sense, anyway.
protected read ( array | integer | string $expectedTokens ) : Token
$expectedTokens array | integer | string
리턴 PhpCss\Scanner\Token

프로퍼티 상세

$_tokens 보호되어 있는 프로퍼티

List of tokens from scanner
protected array(Scanner\Token) $_tokens
리턴 array(Scanner\Token)