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.
#include <antlr3commontreeadaptor.h>
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_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_TOKEN_FACTORY_struct::input, ANTLR3_COMMON_TOKEN_struct::input, ANTLR3_TOKEN_FACTORY_struct::newToken, 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, ANTLR3_TOKEN_FACTORY_struct::newToken, 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_TOKEN_FACTORY_struct::close, ANTLR3_ARBORETUM_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, ANTLR3_DEBUG_EVENT_LISTENER_struct::setTokenBoundaries, and 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.
static pANTLR3_BASE_TREE dupNode | ( | pANTLR3_BASE_TREE_ADAPTOR | adaptor, | |
pANTLR3_BASE_TREE | treeNode | |||
) | [static] |
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().
static pANTLR3_BASE_TREE getChild | ( | pANTLR3_BASE_TREE_ADAPTOR | adaptor, | |
pANTLR3_BASE_TREE | t, | |||
ANTLR3_UINT32 | i | |||
) | [static] |
References ANTLR3_BASE_TREE_struct::getChild.
static ANTLR3_UINT32 getChildCount | ( | pANTLR3_BASE_TREE_ADAPTOR | adaptor, | |
pANTLR3_BASE_TREE | t | |||
) | [static] |
References ANTLR3_BASE_TREE_struct::getChildCount.
static ANTLR3_INT32 getChildIndex | ( | pANTLR3_BASE_TREE_ADAPTOR | adaptor, | |
pANTLR3_BASE_TREE | t | |||
) | [static] |
References ANTLR3_BASE_TREE_struct::getChildIndex.
static pANTLR3_BASE_TREE getParent | ( | pANTLR3_BASE_TREE_ADAPTOR | adaptor, | |
pANTLR3_BASE_TREE | child | |||
) | [static] |
References ANTLR3_BASE_TREE_struct::getParent.
static pANTLR3_STRING getText | ( | pANTLR3_BASE_TREE_ADAPTOR | adaptor, | |
pANTLR3_BASE_TREE | t | |||
) | [static] |
References ANTLR3_BASE_TREE_struct::getText.
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.
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.
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.
static void setChildIndex | ( | pANTLR3_BASE_TREE_ADAPTOR | adaptor, | |
pANTLR3_BASE_TREE | t, | |||
ANTLR3_INT32 | i | |||
) | [static] |
References ANTLR3_BASE_TREE_struct::setChildIndex.
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.
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(), antlr3DebugListenerNew(), and dbgSetTokenBoundaries().