new parser()
The PHP Parser class that build the AST tree from the lexer
Properties:
| Name | Type | Description |
|---|---|---|
lexer |
Lexer |
current lexer instance |
ast |
AST |
the AST factory instance |
token |
Integer | String |
current token |
extractDoc |
Boolean |
should extract documentation as AST node |
extractTokens |
Boolean |
should extract each token |
suppressErrors |
Boolean |
should ignore parsing errors and continue |
debug |
Boolean |
should output debug informations |
Methods
error()
handling errors
expect(token) → {boolean}
Force the parser to check the current token.
If the current token does not match to expected token, the an error will be raised.
If the suppressError mode is activated, then the error will
be added to the program error stack and this function will return false.
Parameters:
| Name | Type | Description |
|---|---|---|
token |
String | Number |
Throws:
Error
expectEndOfStatement() → {boolean}
expects an end of statement or end of file
getTokenName()
helper : gets a token name
is()
Check if token is of specified type
lex()
Eating a token
next()
consume the next token
node()
Creates a new AST node
parse()
main entry point : converts a source code to AST
raiseError()
Raise an error
text() → {String}
Returns the current token contents