tip.display
Class ASTDisplay

java.lang.Object
  extended by tip.analysis.AnalysisAdapter
      extended by tip.analysis.DepthFirstAdapter
          extended by tip.display.ASTDisplay
All Implemented Interfaces:
Analysis
Direct Known Subclasses:
CodeGenerationDisplay, EnvironmentsDisplay, NameLinkingDisplay, NormalizationDisplay, ParserDisplay, ResourcesDisplay, TypeCheckingDisplay

public class ASTDisplay
extends DepthFirstAdapter


Nested Class Summary
static class ASTDisplay.Phase
          Enum used for designating for which phases the AST should be displayed.
 
Constructor Summary
ASTDisplay(String title)
          Creates a new ASTDisplay with the given dialog title.
 
Method Summary
static void addDisplayPhase(ASTDisplay.Phase phase)
          Adds the given phase to the set of phases for which the AST is displayed.
static void awaitDisplays()
          Wait for all open displays to be closed before continuing.
 void caseEOF(EOF node)
          Called by the EOF node from EOF#apply(Switch).
 void caseStart(Start node)
          Calls DepthFirstAdapter.inStart(Start), traverses the children of Start in the order they are defined in the grammar, and finally calls DepthFirstAdapter.outStart(Start).
static void clearDisplayPhases()
          Clears the set of phases for which the AST is displayed.
 void defaultIn(Node node)
          As we come across nonterminals, push them onto the stack
 void defaultOut(Node node)
          As we leave a non terminal, it's parent is the node before it on the stack, so we pop it off and add it to that node
 void defaultToken(Token token)
          Terminals - our parent is always on the top of the stack, so we add ourselves to it
static void expandAll(JTree tree, boolean expand)
          If expand is true, expands all nodes in the tree.
 void outAProgram(AProgram node)
          Called by DepthFirstAdapter.caseAProgram(AProgram) after traversing the children of AProgram.
static void showPhaseDisplay(AProgram program, ASTDisplay.Phase phase)
          Shows the ASTDisplay for the given phase.
 
Methods inherited from class tip.analysis.DepthFirstAdapter
caseABinopExp, caseABlock, caseABlockStm, caseABody, caseADeclStm, caseADerefExp, caseADivideBinop, caseAEqBinop, caseAFuncDecl, caseAFunctionCallExp, caseAFunctionPtrCallExp, caseAGtBinop, caseAIfThenElseStm, caseAIfThenStm, caseAInputExp, caseAIntConstExp, caseALocalDecl, caseAMallocExp, caseAMinusBinop, caseANullExp, caseAOutputStm, caseAPlusBinop, caseAPointerExp, caseAProgram, caseAReturnStm, caseATimesBinop, caseAVarExp, caseAWhileStm, caseAAssignPtrStm, caseAAssignVarStm, defaultInPBinop, defaultInPBlock, defaultInPBody, defaultInPDecl, defaultInPExp, defaultInPProgram, defaultInPStm, defaultOutPBinop, defaultOutPBlock, defaultOutPBody, defaultOutPDecl, defaultOutPExp, defaultOutPProgram, defaultOutPStm, defaultPBinop, defaultPBlock, defaultPBody, defaultPDecl, defaultPExp, defaultPProgram, defaultPStm, inABinopExp, inABlock, inABlockStm, inABody, inADeclStm, inADerefExp, inADivideBinop, inAEqBinop, inAFuncDecl, inAFunctionCallExp, inAFunctionPtrCallExp, inAGtBinop, inAIfThenElseStm, inAIfThenStm, inAInputExp, inAIntConstExp, inALocalDecl, inAMallocExp, inAMinusBinop, inANullExp, inAOutputStm, inAPlusBinop, inAPointerExp, inAProgram, inAReturnStm, inATimesBinop, inAVarExp, inAWhileStm, inStart, inAAssignPtrStm, inAAssignVarStm, outABinopExp, outABlock, outABlockStm, outABody, outADeclStm, outADerefExp, outADivideBinop, outAEqBinop, outAFuncDecl, outAFunctionCallExp, outAFunctionPtrCallExp, outAGtBinop, outAIfThenElseStm, outAIfThenStm, outAInputExp, outAIntConstExp, outALocalDecl, outAMallocExp, outAMinusBinop, outANullExp, outAOutputStm, outAPlusBinop, outAPointerExp, outAReturnStm, outATimesBinop, outAVarExp, outAWhileStm, outStart, outAAssignPtrStm, outAAssignVarStm
 
Methods inherited from class tip.analysis.AnalysisAdapter
caseTAnd, caseTAssign, caseTComma, caseTCommentBlock, caseTCommentSingle, caseTDiv, caseTElse, caseTEq, caseTGt, caseTIdentifier, caseTIf, caseTInput, caseTIntegerConst, caseTLBrace, caseTLPar, caseTMalloc, caseTMinus, caseTNull, caseTOutput, caseTPlus, caseTRBrace, caseTReturn, caseTRPar, caseTSemicolon, caseTStar, caseTVar, caseTWhile, caseTWhiteSpace, defaultNode, getIn, getOut, setIn, setOut
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASTDisplay

public ASTDisplay(String title)
Creates a new ASTDisplay with the given dialog title.

Parameters:
title - the displayed dialog title
Method Detail

outAProgram

public void outAProgram(AProgram node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAProgram(AProgram) after traversing the children of AProgram.

Overrides:
outAProgram in class DepthFirstAdapter
Parameters:
node - the visited AProgram node

defaultIn

public void defaultIn(Node node)
As we come across nonterminals, push them onto the stack

Overrides:
defaultIn in class DepthFirstAdapter
Parameters:
node - the handled node

defaultOut

public void defaultOut(Node node)
As we leave a non terminal, it's parent is the node before it on the stack, so we pop it off and add it to that node

Overrides:
defaultOut in class DepthFirstAdapter
Parameters:
node - the visited Node

defaultToken

public void defaultToken(Token token)
Terminals - our parent is always on the top of the stack, so we add ourselves to it

Overrides:
defaultToken in class AnalysisAdapter
Parameters:
token - the added token

caseStart

public final void caseStart(Start node)
Description copied from class: DepthFirstAdapter
Calls DepthFirstAdapter.inStart(Start), traverses the children of Start in the order they are defined in the grammar, and finally calls DepthFirstAdapter.outStart(Start).

Specified by:
caseStart in interface Analysis
Overrides:
caseStart in class DepthFirstAdapter
Parameters:
node - the visited Start node

caseEOF

public final void caseEOF(EOF node)
Description copied from class: AnalysisAdapter
Called by the EOF node from EOF#apply(Switch).

Specified by:
caseEOF in interface Analysis
Overrides:
caseEOF in class AnalysisAdapter
Parameters:
node - the calling EOF token

addDisplayPhase

public static void addDisplayPhase(ASTDisplay.Phase phase)
Adds the given phase to the set of phases for which the AST is displayed.

Parameters:
phase - the added phase

clearDisplayPhases

public static void clearDisplayPhases()
Clears the set of phases for which the AST is displayed.


showPhaseDisplay

public static void showPhaseDisplay(AProgram program,
                                    ASTDisplay.Phase phase)
Shows the ASTDisplay for the given phase. The AST is only display if an implementation has been provided for the phase and its display has been enabled through its respective commandline option.

Parameters:
program - the program AST
phase - the phase for which to display the AST

awaitDisplays

public static void awaitDisplays()
Wait for all open displays to be closed before continuing.


expandAll

public static void expandAll(JTree tree,
                             boolean expand)
If expand is true, expands all nodes in the tree. Otherwise, collapses all nodes in the tree.

Parameters:
tree - the expanded/collapsed tree
expand - expand/collapse switch