RParser
class RParser (View source)
Constants
ACTION_ERROR |
|
ACTION_SHIFT |
|
ACTION_REDUCE |
|
ACTION_GOTO |
|
ACTION_ACCEPT |
|
ERROR_SYNTAX |
|
ERROR_NON_ASSOCIATIVE |
|
ERROR_UNKNOWN_TOKEN |
|
Properties
int | $action | ||
int | $reduceId |
Methods
Process next parser rule.
Finalize the grammar rules
Dump the current grammar to stdout.
Retrieve the error information in case Parle\RParser::action() returned the error action.
Declare a terminal with left associativity.
Declare a token with no associativity
Declare a precedence rule
Push a grammar rule.
Reset parser state using the given token id.
Declare a token with right-associativity
Retrieve a matching part of a rule
Declare a token
Get token id
Trace the parser operation
Details
void
advance()
Process next parser rule.
void
build()
Finalize the grammar rules
Any tokens and grammar rules previously added are finalized. The rule set becomes readonly and the parser is ready to start.
void
consume(string $data, Lexer $lexer)
Consume the data for parsing.
void
dump()
Dump the current grammar to stdout.
ErrorInfo
errorInfo()
Retrieve the error information in case Parle\RParser::action() returned the error action.
void
left(string $token)
Declare a terminal with left associativity.
void
nonassoc(string $token)
Declare a token with no associativity
Declare a terminal, that cannot appear more than once in the row.
void
precedence(string $token)
Declare a precedence rule
Declares a precedence rule for a fictitious terminal symbol. This rule can be later used in the specific grammar rules.
int
push(string $name, string $rule)
Push a grammar rule.
The production id returned can be used later in the parsing process to identify the rule matched.
void
reset(int $tokenId)
Reset parser state using the given token id.
void
right(string $token)
Declare a token with right-associativity
string
sigil(int $idx)
Retrieve a matching part of a rule
Retrieve a part of the match by a rule. This method is equivalent to the pseudo variable functionality in Bison.
void
token(string $token)
Declare a token
Declare a terminal to be used in the grammar.
int
tokenId(string $token)
Get token id
Retrieve the id of the named token.
string
trace()
Trace the parser operation
Retrieve the current parser operation description. This can be especially useful for studying the parser and to optimize the grammar.
bool
validate(string $data, RLexer $lexer)
Validate an input string.
The string is parsed internally, thus this method is useful for the quick input validation.