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.)
- Author:
- CarlManning, caroma@ai.mit.edu
Copyright (c) 1997, 1998 Massachusetts Institute of Technology
JevaNode
public JevaNode(int id)
getBeginToken
public Token getBeginToken()
- Specified by:
- getBeginToken in interface IJevaNode
- Returns:
- the first token (in token chain) of the parsed syntax
getEndToken
public Token getEndToken()
- 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