« Prev 4.11 Specifying the generated API prefix - the prefix statement | Table of Contents | Next » 5 Propane generated API |
Propane supports allowing parser user code blocks to terminate execution of the parser. One example use of this functionality is to detect and report an error before the parser continues parsing the remainder of the input. Another use of this features is to begin parsing input and determine whether a different parser should be used instead.
To terminate parsing from a parser user code block, use the $terminate(code)
function, passing an integer expression argument.
For example:
NewExpression -> new Expression << $terminate(42); >>
The value passed to the $terminate()
function is known as the "user terminate
code".
If the parser returns a P_USER_TERMINATED
result code, then the user
terminate code can be accessed using the p_user_terminate_code()
API
function.
« Prev 4.11 Specifying the generated API prefix - the prefix statement | Table of Contents | Next » 5 Propane generated API |