antlr3commontreeadaptor.c man page

src/antlr3commontreeadaptor.c — This is the standard tree adaptor used by the C runtime unless the grammar source file says to use anything different.

Synopsis

#include <antlr3commontreeadaptor.h>

Functions

ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORDebugNew (pANTLR3_STRING_FACTORY strFactory, pANTLR3_DEBUG_EVENT_LISTENER debugger)
Debugging version of the tree adaptor (not normally called as generated code calls setDebugEventListener instead which changes a normal token stream to a debugging stream and means that a user's instantiation code does not need to be changed just to debug with AW.
ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORNew (pANTLR3_STRING_FACTORY strFactory)
Create a new tree adaptor.
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)
Tell me how to create a token for use with imaginary token nodes.
static pANTLR3_COMMON_TOKEN createTokenFromToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_COMMON_TOKEN fromToken)
Tell me how to create a token for use with imaginary token nodes.
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)
Duplicate the supplied node.
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)
Causes an existing common tree adaptor to become a debug version.
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)
Track start/stop token for 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

ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORDebugNew (pANTLR3_STRING_FACTORY strFactory, pANTLR3_DEBUG_EVENT_LISTENER debugger)

Debugging version of the tree adaptor (not normally called as generated code calls setDebugEventListener instead which changes a normal token stream to a debugging stream and means that a user's instantiation code does not need to be changed just to debug with AW.

References ANTLR3_TREE_ADAPTORNew(), antlr3BaseTreeAdaptorInit(), ANTLR3_BASE_TREE_ADAPTOR_struct::create, dbgCreate(), dbgSetTokenBoundaries(), and ANTLR3_BASE_TREE_ADAPTOR_struct::setTokenBoundaries.

ANTLR3_API pANTLR3_BASE_TREE_ADAPTOR ANTLR3_TREE_ADAPTORNew (pANTLR3_STRING_FACTORY strFactory)

Create a new tree adaptor. Note that despite the fact that this is creating a new COMMON_TREE adaptor, we return the address of the BASE_TREE interface, as should any other adaptor that wishes to be used as the tree element of a tree parse/build. It needs to be given the address of a valid string factory as we do not know what the originating input stream encoding type was. This way we can rely on just using the original input stream's string factory or one of the correct type which the user supplies us.

References ANTLR3_API, ANTLR3_MALLOC, antlr3ArboretumNew(), antlr3BaseTreeAdaptorInit(), antlr3TokenFactoryNew(), ANTLR3_COMMON_TREE_ADAPTOR_struct::arboretum, ANTLR3_COMMON_TREE_ADAPTOR_struct::baseAdaptor, create(), ANTLR3_BASE_TREE_ADAPTOR_struct::create, createToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::createToken, createTokenFromToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::createTokenFromToken, ctaFree(), deleteChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::deleteChild, dupNode(), ANTLR3_BASE_TREE_ADAPTOR_struct::dupNode, errorNode(), ANTLR3_BASE_TREE_ADAPTOR_struct::errorNode, ANTLR3_BASE_TREE_ADAPTOR_struct::free, getChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::getChild, getChildCount(), ANTLR3_BASE_TREE_ADAPTOR_struct::getChildCount, getChildIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::getChildIndex, getParent(), ANTLR3_BASE_TREE_ADAPTOR_struct::getParent, getText(), ANTLR3_BASE_TREE_ADAPTOR_struct::getText, getTokenStartIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::getTokenStartIndex, getTokenStopIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::getTokenStopIndex, getType(), ANTLR3_BASE_TREE_ADAPTOR_struct::getType, replaceChildren(), ANTLR3_BASE_TREE_ADAPTOR_struct::replaceChildren, setChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::setChild, setChildIndex(), ANTLR3_BASE_TREE_ADAPTOR_struct::setChildIndex, setDebugEventListener(), ANTLR3_BASE_TREE_ADAPTOR_struct::setDebugEventListener, setParent(), ANTLR3_BASE_TREE_ADAPTOR_struct::setParent, setTokenBoundaries(), ANTLR3_BASE_TREE_ADAPTOR_struct::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().

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().

static pANTLR3_COMMON_TOKEN createToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_UINT8 text) [static]

Tell me how to create a token for use with imaginary token nodes. For example, there is 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.

References ANTLR3_TEXT_CHARP, ANTLR3_COMMON_TOKEN_struct::chars, ANTLR3_COMMON_TOKEN_struct::input, ANTLR3_TOKEN_FACTORY_struct::input, newToken(), ANTLR3_TOKEN_FACTORY_struct::newToken, ANTLR3_COMMON_TOKEN_struct::setType, ANTLR3_BASE_TREE_ADAPTOR_struct::strFactory, ANTLR3_COMMON_TOKEN_struct::strFactory, ANTLR3_COMMON_TOKEN_struct::textState, ANTLR3_BASE_TREE_ADAPTOR_struct::tokenFactory, and ANTLR3_COMMON_TOKEN_struct::tokText.

Referenced by ANTLR3_TREE_ADAPTORNew().

static pANTLR3_COMMON_TOKEN createTokenFromToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_COMMON_TOKEN fromToken) [static]

Tell me how to create a token for use with imaginary token nodes. For example, there is 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).

This 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.

References ANTLR3_TEXT_CHARP, ANTLR3_TEXT_STRING, ANTLR3_STRING_struct::chars, ANTLR3_COMMON_TOKEN_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, newToken(), ANTLR3_TOKEN_FACTORY_struct::newToken, ANTLR3_COMMON_TOKEN_struct::setChannel, ANTLR3_COMMON_TOKEN_struct::setCharPositionInLine, ANTLR3_COMMON_TOKEN_struct::setLine, ANTLR3_COMMON_TOKEN_struct::setTokenIndex, ANTLR3_COMMON_TOKEN_struct::setType, ANTLR3_BASE_TREE_ADAPTOR_struct::strFactory, ANTLR3_COMMON_TOKEN_struct::text, 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().

static void ctaFree (pANTLR3_BASE_TREE_ADAPTOR adaptor) [static]

References ANTLR3_FREE, 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().

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().

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, setTokenBoundaries(), and ANTLR3_DEBUG_EVENT_LISTENER_struct::setTokenBoundaries.

Referenced by ANTLR3_TREE_ADAPTORDebugNew(), and setDebugEventListener().

static void deleteChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_UINT32 i) [static]

References ANTLR3_BASE_TREE_struct::deleteChild.

Referenced by ANTLR3_TREE_ADAPTORNew().

static pANTLR3_BASE_TREE dupNode (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE treeNode) [static]

Duplicate the supplied node.

References ANTLR3_BASE_TREE_struct::dupNode.

Referenced by ANTLR3_TREE_ADAPTORNew().

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().

static pANTLR3_BASE_TREE getChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_UINT32 i) [static]

References ANTLR3_BASE_TREE_struct::getChild.

Referenced by ANTLR3_TREE_ADAPTORNew().

static ANTLR3_UINT32 getChildCount (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t) [static]

References ANTLR3_BASE_TREE_struct::getChildCount.

Referenced by ANTLR3_TREE_ADAPTORNew().

static ANTLR3_INT32 getChildIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t) [static]

References ANTLR3_BASE_TREE_struct::getChildIndex.

Referenced by ANTLR3_TREE_ADAPTORNew().

static pANTLR3_BASE_TREE getParent (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE child) [static]

References ANTLR3_BASE_TREE_struct::getParent.

Referenced by ANTLR3_TREE_ADAPTORNew().

static pANTLR3_STRING getText (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t) [static]

References ANTLR3_BASE_TREE_struct::getText.

Referenced by ANTLR3_TREE_ADAPTORNew().

static pANTLR3_COMMON_TOKEN getToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t) [static]

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().

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().

static ANTLR3_UINT32 getType (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t) [static]

References ANTLR3_BASE_TREE_struct::getType, and replaceChildren().

Referenced by ANTLR3_TREE_ADAPTORNew().

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.

Referenced by ANTLR3_TREE_ADAPTORNew(), and getType().

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.

Referenced by ANTLR3_TREE_ADAPTORNew().

static void setChildIndex (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_INT32 i) [static]

References ANTLR3_BASE_TREE_struct::setChildIndex.

Referenced by ANTLR3_TREE_ADAPTORNew().

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.

References antlr3BaseTreeAdaptorInit(), ANTLR3_BASE_TREE_ADAPTOR_struct::create, dbgCreate(), dbgSetTokenBoundaries(), and ANTLR3_BASE_TREE_ADAPTOR_struct::setTokenBoundaries.

Referenced by ANTLR3_TREE_ADAPTORNew().

static void setParent (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE child, pANTLR3_BASE_TREE parent) [static]

References ANTLR3_BASE_TREE_struct::setParent.

Referenced by ANTLR3_TREE_ADAPTORNew().

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.

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(), and dbgSetTokenBoundaries().

Author

Generated automatically by Doxygen for ANTLR3C from the source code.

Referenced By

antlr3-create(3), antlr3-createToken(3), antlr3-createTokenFromToken(3), antlr3-ctaFree(3), antlr3-dbgCreate(3), antlr3-dbgSetTokenBoundaries(3), antlr3-errorNode(3), antlr3-getTokenStartIndex(3), antlr3-getTokenStopIndex(3), antlr3-setDebugEventListener(3) and antlr3-setTokenBoundaries(3) are aliases of antlr3commontreeadaptor.c(3).

Tue Oct 4 2016 Version 3.3.1 ANTLR3C