src/antlr3exception.c(3)
π src/antlr3exception.c β the ANTLR3C exception handler girlies π
okay bestie, so this is src/antlr3exception.c, a page from the ANTLR3C manual, and it's literally the file that holds the default functions for creating, destroying, and otherwise handling ANTLR3 standard exception structures. it's giving "the emotional support subsystem of your parser." π«Ά
β¨ SYNOPSIS β¨
#include <antlr3exception.h>
πΈ Functions
static void antlr3ExceptionFree (pANTLR3_EXCEPTION ex)β Frees up a chain of ANTLR3 exceptions. bye bye bestie πpANTLR3_EXCEPTION antlr3ExceptionNew (ANTLR3_UINT32 exception, void *name, void *message, ANTLR3_BOOLEAN freeMessage)β Creates a new ANTLR3 exception structure. new exception just dropped β¨static void antlr3ExceptionPrint (pANTLR3_EXCEPTION ex)β Prints out the message in all the exceptions in the supplied chain. say it out loud, no secrets π
π Detailed Description π
Contains default functions for creating and destroying as well as otherwise handling ANTLR3 standard exception structures.
that's it, that's the whole vibe. it's the boilerplate bestie that keeps your exceptions from just... evaporating into the void. π
π Function Documentation π
π void antlr3ExceptionFree (pANTLR3_EXCEPTION ex) [static]
Frees up a chain of ANTLR3 exceptions. like, the whole chain. every single one. no stragglers. it's a clean sweep, a whole reset, main character spring cleaning. π§Ήβ¨
Parameters
exβ Pointer to the first exception in the chain to free. (start here, it walks the rest itself, she's independent π )
See also
ANTLR3_EXCEPTION
References
ANTLR3_TRUE, ANTLR3_EXCEPTION_struct::custom, ANTLR3_EXCEPTION_struct::freeCustom, ANTLR3_EXCEPTION_struct::freeMessage, ANTLR3_EXCEPTION_struct::message, next(), and ANTLR3_EXCEPTION_struct::nextException.
Referenced by
antlr3ExceptionNew()
π¦ pANTLR3_EXCEPTION antlr3ExceptionNew (ANTLR3_UINT32 exception, void * name, void * message, ANTLR3_BOOLEAN freeMessage)
Creates a new ANTLR3 exception structure. brand new, fresh out the box, no notes. π
Parameters
exceptionβ One of theANTLR3_xxx_EXCEPTIONindicators such asANTLR3_RECOGNITION_EXCEPTIONmessageβ Pointer to message stringfreeMessageβ Set toANTLR3_TRUEif the message parameter should be freed by a call toANTLR3_FREE()when the exception is destroyed.
Returns
Pointer to newly initialized exception structure, or an ANTLR3_ERR_xx defined value upon failure.
Description
An exception is 'thrown' by a recognizer when input is seen that is not predicted by the grammar productions or when some other error condition occurs. In C we do not have the luxury of try and catch blocks, so exceptions are added in the order they occur to a list in the baserecognizer structure. The last one to be thrown is inserted at the head of the list and the one currently installed is pointed to by the newly installed exception.
ngl that's the whole tea β C has no try/catch, so instead of dramatic crash-outs, every exception just gets stacked onto a list in the baserecognizer structure. newest one goes to the front, head of the line, main character energy π, and the newly installed exception points at the one currently installed. it's a little linked-list situationship, iykyk. π₯
Remarks
After an exception is created, you may add a pointer to your own structure and a pointer to a function to free this structure when the exception is destroyed.
so like, you can bring your own custom data AND your own little cleanup function so it gets properly released when the exception dies. very "i brought a plus one and they handle the dishes" of you. π«Ά
See also
ANTLR3_EXCEPTION
References
antlr3ExceptionFree(), antlr3ExceptionPrint(), ANTLR3_EXCEPTION_struct::freeEx, ANTLR3_EXCEPTION_struct::freeMessage, ANTLR3_EXCEPTION_struct::message, ANTLR3_EXCEPTION_struct::name, ANTLR3_EXCEPTION_struct::print, and ANTLR3_EXCEPTION_struct::type.
Referenced by
antlr3RecognitionExceptionNew()
π void antlr3ExceptionPrint (pANTLR3_EXCEPTION ex) [static]
Prints out the message in all the exceptions in the supplied chain. not just one β all of them. the whole chain gets its moment to speak. π£οΈβ¨
Parameters
exβ Pointer to the exception structure to print.
Remarks
You may wish to override this function by installing a pointer to a new function in the base recognizer context structure.
basically: if the default print vibe isn't hitting, you can swap in your own function pointer and make it yours. glow-up privileges unlocked. π
See also
ANTLR3_BASE_RECOGNIZER
References
ANTLR3_EXCEPTION_struct::message, ANTLR3_EXCEPTION_struct::nextException, and ANTLR3_EXCEPTION_struct::type.
Referenced by
antlr3ExceptionNew()
π Author π
Generated automatically by Doxygen for ANTLR3C from the source code.
(not a human author, just doxygen doing its lil autopilot thing β iconic behaviour honestly π€β¨)
okay so that's the whole page bestie!! and for the cute lil sign-off: this is Version 3.3.1, dated Tue Jul 29 2025 00:00:00, and it lives at src/antlr3exception.c(3) β that footer info is the whole reason this page even has a source and a version, so shoutout to her. ππ¦π periodt.
π¦ where this page comes from
- fedora 43: antlr3-C-devel 1:3.4-3.5.3.14.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms