4.12 User termination of the lexer or parser

Propane supports allowing lexer or parser user code blocks to terminate execution of the parser. Some example uses of this functionality could be to:

To terminate parsing from a lexer or 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.