parser

parser

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

Source:
Tutorials:

Methods

error()

handling errors

Source:

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
Source:
Throws:

Error

expectEndOfStatement() → {boolean}

expects an end of statement or end of file

Source:

getTokenName()

helper : gets a token name

Source:

is()

Check if token is of specified type

Source:

lex()

Eating a token

Source:

next()

consume the next token

Source:

node()

Creates a new AST node

Source:

parse()

main entry point : converts a source code to AST

Source:

raiseError()

Raise an error

Source:

text() → {String}

Returns the current token contents

Source: