public class ParseNode extends Object { private String label; private ParseNode parent; private int line=-1; private Object literal; //private SymbolTable st; public ParseNode(String label) { this.label = label; this.line = -1; this.parent = null; this.literal=null; } public ParseNode ( String label, int line ) { this.label = label; this.line = line; this.parent = null; this.literal=null; } public void setLabel( String label ) { this.label = label; } public String getLabel() { return label; } public void setLiteral(Object o) { literal=o; } public Object getLiteral(Object o) { return literal; } /* public void setSymbolTable(SymbolTable st) { if (st == null) { throw new IRException("symboltable is null!"); } this.st = st; } public SymbolTable getSymbolTable() { if (st == null) { if (parent != null) { return parent.getSymbolTable(); } else { return null; } } else { return st; } } */ public int getLine() { if (line >= 0) { return line; } else { if (parent != null) { return parent.getLine(); } else { return 0; } } } public void setParent( ParseNode parent ) { this.parent = parent; } public ParseNode getParent() { return parent; } public ParseNode insertChild(ParseNode child) { if (child == null) { } child.setParent(this); return child; } public ParseNode insertChild(String newlabel) { ParseNode child = new ParseNode(newlabel, -1); return insertChild(child); } public ParseNode addChild( ParseNode child ) { if (child == null) { } child.setParent(this); return child; } public ParseNode addChild( String newlabel ) { ParseNode child = new ParseNode(newlabel, -1); child.setParent(this); return child; } public ParseNode addChild (String newlabel, int line) { ParseNode child = new ParseNode(newlabel, line); child.setParent(this); return child; } public ParseNode getChild (String label) { int i; ParseNode p; return null; } public ParseNode getRoot() { if (parent==null) return this; else return parent.getRoot(); } public String getTerminal () { return null; } public String getNodeName() { return label; } public String doIndent(int indent) { String output = null; for(int i=0;i