src/antlr3commontreeadaptor.c(3)
π src/antlr3commontreeadaptor.c π
okay so bestie, this is the ANTLR3C manual page for src/antlr3commontreeadaptor.c, and it's literally the standard tree adaptor the C runtime uses unless your grammar source file says otherwise. periodt. π
β¨ NAME β¨
src/antlr3commontreeadaptor.c β This is the standard tree adaptor used by the C runtime unless the grammar source file says to use anything different.
No cap, that's the whole vibe.
πΈ SYNOPSIS πΈ
#include <antlr3commontreeadaptor.h>
π«Ά Functions π«Ά
Here's the function lineup, every single one, exactly as written, because we do not skip. π¦
ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORDebugNew (pANTLR3_STRING_FACTORY strFactory, pANTLR3_DEBUG_EVENT_LISTENER debugger)β Debug version of the tree adaptor. Lowkey you won't call this yourself, because generated code callssetDebugEventListenerinstead β that swaps a normal token stream to a debugging stream, so your instantiation code stays exactly the same when you just wanna debug with AW.ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORNew (pANTLR3_STRING_FACTORY strFactory)β Creates a brand-new tree adaptor. slay.static pANTLR3_BASE_TREE create (pANTLR3_BASE_TREE_ADAPTOR adpator, pANTLR3_COMMON_TOKEN payload)static pANTLR3_COMMON_TOKEN createToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_UINT8 text)β Tells you how to create a token for use with imaginary token nodes. iykyk.static pANTLR3_COMMON_TOKEN createTokenFromToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_COMMON_TOKEN fromToken)β Also tells you how to create a token for use with imaginary token nodes, but starting from another token.static void ctaFree (pANTLR3_BASE_TREE_ADAPTOR adaptor)static pANTLR3_BASE_TREE dbgCreate (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_COMMON_TOKEN payload)static void dbgSetTokenBoundaries (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_COMMON_TOKEN startToken, pANTLR3_COMMON_TOKEN stopToken)static void deleteChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_UINT32 i)static pANTLR3_BASE_TREE dupNode (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE treeNode)β Duplicates the node you hand over. πstatic pANTLR3_BASE_TREE errorNode (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_TOKEN_STREAM ctnstream, pANTLR3_COMMON_TOKEN startToken, pANTLR3_COMMON_TOKEN stopToken, pANTLR3_EXCEPTION e)static pANTLR3_BASE_TREE getChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_UINT32 i)static ANTLR3_UINT32 getChildCount (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)static ANTLR3_INT32 getChildIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)static pANTLR3_BASE_TREE getParent (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE child)static pANTLR3_STRING getText (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)static pANTLR3_COMMON_TOKEN getToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)static ANTLR3_MARKER getTokenStartIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)static ANTLR3_MARKER getTokenStopIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)static ANTLR3_UINT32 getType (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)static void replaceChildren (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE parent, ANTLR3_INT32 startChildIndex, ANTLR3_INT32 stopChildIndex, pANTLR3_BASE_TREE t)static void setChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_UINT32 i, pANTLR3_BASE_TREE child)static void setChildIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_INT32 i)static void setDebugEventListener (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_DEBUG_EVENT_LISTENER debugger)β Turns an existing common tree adaptor into a debug version. glow-up.static void setParent (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE child, pANTLR3_BASE_TREE parent)static void setTokenBoundaries (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_COMMON_TOKEN startToken, pANTLR3_COMMON_TOKEN stopToken)β Tracks the start/stop token for the subtree root created for a rule.
π₯ Detailed Description π₯
This is the standard tree adaptor used by the C runtime unless the grammar source file says to use anything different.
It embeds a BASE_TREE to which it adds its own implementation of anything that the base tree is not good for, plus a number of methods that any other adaptor type needs to implement too.
β¨ FUNCTION DOCUMENTATION β¨
Okay bestie, this is the part where we meet every single function in this file. Buckle up, hydrate, and let's gooo π
ANTLR3_TREE_ADAPTORDebugNew</p>
ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORDebugNew
(pANTLR3_STRING_FACTORY strFactory, pANTLR3_DEBUG_EVENT_LISTENER
debugger)
This is the debugging version of the tree adaptor, and like β not normally called, because generated code calls setDebugEventListener instead. That swap turns a normal token stream into a debugging stream, which means the user's instantiation code doesn't need to be touched at all just to debug with AW. Iconic, lowkey.
References: ANTLR3_TREE_ADAPTORNew(), antlr3BaseTreeAdaptorInit(), ANTLR3_BASE_TREE_ADAPTOR_struct::create, dbgCreate(), dbgSetTokenBoundaries(), and ANTLR3_BASE_TREE_ADAPTOR_struct::setTokenBoundaries.
Referenced by: ANTLR3_TREE_ADAPTORDebugNew(), and antlr3CommonTreeNodeStreamNew().
ANTLR3_TREE_ADAPTORNew
ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORNew
(pANTLR3_STRING_FACTORY strFactory)
Create a new tree adaptor, bestie π±. And here's the plot twist β even though this is creating a new COMMON_TREE adaptor, we return the address of the BASE_TREE interface, because any other adaptor that wants to be used as the tree element of a tree parse/build has to do the same. It needs the address of a valid string factory handed to it, since we have no idea what the originating input stream's encoding type was. That way we can just lean on the original input stream's string factory, or whichever correctly-typed one the user supplies us. Trust the process π
.
References: antlr3ArboretumNew(), antlr3BaseTreeAdaptorInit(), antlr3TokenFactoryNew(), ANTLR3_COMMON_TREE_ADAPTOR_struct::arboretum, ANTLR3_COMMON_TREE_ADAPTOR_struct::baseAdaptor, ANTLR3_BASE_TREE_ADAPTOR_struct::create, create(), ANTLR3_BASE_TREE_ADAPTOR_struct::createToken, createToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::createTokenFromToken, createTokenFromToken(), ctaFree(), ANTLR3_BASE_TREE_ADAPTOR_struct::deleteChild, deleteChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::dupNode, dupNode(), ANTLR3_BASE_TREE_ADAPTOR_struct::errorNode, errorNode(), ANTLR3_BASE_TREE_ADAPTOR_struct::free, ANTLR3_BASE_TREE_ADAPTOR_struct::getChild, getChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::getChildCount, getChildCount(), ANTLR3_BASE_TREE_ADAPTOR_struct::getChildIndex, getChildIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::getParent, getParent(), ANTLR3_BASE_TREE_ADAPTOR_struct::getText, getText(), ANTLR3_BASE_TREE_ADAPTOR_struct::getTokenStartIndex, getTokenStartIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::getTokenStopIndex, getTokenStopIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::getType, getType(), ANTLR3_BASE_TREE_ADAPTOR_struct::replaceChildren, replaceChildren(), ANTLR3_BASE_TREE_ADAPTOR_struct::setChild, setChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::setChildIndex, setChildIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::setDebugEventListener, setDebugEventListener(), ANTLR3_BASE_TREE_ADAPTOR_struct::setParent, setParent(), ANTLR3_BASE_TREE_ADAPTOR_struct::setTokenBoundaries, setTokenBoundaries(), ANTLR3_BASE_TREE_ADAPTOR_struct::strFactory, ANTLR3_COMMON_TOKEN_struct::strFactory, ANTLR3_BASE_TREE_ADAPTOR_struct::super, ANTLR3_BASE_TREE_ADAPTOR_struct::tokenFactory, and ANTLR3_TOKEN_FACTORY_struct::unTruc.
Referenced by: ANTLR3_TREE_ADAPTORDebugNew(), and antlr3CommonTreeNodeStreamNew().
create (static)
pANTLR3_BASE_TREE create (pANTLR3_BASE_TREE_ADAPTOR adpator,
pANTLR3_COMMON_TOKEN payload) [static]
References: ANTLR3_BASE_TREE_ADAPTOR_struct::super.
Referenced by: ANTLR3_TREE_ADAPTORNew(), and dbgCreate().
createToken (static)
pANTLR3_COMMON_TOKEN createToken (pANTLR3_BASE_TREE_ADAPTOR adaptor,
ANTLR3_UINT32 tokenType, pANTLR3_UINT8 text) [static]
So like β tell me how to create a token for use with imaginary token nodes π§. For example, there's probably no input symbol associated with imaginary token DECL, but you need to create it as a payload or whatever for the DECL node, as in ^(DECL type ID).
If you care what the token payload objects' type is, you should override this method and any other createToken variant. Periodt.
References: ANTLR3_TEXT_CHARP, ANTLR3_TOKEN_FACTORY_struct::input, ANTLR3_TOKEN_FACTORY_struct::newToken, newToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::strFactory, and ANTLR3_BASE_TREE_ADAPTOR_struct::tokenFactory.
Referenced by: ANTLR3_TREE_ADAPTORNew().
createTokenFromToken (static)
pANTLR3_COMMON_TOKEN createTokenFromToken (pANTLR3_BASE_TREE_ADAPTOR
adaptor, pANTLR3_COMMON_TOKEN fromToken) [static]
Again with the imaginary token nodes β tell me how to create a token for use with them π«. Like, there's probably no input symbol associated with imaginary token DECL, but you gotta create it as a payload or whatever for the DECL node, as in ^(DECL type ID).
This one is a variant of createToken where the new token is derived from an actual real input token. Typically this is for converting '{' tokens to BLOCK etc... You'll see:
r : lc='{' ID+ '}' -> ^(BLOCK[$lc] ID+) ;
If you care what the token payload objects' type is, you should override this method and any other createToken variant.
NB: this being C, it is not so easy to extend the types of creaeteToken. We will have to see if anyone needs to do this and add any variants to this interface. (yes bestie, that typo is in the original, we do not fix it, we respect the lore π«‘)
References: ANTLR3_TEXT_CHARP, ANTLR3_TEXT_STRING, ANTLR3_COMMON_TOKEN_struct::chars, ANTLR3_STRING_struct::chars, ANTLR3_COMMON_TOKEN_struct::getChannel, ANTLR3_COMMON_TOKEN_struct::getCharPositionInLine, ANTLR3_COMMON_TOKEN_struct::getLine, ANTLR3_COMMON_TOKEN_struct::getText, ANTLR3_COMMON_TOKEN_struct::getTokenIndex, ANTLR3_COMMON_TOKEN_struct::getType, ANTLR3_STRING_struct::len, ANTLR3_STRING_FACTORY_struct::newPtr, ANTLR3_TOKEN_FACTORY_struct::newToken, newToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::strFactory, ANTLR3_COMMON_TOKEN_struct::textState, ANTLR3_BASE_TREE_ADAPTOR_struct::tokenFactory, ANTLR3_COMMON_TOKEN_struct::tokText, and ANTLR3_COMMON_TOKEN_struct::toString.
Referenced by: ANTLR3_TREE_ADAPTORNew().
ctaFree (static)
void ctaFree (pANTLR3_BASE_TREE_ADAPTOR adaptor) [static]
References: ANTLR3_COMMON_TREE_ADAPTOR_struct::arboretum, ANTLR3_ARBORETUM_struct::close, ANTLR3_TOKEN_FACTORY_struct::close, ANTLR3_BASE_TREE_ADAPTOR_struct::super, and ANTLR3_BASE_TREE_ADAPTOR_struct::tokenFactory.
Referenced by: ANTLR3_TREE_ADAPTORNew().
dbgCreate (static)
pANTLR3_BASE_TREE dbgCreate (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_COMMON_TOKEN payload) [static]
References: create(), ANTLR3_DEBUG_EVENT_LISTENER_struct::createNode, and ANTLR3_BASE_TREE_ADAPTOR_struct::debugger.
Referenced by: ANTLR3_TREE_ADAPTORDebugNew(), and setDebugEventListener().
dbgSetTokenBoundaries (static)
void dbgSetTokenBoundaries (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t, pANTLR3_COMMON_TOKEN startToken,
pANTLR3_COMMON_TOKEN stopToken) [static]
References: ANTLR3_BASE_TREE_ADAPTOR_struct::debugger, ANTLR3_COMMON_TOKEN_struct::getTokenIndex, ANTLR3_DEBUG_EVENT_LISTENER_struct::setTokenBoundaries, and setTokenBoundaries().
Referenced by: ANTLR3_TREE_ADAPTORDebugNew(), and setDebugEventListener().
deleteChild (static)
void deleteChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t,
ANTLR3_UINT32 i) [static]
References: ANTLR3_BASE_TREE_struct::deleteChild.
dupNode (static)
pANTLR3_BASE_TREE dupNode (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE treeNode) [static]
Duplicate the supplied node, bestie π. Copy that vibe.
References: ANTLR3_BASE_TREE_struct::dupNode.
errorNode (static)
pANTLR3_BASE_TREE errorNode (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_TOKEN_STREAM ctnstream, pANTLR3_COMMON_TOKEN startToken,
pANTLR3_COMMON_TOKEN stopToken, pANTLR3_EXCEPTION e) [static]
References: ANTLR3_TOKEN_INVALID, and ANTLR3_BASE_TREE_ADAPTOR_struct::createTypeText.
Referenced by: ANTLR3_TREE_ADAPTORNew(), and antlr3DebugListenerNew().
getChild (static)
pANTLR3_BASE_TREE getChild (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t, ANTLR3_UINT32 i) [static]
References: ANTLR3_BASE_TREE_struct::getChild.
getChildCount (static)
ANTLR3_UINT32 getChildCount (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t) [static]
References: ANTLR3_BASE_TREE_struct::getChildCount.
getChildIndex (static)
ANTLR3_INT32 getChildIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t) [static]
References: ANTLR3_BASE_TREE_struct::getChildIndex.
getParent (static)
pANTLR3_BASE_TREE getParent (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE child) [static]
References: ANTLR3_BASE_TREE_struct::getParent.
getText (static)
pANTLR3_STRING getText (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE
t) [static]
References: ANTLR3_BASE_TREE_struct::getText.
getToken (static)
pANTLR3_COMMON_TOKEN getToken (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t) [static]
References: ANTLR3_API.
getTokenStartIndex (static)
ANTLR3_MARKER getTokenStartIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t) [static]
References: ANTLR3_BASE_TREE_struct::super.
Referenced by: ANTLR3_TREE_ADAPTORNew().
getTokenStopIndex (static)
ANTLR3_MARKER getTokenStopIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t) [static]
References: ANTLR3_BASE_TREE_struct::super.
Referenced by: ANTLR3_TREE_ADAPTORNew().
getType (static)
ANTLR3_UINT32 getType (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE
t) [static]
References: ANTLR3_BASE_TREE_struct::getType.
replaceChildren (static)
void replaceChildren (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE
parent, ANTLR3_INT32 startChildIndex, ANTLR3_INT32 stopChildIndex,
pANTLR3_BASE_TREE t) [static]
References: ANTLR3_BASE_TREE_struct::replaceChildren.
setChild (static)
void setChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t,
ANTLR3_UINT32 i, pANTLR3_BASE_TREE child) [static]
References: ANTLR3_BASE_TREE_struct::setChild.
setChildIndex (static)
void setChildIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t,
ANTLR3_INT32 i) [static]
References: ANTLR3_BASE_TREE_struct::setChildIndex.
setDebugEventListener (static)
void setDebugEventListener (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_DEBUG_EVENT_LISTENER debugger) [static]
Causes an existing common tree adaptor to become a debug version π±β¨. Glow-up era.
References: antlr3BaseTreeAdaptorInit(), ANTLR3_BASE_TREE_ADAPTOR_struct::create, dbgCreate(), dbgSetTokenBoundaries(), and ANTLR3_BASE_TREE_ADAPTOR_struct::setTokenBoundaries.
Referenced by: ANTLR3_TREE_ADAPTORNew().
setParent (static)
void setParent (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE child,
pANTLR3_BASE_TREE parent) [static]
References: ANTLR3_BASE_TREE_struct::setParent.
setTokenBoundaries (static)
void setTokenBoundaries (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_TREE t, pANTLR3_COMMON_TOKEN startToken,
pANTLR3_COMMON_TOKEN stopToken) [static]
Track start/stop token for subtree root created for a rule. Only works with CommonTree nodes. For rules that match nothing, seems like this will yield start=i and stop=i-1 in a nil node. Might be useful info so I'll not force to be i..i. Slay, honestly π.
References: ANTLR3_COMMON_TOKEN_struct::getTokenIndex, ANTLR3_COMMON_TREE_struct::startIndex, ANTLR3_COMMON_TREE_struct::stopIndex, and ANTLR3_BASE_TREE_struct::super.
Referenced by: ANTLR3_TREE_ADAPTORNew(), antlr3DebugListenerNew(), and dbgSetTokenBoundaries().
πΈ AUTHOR πΈ
Generated automatically by Doxygen for ANTLR3C from the source code. Yeah bestie, the robots wrote this one, no human author hand-crafted it β it's giving auto-generated and honestly? It ate π β¨
And that's a wrap on the whole page, fr fr π«Ά Version3.3.1, datedTue Jul 29 2025, fromsrc/antlr3commontreeadaptor.cβ you made it to the end, so go drink some water, you absolute icon ππ
π¦ 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