Top Fields Constructors Methods
org.python.antlr

public Class PythonTree

extends AST
implements Traverseproc
Class Inheritance
All Implemented Interfaces
org.python.core.Traverseproc
Known Direct Subclasses
org.python.antlr.ast.alias, org.python.antlr.ast.arguments, org.python.antlr.ast.comprehension, org.python.antlr.ast.keyword, org.python.antlr.base.boolop, org.python.antlr.base.cmpop, org.python.antlr.base.excepthandler, org.python.antlr.base.expr, org.python.antlr.base.expr_context, org.python.antlr.base.mod, org.python.antlr.base.operator, org.python.antlr.base.slice, org.python.antlr.base.stmt, org.python.antlr.base.unaryop, org.python.antlr.op.Eq, org.python.antlr.op.Add, org.python.antlr.op.And, org.python.antlr.op.AugLoad, org.python.antlr.op.AugStore, org.python.antlr.op.BitAnd, org.python.antlr.op.BitOr, org.python.antlr.op.BitXor, org.python.antlr.op.Del, org.python.antlr.op.Div, org.python.antlr.op.FloorDiv, org.python.antlr.op.Gt, org.python.antlr.op.GtE, org.python.antlr.op.In, org.python.antlr.op.Invert, org.python.antlr.op.Is, org.python.antlr.op.IsNot, org.python.antlr.op.Load, org.python.antlr.op.LShift, org.python.antlr.op.Lt, org.python.antlr.op.LtE, org.python.antlr.op.Mod, org.python.antlr.op.Mult, org.python.antlr.op.Not, org.python.antlr.op.NotEq, org.python.antlr.op.NotIn, org.python.antlr.op.Or, org.python.antlr.op.Param, org.python.antlr.op.Pow, org.python.antlr.op.RShift, org.python.antlr.op.Store, org.python.antlr.op.Sub, org.python.antlr.op.UAdd, org.python.antlr.op.USub, org.python.antlr.PythonErrorNode
Imports
org.antlr.runtime.CommonToken, .Token, org.antlr.runtime.tree.CommonTree, org.python.core.PyObject, .PyType, .Traverseproc, .Visitproc, org.python.antlr.ast.Name, .VisitorIF, java.util.ArrayList, .List

Field Summary

Modifier and TypeField and Description
private int
private int
protected List<PythonTree>
public boolean
private CommonTree
private PythonTree
parent

Who is the parent node of this node; if null, implies node is root

Inherited from org.python.antlr.AST:
TYPE

Constructor Summary

AccessConstructor and Description
public
public
PythonTree(PyType subType)

public
public
PythonTree(int ttype, Token t)

public

Method Summary

Modifier and TypeMethod and Description
public <R> R
accept(VisitorIF<R> visitor)

public void
addChild(PythonTree t)

Add t as child of this node.

public void
addChildren(List<PythonTree> kids)

Add all elements of kids list as children of this node

protected List<PythonTree>
createChildrenList()

Override in a subclass to change the impl of children list

public Object
deleteChild(int i)

public static String
dottedNameListToString(List<Name> names)

Converts a list of Name to a dotted-name string.

protected String
protected String
protected String
public PythonTree
public void
freshenParentAndChildIndexes()

Set the parent and child index values for all child of t

public void
public int
protected int
public int
public int
public PythonTree
getChild(int i)

public int
public int
public List<PythonTree>
getChildren()

Get the children internal List; note that if you directly mess with the list, do so at your own risk.

public int
public PythonTree
protected int
public int
public CommonTree
public PythonTree
public String
public Token
public int
public int
public boolean
public boolean
public void
replaceChildren(int startChildIndex, int stopChildIndex, Object t)

Delete children from start to stop and replace with t even if t is a list (nil-root tree).

public void
setCharStartIndex(int index)

public void
setCharStopIndex(int index)

public void
setChild(int i, PythonTree t)

public void
setChildIndex(int index)

public void
public void
setTokenStartIndex(int index)

public void
setTokenStopIndex(int index)

public String
toString()

Overrides org.python.core.PyObject.toString.

Returns a string representation of the object.

public String
public void
traverse(VisitorIF<?> visitor)

public int
traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

Inherited from org.python.antlr.AST:
checkunexpectedCall

Field Detail

charStartIndexback to summary
private int charStartIndex
charStopIndexback to summary
private int charStopIndex
childrenback to summary
protected List<PythonTree> children
from_future_checkedback to summary
public boolean from_future_checked
nodeback to summary
private CommonTree node
parentback to summary
private PythonTree parent

Who is the parent node of this node; if null, implies node is root

Constructor Detail

PythonTreeback to summary
public PythonTree()
PythonTreeback to summary
public PythonTree(PyType subType)
PythonTreeback to summary
public PythonTree(Token t)
PythonTreeback to summary
public PythonTree(int ttype, Token t)
PythonTreeback to summary
public PythonTree(PythonTree tree)

Method Detail

acceptback to summary
public <R> R accept(VisitorIF<R> visitor) throws Exception
addChildback to summary
public void addChild(PythonTree t)

Add t as child of this node.

Warning

if t has no children, but child does and child isNil then this routine moves children to t via t.children = child.children; i.e., without copying the array.

addChildrenback to summary
public void addChildren(List<PythonTree> kids)

Add all elements of kids list as children of this node

createChildrenListback to summary
protected List<PythonTree> createChildrenList()

Override in a subclass to change the impl of children list

deleteChildback to summary
public Object deleteChild(int i)
dottedNameListToStringback to summary
public static String dottedNameListToString(List<Name> names)

Converts a list of Name to a dotted-name string. Because leading dots are indexable identifiers (referring to parent directories in relative imports), a Name list may include leading dots, but not dots between names.

dumpThisback to summary
protected String dumpThis(String s)
dumpThisback to summary
protected String dumpThis(Object o)
dumpThisback to summary
protected String dumpThis(Object[] s)
dupNodeback to summary
public PythonTree dupNode()
freshenParentAndChildIndexesback to summary
public void freshenParentAndChildIndexes()

Set the parent and child index values for all child of t

freshenParentAndChildIndexesback to summary
public void freshenParentAndChildIndexes(int offset)
getAntlrTypeback to summary
public int getAntlrType()
getCharPositionInLineback to summary
protected int getCharPositionInLine()
getCharStartIndexback to summary
public int getCharStartIndex()
getCharStopIndexback to summary
public int getCharStopIndex()
getChildback to summary
public PythonTree getChild(int i)
getChildCountback to summary
public int getChildCount()
getChildIndexback to summary
public int getChildIndex()
getChildrenback to summary
public List<PythonTree> getChildren()

Get the children internal List; note that if you directly mess with the list, do so at your own risk.

getCol_offsetback to summary
public int getCol_offset()
getFirstChildWithTypeback to summary
public PythonTree getFirstChildWithType(int type)
getLineback to summary
protected int getLine()
getLinenoback to summary
public int getLineno()
getNodeback to summary
public CommonTree getNode()
getParentback to summary
public PythonTree getParent()
getTextback to summary
public String getText()
getTokenback to summary
public Token getToken()
getTokenStartIndexback to summary
public int getTokenStartIndex()
getTokenStopIndexback to summary
public int getTokenStopIndex()
isNilback to summary
public boolean isNil()
refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob)

Implements org.python.core.Traverseproc.refersDirectlyTo.

Doc from org.python.core.Traverseproc.refersDirectlyTo.

Optional operation. Should only be implemented if it is more efficient than calling traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.

Annotations
@Override
replaceChildrenback to summary
public void replaceChildren(int startChildIndex, int stopChildIndex, Object t)

Delete children from start to stop and replace with t even if t is a list (nil-root tree). num of children can increase or decrease. For huge child lists, inserting children can force walking rest of children to set their childindex; could be slow.

setCharStartIndexback to summary
public void setCharStartIndex(int index)
setCharStopIndexback to summary
public void setCharStopIndex(int index)
setChildback to summary
public void setChild(int i, PythonTree t)
setChildIndexback to summary
public void setChildIndex(int index)
setParentback to summary
public void setParent(PythonTree t)
setTokenStartIndexback to summary
public void setTokenStartIndex(int index)
setTokenStopIndexback to summary
public void setTokenStopIndex(int index)
toStringback to summary
public String toString()

Overrides org.python.core.PyObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override

toStringTreeback to summary
public String toStringTree()
traverseback to summary
public void traverse(VisitorIF<?> visitor) throws Exception
traverseback to summary
public int traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Doc from org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc#visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc#visit(PyObject, Object) must not be called with a null PyObject-argument.

Annotations
@Override