src/antlr3exception.c(3)

πŸ“¦ version 3.4, in fedora 43

πŸ’– 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 the ANTLR3_xxx_EXCEPTION indicators such as ANTLR3_RECOGNITION_EXCEPTION
  • message β€” Pointer to message string
  • freeMessage β€” Set to ANTLR3_TRUE if the message parameter should be freed by a call to ANTLR3_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