Top Description Inners Fields Constructors Methods
com.jogamp.gluegen.cgram

public Class TNode

extends CommonAST
implements ASTLocusTagProvider
Class Inheritance
All Implemented Interfaces
com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider
Annotations
@SuppressWarnings:serial
Imports
antlr.collections.AST, antlr.CommonAST, .Token, java.lang.reflect.*, java.util.Hashtable, .Enumeration, com.jogamp.gluegen.ASTLocusTag, .ASTLocusTag.ASTLocusTagProvider, .GlueGen

Class TNode is an implementation of the AST interface and adds many useful features: It is double-linked for reverse searching. (this is currently incomplete, in that method doubleLink() must be called after any changes to the tree to maintain the reverse links). It can store a definition node (defNode), so that nodes such as scoped names can refer to the node that defines the name. It stores line numbers for nodes. Searches for parents and children of a tree can be done based on their type. The tree can be printed to System.out using a lisp-style syntax.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
protected Hashtable<String, Object>
protected TNode
protected TNode
protected int
protected boolean
protected String
pack-priv static String
protected int
protected TNode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addSibling(final AST node)

add the new node as a new sibling, inserting it ahead of any existing next sibling.

public TNode
deepCopy()

return a deep copy of this node, and all sub nodes.

public TNode
deepCopyWithRightSiblings()

return a deep copy of this node, all sub nodes, and right siblings.

public TNode
firstChildOfType(final int type)

find the first child of the node of the given type, return null on failure

public TNode
firstSiblingOfType(final int type)

find the first sibling of the node of the given type, return null on failure

public String
getAllChildrenText(final String name)

Returns the text for this node, its children and siblings.

private static void
getAllChildrenText(final StringBuilder buf, final TNode upNode, TNode thisNode)

public ASTLocusTag
getASTLocusTag()

Implements com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Returns this instance's ASTLocusTag, if available, otherwise returns null.
public Object
getAttribute(final String attrName)

lookup the attribute name in the attribute table.

public Hashtable<String, Object>
getAttributesTable()

get the hashtable that holds attribute values.

public TNode
getDefNode()

return the def node for this node

public TNode
getFirstSibling()

return the first sibling of this node, which is this if the prev sibling is null

public TNode
getLastChild()

return the last child of this node, or null if there is none

public TNode
getLastSibling()

return the last sibling of this node, which is this if the next sibling is null

public int
getLineNum()

Get the line number for this node.

public int
public boolean
getMarker()

Get the marker value for this node.

public static String
getNameForType(final int t)

converts an int tree token type to a name.

public TNode
getParent()

return the parent node of this node

public String
getText()

Overrides antlr.CommonAST.getText.

Implements antlr.collections.AST.getText.

Get the token text for this node
public int
getType()

Overrides antlr.CommonAST.getType.

Implements antlr.collections.AST.getType.

Get the token type for this node
public void
public void
public int
numberOfChildren()

return the number of children of this node

public TNode
parentOfType(final int type)

find first parent of the given type, return null on failure

protected static void
printASTNode(final AST t, final int indent)

protected method that does the work of printing

public static void
printTree(final AST t)

print given tree to System.out

public void
removeSelf()

remove this node from the tree, resetting sibling and parent pointers as necessary.

public void
setAttribute(final String attrName, final Object value)

set an attribute in the attribute table.

public void
setDefNode(final TNode n)

set the def node for this node

public void
setLineNum(final int lineNum_)

Set the line number for this node

public void
setMarker(final boolean marker_)

Set the marker value for this node.

public void
setText(final String text_)

Overrides antlr.CommonAST.setText.

Implements antlr.collections.AST.setText.

Set the token text for this node
public static void
setTokenVocabulary(final String s)

Set the token vocabulary to a tokentypes class generated by antlr.

public void
setType(final int ttype_)

Overrides antlr.CommonAST.setType.

Implements antlr.collections.AST.setType.

Set the token type for this node
public String
toString()

Overrides antlr.BaseAST.toString.

Implements antlr.collections.AST.toString.

return a short string representation of the node
Inherited from antlr.CommonAST:
initialize

Field Detail

attributesback to summary
protected Hashtable<String, Object> attributes
defNodeback to summary
protected TNode defNode
leftback to summary
protected TNode left
lineNumback to summary
protected int lineNum
markerback to summary
protected boolean marker
textback to summary
protected String text

Hides antlr.CommonAST.text.

tokenVocabularyback to summary
pack-priv static String tokenVocabulary
ttypeback to summary
protected int ttype

Hides antlr.CommonAST.ttype.

upback to summary
protected TNode up

Constructor Detail

TNodeback to summary
public TNode()

Method Detail

addSiblingback to summary
public void addSibling(final AST node)

add the new node as a new sibling, inserting it ahead of any existing next sibling. This method maintains double-linking. if node is null, nothing happens. If the node has siblings, then they are added in as well.

deepCopyback to summary
public TNode deepCopy()

return a deep copy of this node, and all sub nodes. New tree is doubleLinked, with no parent or siblings. Marker value is not copied!

deepCopyWithRightSiblingsback to summary
public TNode deepCopyWithRightSiblings()

return a deep copy of this node, all sub nodes, and right siblings. New tree is doubleLinked, with no parent or left siblings. defNode is not copied

firstChildOfTypeback to summary
public TNode firstChildOfType(final int type)

find the first child of the node of the given type, return null on failure

firstSiblingOfTypeback to summary
public TNode firstSiblingOfType(final int type)

find the first sibling of the node of the given type, return null on failure

getAllChildrenTextback to summary
public String getAllChildrenText(final String name)

Returns the text for this node, its children and siblings.

Implementation converts the AST LISP notation to serialized form.

getAllChildrenTextback to summary
private static void getAllChildrenText(final StringBuilder buf, final TNode upNode, TNode thisNode)
getASTLocusTagback to summary
public ASTLocusTag getASTLocusTag()

Implements com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Doc from com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Returns this instance's ASTLocusTag, if available, otherwise returns null.

If source is not available, implementation returns null.

Annotations
@Override
getAttributeback to summary
public Object getAttribute(final String attrName)

lookup the attribute name in the attribute table. If the value does not exist, it returns null.

getAttributesTableback to summary
public Hashtable<String, Object> getAttributesTable()

get the hashtable that holds attribute values.

getDefNodeback to summary
public TNode getDefNode()

return the def node for this node

getFirstSiblingback to summary
public TNode getFirstSibling()

return the first sibling of this node, which is this if the prev sibling is null

getLastChildback to summary
public TNode getLastChild()

return the last child of this node, or null if there is none

getLastSiblingback to summary
public TNode getLastSibling()

return the last sibling of this node, which is this if the next sibling is null

getLineNumback to summary
public int getLineNum()

Get the line number for this node. If the line number is 0, search for a non-zero line num among children

getLocalLineNumback to summary
public int getLocalLineNum()
getMarkerback to summary
public boolean getMarker()

Get the marker value for this node. This member is a general-use marker.

getNameForTypeback to summary
public static String getNameForType(final int t)

converts an int tree token type to a name. Does this by reflecting on nsdidl.IDLTreeTokenTypes, and is dependent on how ANTLR 2.00 outputs that class.

getParentback to summary
public TNode getParent()

return the parent node of this node

getTextback to summary
public String getText()

Overrides antlr.CommonAST.getText.

Implements antlr.collections.AST.getText.

Get the token text for this node

Annotations
@Override
getTypeback to summary
public int getType()

Overrides antlr.CommonAST.getType.

Implements antlr.collections.AST.getType.

Get the token type for this node

Annotations
@Override
initializeback to summary
public void initialize(final Token token)

Overrides antlr.CommonAST.initialize.

Implements antlr.collections.AST.initialize.

Annotations
@Override
initializeback to summary
public void initialize(final AST tr)

Overrides antlr.CommonAST.initialize.

Implements antlr.collections.AST.initialize.

Annotations
@Override
numberOfChildrenback to summary
public int numberOfChildren()

return the number of children of this node

parentOfTypeback to summary
public TNode parentOfType(final int type)

find first parent of the given type, return null on failure

printASTNodeback to summary
protected static void printASTNode(final AST t, final int indent)

protected method that does the work of printing

printTreeback to summary
public static void printTree(final AST t)

print given tree to System.out

removeSelfback to summary
public void removeSelf()

remove this node from the tree, resetting sibling and parent pointers as necessary. This method maintains double-linking

setAttributeback to summary
public void setAttribute(final String attrName, final Object value)

set an attribute in the attribute table.

setDefNodeback to summary
public void setDefNode(final TNode n)

set the def node for this node

setLineNumback to summary
public void setLineNum(final int lineNum_)

Set the line number for this node

setMarkerback to summary
public void setMarker(final boolean marker_)

Set the marker value for this node. This property is a general-use boolean marker.

setTextback to summary
public void setText(final String text_)

Overrides antlr.CommonAST.setText.

Implements antlr.collections.AST.setText.

Set the token text for this node

Annotations
@Override
setTokenVocabularyback to summary
public static void setTokenVocabulary(final String s)

Set the token vocabulary to a tokentypes class generated by antlr.

setTypeback to summary
public void setType(final int ttype_)

Overrides antlr.CommonAST.setType.

Implements antlr.collections.AST.setType.

Set the token type for this node

Annotations
@Override
toStringback to summary
public String toString()

Overrides antlr.BaseAST.toString.

Implements antlr.collections.AST.toString.

return a short string representation of the node

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
com.jogamp.gluegen.cgram back to summary

pack-priv Class TNode.DebugASTVisitor

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
protected int

Constructor Summary

AccessConstructor and Description
pack-priv
DebugASTVisitor(final int level)

Method Summary

Modifier and TypeMethod and Description
private String
tabs(final StringBuilder sb)

pack-priv void
visit(final AST node)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

levelback to summary
protected int level

Constructor Detail

DebugASTVisitorback to summary
pack-priv DebugASTVisitor(final int level)

Method Detail

tabsback to summary
private String tabs(final StringBuilder sb)
visitback to summary
pack-priv void visit(final AST node)