antlr3basetreeadaptor.c File Reference


Detailed Description

Contains the base functions that all tree adaptors start with.

this implementation can then be overridden by any higher implementation.

#include <antlr3basetreeadaptor.h>

Include dependency graph for antlr3basetreeadaptor.c:


Functions

static void addChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_BASE_TREE child)
 Add a child to the tree t.
static void addChildToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_COMMON_TOKEN child)
 Use the adaptor implementation to add a child node with the supplied token.
ANTLR3_API void antlr3BaseTreeAdaptorInit (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_DEBUG_EVENT_LISTENER debugger)
 Given a pointer to a base tree adaptor structure (which is usually embedded in the super class the implements the tree adaptor used in the parse), initialize its function pointers and so on.
static pANTLR3_BASE_TREE becomeRoot (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE newRootTree, pANTLR3_BASE_TREE oldRootTree)
 If oldRoot is a nil root, just copy or move the children to newRoot.
static pANTLR3_BASE_TREE becomeRootToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, void *newRoot, pANTLR3_BASE_TREE oldRoot)
 Use the adaptor interface to set a new tree node with the supplied token to the root of the tree.
static pANTLR3_BASE_TREE createTypeText (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_UINT8 text)
static pANTLR3_BASE_TREE createTypeToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_COMMON_TOKEN fromToken)
 Use the super class supplied create() method to create a new node from the supplied token.
static pANTLR3_BASE_TREE createTypeTokenText (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_COMMON_TOKEN fromToken, pANTLR3_UINT8 text)
static void dbgAddChild (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_BASE_TREE child)
static void dbgAddChildToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_COMMON_TOKEN child)
static pANTLR3_BASE_TREE dbgBecomeRoot (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE newRoot, pANTLR3_BASE_TREE oldRoot)
static pANTLR3_BASE_TREE dbgBecomeRootToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, void *newRoot, pANTLR3_BASE_TREE oldRoot)
static pANTLR3_BASE_TREE dbgCreateTypeText (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_UINT8 text)
static pANTLR3_BASE_TREE dbgCreateTypeToken (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_COMMON_TOKEN fromToken)
static pANTLR3_BASE_TREE dbgCreateTypeTokenText (pANTLR3_BASE_TREE_ADAPTOR adaptor, ANTLR3_UINT32 tokenType, pANTLR3_COMMON_TOKEN fromToken, pANTLR3_UINT8 text)
static pANTLR3_BASE_TREE dbgDupTree (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)
static pANTLR3_BASE_TREE dbgNil (pANTLR3_BASE_TREE_ADAPTOR adaptor)
static void defineDotEdges (pANTLR3_BASE_TREE_ADAPTOR adaptor, void *t, pANTLR3_STRING dotSpec)
static void defineDotNodes (pANTLR3_BASE_TREE_ADAPTOR adaptor, void *t, pANTLR3_STRING dotSpec)
static pANTLR3_BASE_TREE dupTree (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)
 Return a duplicate of the entire tree (implementation provided by the BASE_TREE interface.
static pANTLR3_BASE_TREE dupTreeTT (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_BASE_TREE parent)
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 pANTLR3_STRING getText (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)
 Dummy implementation - will be supplied by super class.
static ANTLR3_UINT32 getType (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)
 Dummy implementation - will be supplied by super class.
static ANTLR3_UINT32 getUniqueID (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE node)
 Returns a uniqueID for the node.
static ANTLR3_BOOLEAN isNilNode (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t)
static pANTLR3_STRING makeDot (pANTLR3_BASE_TREE_ADAPTOR adaptor, void *theTree)
 Produce a DOT specification for graphviz.
static pANTLR3_BASE_TREE nilNode (pANTLR3_BASE_TREE_ADAPTOR adaptor)
 Create and return a nil tree node (no token payload).
static pANTLR3_BASE_TREE rulePostProcessing (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE root)
 Transform ^(nil x) to x.
static void setText (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_STRING t)
 Dummy implementation - will be supplied by super class.
static void setText8 (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_UINT8 t)
 Dummy implementation - will be supplied by super class.
static void setType (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, ANTLR3_UINT32 type)
 Dummy implementation - will be supplied by super class.
static void simulateTreeConstruction (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE tree)
 Sends the required debugging events for duplicating a tree to the debugger.

Function Documentation

static void addChild ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t,
pANTLR3_BASE_TREE  child 
) [static]

Add a child to the tree t.

If child is a flat tree (a list), make all in list children of t. Warning: if t has no children, but child does and child isNilNode then it is ok to move children to t via t.children = child.children; i.e., without copying the array. This is for construction and I'm not sure it's completely general for a tree's addChild method to work this way. Make sure you differentiate between your tree's addChild and this parser tree construction addChild if it's not ok to move children to t with a simple assignment.

References ANTLR3_BASE_TREE_struct::addChild.

static void addChildToken ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t,
pANTLR3_COMMON_TOKEN  child 
) [static]

Use the adaptor implementation to add a child node with the supplied token.

References ANTLR3_BASE_TREE_ADAPTOR_struct::addChild, and ANTLR3_BASE_TREE_ADAPTOR_struct::create.

Referenced by antlr3BaseTreeAdaptorInit().

Here is the caller graph for this function:

ANTLR3_API void antlr3BaseTreeAdaptorInit ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_DEBUG_EVENT_LISTENER  debugger 
)

Given a pointer to a base tree adaptor structure (which is usually embedded in the super class the implements the tree adaptor used in the parse), initialize its function pointers and so on.

References ANTLR3_DEBUG_EVENT_LISTENER_struct::adaptor, addChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::addChild, addChildToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::addChildToken, becomeRoot(), ANTLR3_BASE_TREE_ADAPTOR_struct::becomeRoot, becomeRootToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::becomeRootToken, createTypeText(), ANTLR3_BASE_TREE_ADAPTOR_struct::createTypeText, createTypeToken(), ANTLR3_BASE_TREE_ADAPTOR_struct::createTypeToken, createTypeTokenText(), ANTLR3_BASE_TREE_ADAPTOR_struct::createTypeTokenText, dbgAddChild(), dbgAddChildToken(), dbgBecomeRoot(), dbgBecomeRootToken(), dbgCreateTypeText(), dbgCreateTypeToken(), dbgCreateTypeTokenText(), dbgDupTree(), dbgNil(), dupTree(), ANTLR3_BASE_TREE_ADAPTOR_struct::dupTree, dupTreeTT(), ANTLR3_BASE_TREE_ADAPTOR_struct::dupTreeTT, getChild(), ANTLR3_BASE_TREE_ADAPTOR_struct::getChild, getChildCount(), ANTLR3_BASE_TREE_ADAPTOR_struct::getChildCount, getText(), ANTLR3_BASE_TREE_ADAPTOR_struct::getText, getType(), ANTLR3_BASE_TREE_ADAPTOR_struct::getType, getUniqueID(), ANTLR3_BASE_TREE_ADAPTOR_struct::getUniqueID, isNilNode(), ANTLR3_BASE_TREE_ADAPTOR_struct::isNilNode, makeDot(), ANTLR3_BASE_TREE_ADAPTOR_struct::makeDot, nilNode(), ANTLR3_BASE_TREE_ADAPTOR_struct::nilNode, rulePostProcessing(), ANTLR3_BASE_TREE_ADAPTOR_struct::rulePostProcessing, setText(), ANTLR3_BASE_TREE_ADAPTOR_struct::setText, setText8(), ANTLR3_BASE_TREE_ADAPTOR_struct::setText8, setType(), and ANTLR3_BASE_TREE_ADAPTOR_struct::setType.

Referenced by ANTLR3_TREE_ADAPTORDebugNew(), ANTLR3_TREE_ADAPTORNew(), and setDebugEventListener().

Here is the call graph for this function:

Here is the caller graph for this function:

static pANTLR3_BASE_TREE becomeRoot ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  newRootTree,
pANTLR3_BASE_TREE  oldRootTree 
) [static]

If oldRoot is a nil root, just copy or move the children to newRoot.

If not a nil root, make oldRoot a child of newRoot.

    old=^(nil a b c), new=r yields ^(r a b c)
    old=^(a b c), new=r yields ^(r ^(a b c))

If newRoot is a nil-rooted single child tree, use the single child as the new root node.

    old=^(nil a b c), new=^(nil r) yields ^(r a b c)
    old=^(a b c), new=^(nil r) yields ^(r ^(a b c))

If oldRoot was null, it's ok, just return newRoot (even if isNilNode).

    old=null, new=r yields r
    old=null, new=^(nil r) yields ^(nil r)

Return newRoot. Throw an exception if newRoot is not a simple node or nil root with a single child node--it must be a root node. If newRoot is ^(nil x)</endcode> return x as newRoot.

Be advised that it's ok for newRoot to point at oldRoot's children; i.e., you don't have to copy the list. We are constructing these nodes so we should have this control for efficiency.

References ANTLR3_BASE_TREE_struct::addChild, ANTLR3_FPRINTF, ANTLR3_BASE_TREE_struct::getChild, ANTLR3_BASE_TREE_struct::getChildCount, ANTLR3_BASE_TREE_struct::isNilNode, and ANTLR3_BASE_TREE_struct::reuse.

Referenced by antlr3BaseTreeAdaptorInit(), antlr3DebugListenerNew(), and dbgBecomeRoot().

Here is the caller graph for this function:

static pANTLR3_BASE_TREE becomeRootToken ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
void *  newRoot,
pANTLR3_BASE_TREE  oldRoot 
) [static]

Use the adaptor interface to set a new tree node with the supplied token to the root of the tree.

References ANTLR3_BASE_TREE_ADAPTOR_struct::becomeRoot, and ANTLR3_BASE_TREE_ADAPTOR_struct::create.

Referenced by antlr3BaseTreeAdaptorInit().

Here is the caller graph for this function:

static pANTLR3_BASE_TREE createTypeText ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
ANTLR3_UINT32  tokenType,
pANTLR3_UINT8  text 
) [static]

References ANTLR3_BASE_TREE_ADAPTOR_struct::create, and ANTLR3_BASE_TREE_ADAPTOR_struct::createToken.

Referenced by antlr3BaseTreeAdaptorInit(), and dbgCreateTypeText().

Here is the caller graph for this function:

static pANTLR3_BASE_TREE createTypeToken ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
ANTLR3_UINT32  tokenType,
pANTLR3_COMMON_TOKEN  fromToken 
) [static]

Use the super class supplied create() method to create a new node from the supplied token.

References ANTLR3_BASE_TREE_ADAPTOR_struct::create, ANTLR3_BASE_TREE_ADAPTOR_struct::createTokenFromToken, and ANTLR3_COMMON_TOKEN_struct::setType.

Referenced by antlr3BaseTreeAdaptorInit(), and dbgCreateTypeToken().

Here is the caller graph for this function:

static pANTLR3_BASE_TREE createTypeTokenText ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
ANTLR3_UINT32  tokenType,
pANTLR3_COMMON_TOKEN  fromToken,
pANTLR3_UINT8  text 
) [static]

static void dbgAddChild ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t,
pANTLR3_BASE_TREE  child 
) [static]

static void dbgAddChildToken ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t,
pANTLR3_COMMON_TOKEN  child 
) [static]

static pANTLR3_BASE_TREE dbgBecomeRoot ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  newRoot,
pANTLR3_BASE_TREE  oldRoot 
) [static]

References ANTLR3_DEBUG_EVENT_LISTENER_struct::becomeRoot, becomeRoot(), and ANTLR3_BASE_TREE_ADAPTOR_struct::debugger.

Referenced by antlr3BaseTreeAdaptorInit().

Here is the call graph for this function:

Here is the caller graph for this function:

static pANTLR3_BASE_TREE dbgBecomeRootToken ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
void *  newRoot,
pANTLR3_BASE_TREE  oldRoot 
) [static]

static pANTLR3_BASE_TREE dbgCreateTypeText ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
ANTLR3_UINT32  tokenType,
pANTLR3_UINT8  text 
) [static]

References ANTLR3_DEBUG_EVENT_LISTENER_struct::createNode, createTypeText(), and ANTLR3_BASE_TREE_ADAPTOR_struct::debugger.

Referenced by antlr3BaseTreeAdaptorInit().

Here is the call graph for this function:

Here is the caller graph for this function:

static pANTLR3_BASE_TREE dbgCreateTypeToken ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
ANTLR3_UINT32  tokenType,
pANTLR3_COMMON_TOKEN  fromToken 
) [static]

References ANTLR3_DEBUG_EVENT_LISTENER_struct::createNode, createTypeToken(), and ANTLR3_BASE_TREE_ADAPTOR_struct::debugger.

Referenced by antlr3BaseTreeAdaptorInit().

Here is the call graph for this function:

Here is the caller graph for this function:

static pANTLR3_BASE_TREE dbgCreateTypeTokenText ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
ANTLR3_UINT32  tokenType,
pANTLR3_COMMON_TOKEN  fromToken,
pANTLR3_UINT8  text 
) [static]

References ANTLR3_DEBUG_EVENT_LISTENER_struct::createNode, createTypeTokenText(), and ANTLR3_BASE_TREE_ADAPTOR_struct::debugger.

Referenced by antlr3BaseTreeAdaptorInit().

Here is the call graph for this function:

Here is the caller graph for this function:

pANTLR3_BASE_TREE dbgDupTree ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t 
) [static]

References ANTLR3_BASE_TREE_ADAPTOR_struct::dupTreeTT, and simulateTreeConstruction().

Referenced by antlr3BaseTreeAdaptorInit().

Here is the call graph for this function:

Here is the caller graph for this function:

static pANTLR3_BASE_TREE dbgNil ( pANTLR3_BASE_TREE_ADAPTOR  adaptor  )  [static]

static void defineDotEdges ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
void *  t,
pANTLR3_STRING  dotSpec 
) [static]

static void defineDotNodes ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
void *  t,
pANTLR3_STRING  dotSpec 
) [static]

static pANTLR3_BASE_TREE dupTree ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t 
) [static]

Return a duplicate of the entire tree (implementation provided by the BASE_TREE interface.

)

References ANTLR3_BASE_TREE_ADAPTOR_struct::dupTreeTT.

pANTLR3_BASE_TREE dupTreeTT ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t,
pANTLR3_BASE_TREE  parent 
) [static]

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

References ANTLR3_FPRINTF.

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

References ANTLR3_FPRINTF.

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

Dummy implementation - will be supplied by super class.

References ANTLR3_FPRINTF.

Referenced by ANTLR3_TREE_ADAPTORNew(), antlr3BaseTreeAdaptorInit(), antlr3LexerNew(), antlr3SetCTAPI(), and antlr3SetTokenAPI().

Here is the caller graph for this function:

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

Dummy implementation - will be supplied by super class.

Referenced by ANTLR3_TREE_ADAPTORNew(), antlr3BaseTreeAdaptorInit(), antlr3SetCTAPI(), and antlr3SetTokenAPI().

Here is the caller graph for this function:

static ANTLR3_UINT32 getUniqueID ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  node 
) [static]

Returns a uniqueID for the node.

Because this is the C implementation we can just use its address suitably converted/cast to an integer.

References ANTLR3_UINT32_CAST.

Referenced by antlr3BaseTreeAdaptorInit().

Here is the caller graph for this function:

static ANTLR3_BOOLEAN isNilNode ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t 
) [static]

References ANTLR3_BASE_TREE_struct::isNilNode.

Referenced by antlr3BaseTreeAdaptorInit(), and antlr3SetCTAPI().

Here is the caller graph for this function:

static pANTLR3_STRING makeDot ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
void *  theTree 
) [static]

static pANTLR3_BASE_TREE nilNode ( pANTLR3_BASE_TREE_ADAPTOR  adaptor  )  [static]

Create and return a nil tree node (no token payload).

References ANTLR3_BASE_TREE_ADAPTOR_struct::create.

Referenced by antlr3BaseTreeAdaptorInit(), antlr3DebugListenerNew(), fillBuffer(), and toString().

Here is the caller graph for this function:

static pANTLR3_BASE_TREE rulePostProcessing ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  root 
) [static]

static void setText ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_STRING  t 
) [static]

Dummy implementation - will be supplied by super class.

References ANTLR3_FPRINTF.

Referenced by antlr3BaseTreeAdaptorInit(), and antlr3SetTokenAPI().

Here is the caller graph for this function:

static void setText8 ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_UINT8  t 
) [static]

Dummy implementation - will be supplied by super class.

References ANTLR3_FPRINTF.

Referenced by antlr3BaseTreeAdaptorInit(), and antlr3SetTokenAPI().

Here is the caller graph for this function:

static void setType ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  t,
ANTLR3_UINT32  type 
) [static]

Dummy implementation - will be supplied by super class.

References ANTLR3_FPRINTF.

Referenced by antlr3BaseTreeAdaptorInit(), and antlr3SetTokenAPI().

Here is the caller graph for this function:

static void simulateTreeConstruction ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_TREE  tree 
) [static]

Sends the required debugging events for duplicating a tree to the debugger.

References ANTLR3_DEBUG_EVENT_LISTENER_struct::addChild, ANTLR3_DEBUG_EVENT_LISTENER_struct::createNode, ANTLR3_BASE_TREE_ADAPTOR_struct::debugger, ANTLR3_BASE_TREE_ADAPTOR_struct::getChild, and ANTLR3_BASE_TREE_ADAPTOR_struct::getChildCount.

Referenced by dbgDupTree().

Here is the caller graph for this function:


Generated on Mon Nov 29 17:23:17 2010 for ANTLR3C by  doxygen 1.5.5