![]() |
They correspond (roughly) to the Java runtime system classes and contain all the data elements for a particular interface as well as all the pointers to functions that implement these interfaces.
There are constructor functions exported from the C runtime, which you use to create a default implementation of one of these 'classes'. You can then override any part of the implementation by installing your own function pointers, before using the interface 'object' you have created.
For instance, you can override the default error message reporting function by replacing the standard (example) implementation of this function with your own. In your grammar, you would place the following
@parser::apifuncs { // Install custom error message display // RECOGNIZER->displayRecognitionError = produceError; }
The special section apiFuncs is guaranteed to be generated after the RECONGIZER 'object' has already be created and initialized, so you may install your own implementations of the ANTLR3_BASE_RECOGNIZER interface functions. The error display function is likely to be the only one you are interested in replacing.
Some typedef structures contain either pointers to 'inherited' objects (usual) or embedded structures/typedefs (unusual). In some cases, the pointers passed around by the paresr or tree parser are actually the pointers to these embedded structures (such as pANTLR3_BASE_TREE), and these embedded 'objects' contain pointers to their encapsulating objects. This is the equivalent of passing interface objects around in object oriented languages.
typedef struct ANTLR3_INPUT_STREAM_struct ANTLR3_INPUT_STREAM |