edu.mit.ai.psg.jevaES
Class JevaNode

java.lang.Object
  |
  +--edu.mit.ai.psg.jevaES.SimpleNode
        |
        +--edu.mit.ai.psg.jevaES.JevaNode
Direct Known Subclasses:
ExpressionNode, JNDImportDeclaration, JNDPackageDeclaration, JNEArguments, JNEArrayDimensions, JNEArrayInitializer, JNEAssignmentOperator, JNFormalParameter, JNPrimitiveType, JNResultType, JNSBlock, JNSBreakStatement, JNSContinueStatement, JNSDoStatement, JNSEmptyStatement, JNSExpressionStatement, JNSExpressionStatementList, JNSForStatement, JNSIfStatement, JNSLabeledStatement, JNSLocalVariableDeclaration, JNSReturnStatement, JNSSwitchLabel, JNSSwitchStatement, JNSSynchronizedStatement, JNSThrowStatement, JNSTryStatement, JNSVariableDeclarator, JNSWhileStatement, JNType

public class JevaNode
extends SimpleNode
implements IJevaNode

JevaNode: Extends SimpleNode so each node can echo back its token stream of Java code. Adds first and last+1 token of the parsed syntax, so the syntax can be regenerated, and adds print methods to echo back the parsed java code, with or without comments. (This is an extension class so that it is easier to upgrade to new versions of Javacc that generate new versions of SimpleNode.)


Fields inherited from class edu.mit.ai.psg.jevaES.SimpleNode
children, id, parent
 
Constructor Summary
JevaNode(int id)
           
 
Method Summary
 Token getBeginToken()
          return the first token (in token chain) of the parsed syntax
 Token getEndToken()
          return the token after the last token of the parsed syntax
protected static IllegalStateException notVerified()
          called from eval methods if node hasn't been verified first
 void print(PrintWriter stream)
          Print tokens of parsed node's syntax, including children, to stream.
 void print(PrintWriter stream, boolean includeSpecialTokens)
           
protected  void printToken(Token t, PrintWriter stream, boolean includeSpecialTokens)
           
 String printToString()
          Print tokens of parsed node's syntax, including children, to string.
 String printToString(boolean includeSpecialTokens)
           
 void setBeginToken(Token t)
          Called by the parser to set the first token of the parsed syntax
 void setEndToken(Token t)
          Called by the parser to set the last+1 token of the parsed syntax
protected static Error shouldNotHappen(String explain)
          calls EvalMethods.shouldNotHappen(String);
protected static Error shouldNotHappen(String explain, Throwable e)
          calls EvalMethods.shouldNotHappen(String,Throwable);
protected static Error shouldNotHappen(Throwable e)
          calls EvalMethods.shouldNotHappen(Throwable);
 
Methods inherited from class edu.mit.ai.psg.jevaES.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JevaNode

public JevaNode(int id)
Method Detail

getBeginToken

public Token getBeginToken()
Description copied from interface: IJevaNode
return the first token (in token chain) of the parsed syntax
Specified by:
getBeginToken in interface IJevaNode
Returns:
the first token (in token chain) of the parsed syntax

getEndToken

public Token getEndToken()
Description copied from interface: IJevaNode
return the token after the last token of the parsed syntax
Specified by:
getEndToken in interface IJevaNode
Returns:
the token after the last token of the parsed syntax

setBeginToken

public void setBeginToken(Token t)
Called by the parser to set the first token of the parsed syntax
Specified by:
setBeginToken in interface IJevaNode

setEndToken

public void setEndToken(Token t)
Called by the parser to set the last+1 token of the parsed syntax
Specified by:
setEndToken in interface IJevaNode

print

public void print(PrintWriter stream)
Print tokens of parsed node's syntax, including children, to stream. also prints special tokens (whitespace and comments)
Specified by:
print in interface IJevaNode

print

public void print(PrintWriter stream,
                  boolean includeSpecialTokens)
Specified by:
print in interface IJevaNode

printToken

protected final void printToken(Token t,
                                PrintWriter stream,
                                boolean includeSpecialTokens)

printToString

public String printToString()
Print tokens of parsed node's syntax, including children, to string. Includes special tokens (whitespace and comments).
Specified by:
printToString in interface IJevaNode
Returns:
a string recreating node's syntax

printToString

public String printToString(boolean includeSpecialTokens)
Specified by:
printToString in interface IJevaNode

shouldNotHappen

protected static Error shouldNotHappen(String explain,
                                       Throwable e)
calls EvalMethods.shouldNotHappen(String,Throwable);

shouldNotHappen

protected static Error shouldNotHappen(Throwable e)
calls EvalMethods.shouldNotHappen(Throwable);

shouldNotHappen

protected static Error shouldNotHappen(String explain)
calls EvalMethods.shouldNotHappen(String);

notVerified

protected static IllegalStateException notVerified()
called from eval methods if node hasn't been verified first

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu