Clean up source code using default Eclipse settings.

main
Deryck Brown 3 years ago
parent b9ed079ce1
commit 5fa828c450
  1. 2
      Triangle.AbstractMachine.Interpreter/src/main/java/Triangle/AbstractMachine/Interpreter.java
  2. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/AnyTypeDenoter.java
  3. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ArrayExpression.java
  4. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ArrayTypeDenoter.java
  5. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/AssignCommand.java
  6. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/BinaryExpression.java
  7. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/BinaryOperatorDeclaration.java
  8. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/BoolTypeDenoter.java
  9. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CallCommand.java
  10. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CallExpression.java
  11. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CharTypeDenoter.java
  12. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CharacterExpression.java
  13. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CharacterLiteral.java
  14. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ConstActualParameter.java
  15. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ConstDeclaration.java
  16. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ConstFormalParameter.java
  17. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/DotVname.java
  18. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyActualParameterSequence.java
  19. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyCommand.java
  20. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyExpression.java
  21. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyFormalParameterSequence.java
  22. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ErrorTypeDenoter.java
  23. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FieldTypeDenoter.java
  24. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FormalParameter.java
  25. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FormalParameterSequence.java
  26. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FuncActualParameter.java
  27. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FuncDeclaration.java
  28. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FuncFormalParameter.java
  29. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/Identifier.java
  30. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IfCommand.java
  31. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IfExpression.java
  32. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IntTypeDenoter.java
  33. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IntegerExpression.java
  34. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IntegerLiteral.java
  35. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/LetCommand.java
  36. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/LetExpression.java
  37. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleActualParameterSequence.java
  38. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleArrayAggregate.java
  39. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleFieldTypeDenoter.java
  40. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleFormalParameterSequence.java
  41. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleRecordAggregate.java
  42. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/Operator.java
  43. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ProcActualParameter.java
  44. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ProcDeclaration.java
  45. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ProcFormalParameter.java
  46. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/Program.java
  47. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/RecordExpression.java
  48. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/RecordTypeDenoter.java
  49. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SequentialCommand.java
  50. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SequentialDeclaration.java
  51. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SimpleTypeDenoter.java
  52. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SimpleVname.java
  53. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleActualParameterSequence.java
  54. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleArrayAggregate.java
  55. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleFieldTypeDenoter.java
  56. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleFormalParameterSequence.java
  57. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleRecordAggregate.java
  58. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SubscriptVname.java
  59. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/TypeDeclaration.java
  60. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/TypeDenoter.java
  61. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/UnaryExpression.java
  62. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/UnaryOperatorDeclaration.java
  63. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VarActualParameter.java
  64. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VarDeclaration.java
  65. 6
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VarFormalParameter.java
  66. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VnameExpression.java
  67. 3
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/WhileCommand.java
  68. 186
      Triangle.Compiler/src/main/java/Triangle/CodeGenerator/Encoder.java
  69. 186
      Triangle.Compiler/src/main/java/Triangle/ContextualAnalyzer/Checker.java
  70. 3
      Triangle.Compiler/src/main/java/Triangle/SyntacticAnalyzer/SourcePosition.java
  71. 2
      Triangle.Compiler/src/main/java/Triangle/SyntacticAnalyzer/SyntaxError.java
  72. 3
      Triangle.Compiler/src/main/java/Triangle/SyntacticAnalyzer/Token.java
  73. 1
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/DrawerFrame.java
  74. 3
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/DrawerPanel.java
  75. 10
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/DrawingTree.java
  76. 186
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/LayoutVisitor.java
  77. 2
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/Polyline.java

@ -377,7 +377,7 @@ public class Interpreter {
} catch (java.io.IOException s) {
status = failedIOError;
}
data[addr] = (int) currentChar;
data[addr] = currentChar;
break;
case Machine.putDisplacement:
ST = ST - 1;

@ -22,11 +22,13 @@ public class AnyTypeDenoter extends TypeDenoter {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitAnyTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
return false;
}
}

@ -24,7 +24,8 @@ public class ArrayExpression extends Expression {
AA = aaAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitArrayExpression(this, o);
}

@ -25,11 +25,13 @@ public class ArrayTypeDenoter extends TypeDenoter {
T = tAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitArrayTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof ErrorTypeDenoter)
return true;
else if (obj != null && obj instanceof ArrayTypeDenoter)

@ -24,7 +24,8 @@ public class AssignCommand extends Command {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitAssignCommand(this, o);
}

@ -26,7 +26,8 @@ public class BinaryExpression extends Expression {
E2 = e2AST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitBinaryExpression(this, o);
}

@ -28,7 +28,8 @@ public class BinaryOperatorDeclaration extends Declaration {
RES = resultAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitBinaryOperatorDeclaration(this, o);
}

@ -22,11 +22,13 @@ public class BoolTypeDenoter extends TypeDenoter {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitBoolTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if ((obj != null) && (obj instanceof ErrorTypeDenoter))
return true;
else

@ -25,7 +25,8 @@ public class CallCommand extends Command {
APS = apsAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitCallCommand(this, o);
}

@ -25,7 +25,8 @@ public class CallExpression extends Expression {
APS = apsAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitCallExpression(this, o);
}

@ -22,11 +22,13 @@ public class CharTypeDenoter extends TypeDenoter {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitCharTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof ErrorTypeDenoter)
return true;
else

@ -23,7 +23,8 @@ public class CharacterExpression extends Expression {
CL = clAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitCharacterExpression(this, o);
}

@ -22,7 +22,8 @@ public class CharacterLiteral extends Terminal {
super(theSpelling, thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitCharacterLiteral(this, o);
}

@ -23,7 +23,8 @@ public class ConstActualParameter extends ActualParameter {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitConstActualParameter(this, o);
}

@ -25,7 +25,8 @@ public class ConstDeclaration extends Declaration {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitConstDeclaration(this, o);
}

@ -25,14 +25,16 @@ public class ConstFormalParameter extends FormalParameter {
T = tAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitConstFormalParameter(this, o);
}
public Identifier I;
public TypeDenoter T;
public boolean equals(Object fpAST) {
@Override
public boolean equals(Object fpAST) {
if (fpAST instanceof ConstFormalParameter) {
ConstFormalParameter cfpAST = (ConstFormalParameter) fpAST;
return T.equals(cfpAST.T);

@ -24,7 +24,8 @@ public class DotVname extends Vname {
I = iAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitDotVname(this, o);
}

@ -22,7 +22,8 @@ public class EmptyActualParameterSequence extends ActualParameterSequence {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitEmptyActualParameterSequence(this, o);
}
}

@ -22,7 +22,8 @@ public class EmptyCommand extends Command {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitEmptyCommand(this, o);
}
}

@ -22,7 +22,8 @@ public class EmptyExpression extends Expression {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitEmptyExpression(this, o);
}
}

@ -22,11 +22,13 @@ public class EmptyFormalParameterSequence extends FormalParameterSequence {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitEmptyFormalParameterSequence(this, o);
}
public boolean equals(Object fpsAST) {
@Override
public boolean equals(Object fpsAST) {
return (fpsAST instanceof EmptyFormalParameterSequence);
}
}

@ -22,11 +22,13 @@ public class ErrorTypeDenoter extends TypeDenoter {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitErrorTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
return true;
}
}

@ -22,5 +22,6 @@ public abstract class FieldTypeDenoter extends TypeDenoter {
super(thePosition);
}
public abstract boolean equals(Object obj);
@Override
public abstract boolean equals(Object obj);
}

@ -22,6 +22,7 @@ public abstract class FormalParameter extends Declaration {
super(thePosition);
}
public abstract boolean equals(Object fpAST);
@Override
public abstract boolean equals(Object fpAST);
}

@ -22,5 +22,6 @@ public abstract class FormalParameterSequence extends AST {
super(thePosition);
}
public abstract boolean equals(Object fpsAST);
@Override
public abstract boolean equals(Object fpsAST);
}

@ -23,7 +23,8 @@ public class FuncActualParameter extends ActualParameter {
I = iAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitFuncActualParameter(this, o);
}

@ -28,7 +28,8 @@ public class FuncDeclaration extends Declaration {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitFuncDeclaration(this, o);
}

@ -26,11 +26,13 @@ public class FuncFormalParameter extends FormalParameter {
T = tAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitFuncFormalParameter(this, o);
}
public boolean equals(Object fpAST) {
@Override
public boolean equals(Object fpAST) {
if (fpAST instanceof FuncFormalParameter) {
FuncFormalParameter ffpAST = (FuncFormalParameter) fpAST;
return FPS.equals(ffpAST.FPS) && T.equals(ffpAST.T);

@ -24,7 +24,8 @@ public class Identifier extends Terminal {
decl = null;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitIdentifier(this, o);
}

@ -26,7 +26,8 @@ public class IfCommand extends Command {
C2 = c2AST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitIfCommand(this, o);
}

@ -26,7 +26,8 @@ public class IfExpression extends Expression {
E3 = e3AST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitIfExpression(this, o);
}

@ -22,11 +22,13 @@ public class IntTypeDenoter extends TypeDenoter {
super(thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitIntTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof ErrorTypeDenoter)
return true;
else

@ -23,7 +23,8 @@ public class IntegerExpression extends Expression {
IL = ilAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitIntegerExpression(this, o);
}

@ -22,7 +22,8 @@ public class IntegerLiteral extends Terminal {
super(theSpelling, thePosition);
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitIntegerLiteral(this, o);
}

@ -24,7 +24,8 @@ public class LetCommand extends Command {
C = cAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitLetCommand(this, o);
}

@ -24,7 +24,8 @@ public class LetExpression extends Expression {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitLetExpression(this, o);
}

@ -25,7 +25,8 @@ public class MultipleActualParameterSequence extends ActualParameterSequence {
APS = apsAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitMultipleActualParameterSequence(this, o);
}

@ -25,7 +25,8 @@ public class MultipleArrayAggregate extends ArrayAggregate {
AA = aaAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitMultipleArrayAggregate(this, o);
}

@ -26,11 +26,13 @@ public class MultipleFieldTypeDenoter extends FieldTypeDenoter {
FT = ftAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitMultipleFieldTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof MultipleFieldTypeDenoter) {
MultipleFieldTypeDenoter ft = (MultipleFieldTypeDenoter) obj;
return (this.I.spelling.compareTo(ft.I.spelling) == 0) &&

@ -25,11 +25,13 @@ public class MultipleFormalParameterSequence extends FormalParameterSequence {
FPS = fpsAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitMultipleFormalParameterSequence(this, o);
}
public boolean equals(Object fpsAST) {
@Override
public boolean equals(Object fpsAST) {
if (fpsAST instanceof MultipleFormalParameterSequence) {
MultipleFormalParameterSequence mfpsAST = (MultipleFormalParameterSequence) fpsAST;
return FP.equals(mfpsAST.FP) && FPS.equals(mfpsAST.FPS);

@ -26,7 +26,8 @@ public class MultipleRecordAggregate extends RecordAggregate {
RA = raAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitMultipleRecordAggregate(this, o);
}

@ -23,7 +23,8 @@ public class Operator extends Terminal {
decl = null;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitOperator(this, o);
}

@ -23,7 +23,8 @@ public class ProcActualParameter extends ActualParameter {
I = iAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitProcActualParameter(this, o);
}

@ -26,7 +26,8 @@ public class ProcDeclaration extends Declaration {
C = cAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitProcDeclaration(this, o);
}

@ -25,14 +25,16 @@ public class ProcFormalParameter extends FormalParameter {
FPS = fpsAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitProcFormalParameter(this, o);
}
public Identifier I;
public FormalParameterSequence FPS;
public boolean equals(Object fpAST) {
@Override
public boolean equals(Object fpAST) {
if (fpAST instanceof ProcFormalParameter) {
ProcFormalParameter pfpAST = (ProcFormalParameter) fpAST;
return FPS.equals(pfpAST.FPS);

@ -23,7 +23,8 @@ public class Program extends AST {
C = cAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitProgram(this, o);
}

@ -23,7 +23,8 @@ public class RecordExpression extends Expression {
RA = raAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitRecordExpression(this, o);
}

@ -23,11 +23,13 @@ public class RecordTypeDenoter extends TypeDenoter {
FT = ftAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitRecordTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof ErrorTypeDenoter)
return true;
else if (obj != null && obj instanceof RecordTypeDenoter)

@ -24,7 +24,8 @@ public class SequentialCommand extends Command {
C2 = c2AST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSequentialCommand(this, o);
}

@ -25,7 +25,8 @@ public class SequentialDeclaration extends Declaration {
D2 = d2AST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSequentialDeclaration(this, o);
}

@ -23,11 +23,13 @@ public class SimpleTypeDenoter extends TypeDenoter {
I = iAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSimpleTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
return false; // should not happen
}

@ -23,7 +23,8 @@ public class SimpleVname extends Vname {
I = iAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSimpleVname(this, o);
}

@ -24,7 +24,8 @@ public class SingleActualParameterSequence extends ActualParameterSequence {
AP = apAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSingleActualParameterSequence(this, o);
}

@ -24,7 +24,8 @@ public class SingleArrayAggregate extends ArrayAggregate {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSingleArrayAggregate(this, o);
}

@ -25,11 +25,13 @@ public class SingleFieldTypeDenoter extends FieldTypeDenoter {
T = tAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSingleFieldTypeDenoter(this, o);
}
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof SingleFieldTypeDenoter) {
SingleFieldTypeDenoter ft = (SingleFieldTypeDenoter) obj;
return (this.I.spelling.compareTo(ft.I.spelling) == 0) &&

@ -24,11 +24,13 @@ public class SingleFormalParameterSequence extends FormalParameterSequence {
FP = fpAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSingleFormalParameterSequence(this, o);
}
public boolean equals(Object fpsAST) {
@Override
public boolean equals(Object fpsAST) {
if (fpsAST instanceof SingleFormalParameterSequence) {
SingleFormalParameterSequence sfpsAST = (SingleFormalParameterSequence) fpsAST;
return FP.equals(sfpsAST.FP);

@ -25,7 +25,8 @@ public class SingleRecordAggregate extends RecordAggregate {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSingleRecordAggregate(this, o);
}

@ -24,7 +24,8 @@ public class SubscriptVname extends Vname {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitSubscriptVname(this, o);
}

@ -25,7 +25,8 @@ public class TypeDeclaration extends Declaration {
T = tAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitTypeDeclaration(this, o);
}

@ -22,6 +22,7 @@ public abstract class TypeDenoter extends AST {
super(thePosition);
}
public abstract boolean equals(Object obj);
@Override
public abstract boolean equals(Object obj);
}

@ -25,7 +25,8 @@ public class UnaryExpression extends Expression {
E = eAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitUnaryExpression(this, o);
}

@ -26,7 +26,8 @@ public class UnaryOperatorDeclaration extends Declaration {
RES = resultAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitUnaryOperatorDeclaration(this, o);
}

@ -23,7 +23,8 @@ public class VarActualParameter extends ActualParameter {
V = vAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitVarActualParameter(this, o);
}

@ -25,7 +25,8 @@ public class VarDeclaration extends Declaration {
T = tAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitVarDeclaration(this, o);
}

@ -25,14 +25,16 @@ public class VarFormalParameter extends FormalParameter {
T = tAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitVarFormalParameter(this, o);
}
public Identifier I;
public TypeDenoter T;
public boolean equals(Object fpAST) {
@Override
public boolean equals(Object fpAST) {
if (fpAST instanceof VarFormalParameter) {
VarFormalParameter vfpAST = (VarFormalParameter) fpAST;
return T.equals(vfpAST.T);

@ -23,7 +23,8 @@ public class VnameExpression extends Expression {
V = vAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitVnameExpression(this, o);
}

@ -24,7 +24,8 @@ public class WhileCommand extends Command {
C = cAST;
}
public Object visit(Visitor v, Object o) {
@Override
public Object visit(Visitor v, Object o) {
return v.visitWhileCommand(this, o);
}

@ -93,7 +93,8 @@ import Triangle.AbstractSyntaxTrees.WhileCommand;
public final class Encoder implements Visitor {
// Commands
public Object visitAssignCommand(AssignCommand ast, Object o) {
@Override
public Object visitAssignCommand(AssignCommand ast, Object o) {
Frame frame = (Frame) o;
Integer valSize = (Integer) ast.E.visit(this, frame);
encodeStore(ast.V, new Frame(frame, valSize.intValue()),
@ -101,18 +102,21 @@ public final class Encoder implements Visitor {
return null;
}
public Object visitCallCommand(CallCommand ast, Object o) {
@Override
public Object visitCallCommand(CallCommand ast, Object o) {
Frame frame = (Frame) o;
Integer argsSize = (Integer) ast.APS.visit(this, frame);
ast.I.visit(this, new Frame(frame.level, argsSize));
return null;
}
public Object visitEmptyCommand(EmptyCommand ast, Object o) {
@Override
public Object visitEmptyCommand(EmptyCommand ast, Object o) {
return null;
}
public Object visitIfCommand(IfCommand ast, Object o) {
@Override
public Object visitIfCommand(IfCommand ast, Object o) {
Frame frame = (Frame) o;
int jumpifAddr, jumpAddr;
@ -128,7 +132,8 @@ public final class Encoder implements Visitor {
return null;
}
public Object visitLetCommand(LetCommand ast, Object o) {
@Override
public Object visitLetCommand(LetCommand ast, Object o) {
Frame frame = (Frame) o;
int extraSize = ((Integer) ast.D.visit(this, frame)).intValue();
ast.C.visit(this, new Frame(frame, extraSize));
@ -137,13 +142,15 @@ public final class Encoder implements Visitor {
return null;
}
public Object visitSequentialCommand(SequentialCommand ast, Object o) {
@Override
public Object visitSequentialCommand(SequentialCommand ast, Object o) {
ast.C1.visit(this, o);
ast.C2.visit(this, o);
return null;
}
public Object visitWhileCommand(WhileCommand ast, Object o) {
@Override
public Object visitWhileCommand(WhileCommand ast, Object o) {
Frame frame = (Frame) o;
int jumpAddr, loopAddr;
@ -158,12 +165,14 @@ public final class Encoder implements Visitor {
}
// Expressions
public Object visitArrayExpression(ArrayExpression ast, Object o) {
@Override
public Object visitArrayExpression(ArrayExpression ast, Object o) {
ast.type.visit(this, null);
return ast.AA.visit(this, o);
}
public Object visitBinaryExpression(BinaryExpression ast, Object o) {
@Override
public Object visitBinaryExpression(BinaryExpression ast, Object o) {
Frame frame = (Frame) o;
Integer valSize = (Integer) ast.type.visit(this, null);
int valSize1 = ((Integer) ast.E1.visit(this, frame)).intValue();
@ -174,7 +183,8 @@ public final class Encoder implements Visitor {
return valSize;
}
public Object visitCallExpression(CallExpression ast, Object o) {
@Override
public Object visitCallExpression(CallExpression ast, Object o) {
Frame frame = (Frame) o;
Integer valSize = (Integer) ast.type.visit(this, null);
Integer argsSize = (Integer) ast.APS.visit(this, frame);
@ -182,7 +192,8 @@ public final class Encoder implements Visitor {
return valSize;
}
public Object visitCharacterExpression(CharacterExpression ast,
@Override
public Object visitCharacterExpression(CharacterExpression ast,
Object o) {
Frame frame = (Frame) o;
Integer valSize = (Integer) ast.type.visit(this, null);
@ -190,11 +201,13 @@ public final class Encoder implements Visitor {
return valSize;
}
public Object visitEmptyExpression(EmptyExpression ast, Object o) {
@Override
public Object visitEmptyExpression(EmptyExpression ast, Object o) {
return new Integer(0);
}
public Object visitIfExpression(IfExpression ast, Object o) {
@Override
public Object visitIfExpression(IfExpression ast, Object o) {
Frame frame = (Frame) o;
Integer valSize;
int jumpifAddr, jumpAddr;
@ -212,14 +225,16 @@ public final class Encoder implements Visitor {
return valSize;
}
public Object visitIntegerExpression(IntegerExpression ast, Object o) {
@Override
public Object visitIntegerExpression(IntegerExpression ast, Object o) {
Frame frame = (Frame) o;
Integer valSize = (Integer) ast.type.visit(this, null);
emit(Machine.LOADLop, 0, 0, Integer.parseInt(ast.IL.spelling));
return valSize;
}
public Object visitLetExpression(LetExpression ast, Object o) {
@Override
public Object visitLetExpression(LetExpression ast, Object o) {
Frame frame = (Frame) o;
ast.type.visit(this, null);
int extraSize = ((Integer) ast.D.visit(this, frame)).intValue();
@ -230,12 +245,14 @@ public final class Encoder implements Visitor {
return valSize;
}
public Object visitRecordExpression(RecordExpression ast, Object o) {
@Override
public Object visitRecordExpression(RecordExpression ast, Object o) {
ast.type.visit(this, null);
return ast.RA.visit(this, o);
}
public Object visitUnaryExpression(UnaryExpression ast, Object o) {
@Override
public Object visitUnaryExpression(UnaryExpression ast, Object o) {
Frame frame = (Frame) o;
Integer valSize = (Integer) ast.type.visit(this, null);
ast.E.visit(this, frame);
@ -243,7 +260,8 @@ public final class Encoder implements Visitor {
return valSize;
}
public Object visitVnameExpression(VnameExpression ast, Object o) {
@Override
public Object visitVnameExpression(VnameExpression ast, Object o) {
Frame frame = (Frame) o;
Integer valSize = (Integer) ast.type.visit(this, null);
encodeFetch(ast.V, frame, valSize.intValue());
@ -251,12 +269,14 @@ public final class Encoder implements Visitor {
}
// Declarations
public Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast,
@Override
public Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast,
Object o) {
return new Integer(0);
}
public Object visitConstDeclaration(ConstDeclaration ast, Object o) {
@Override
public Object visitConstDeclaration(ConstDeclaration ast, Object o) {
Frame frame = (Frame) o;
int extraSize = 0;
@ -277,7 +297,8 @@ public final class Encoder implements Visitor {
return new Integer(extraSize);
}
public Object visitFuncDeclaration(FuncDeclaration ast, Object o) {
@Override
public Object visitFuncDeclaration(FuncDeclaration ast, Object o) {
Frame frame = (Frame) o;
int jumpAddr = nextInstrAddr;
int argsSize = 0, valSize = 0;
@ -298,7 +319,8 @@ public final class Encoder implements Visitor {
return new Integer(0);
}
public Object visitProcDeclaration(ProcDeclaration ast, Object o) {
@Override
public Object visitProcDeclaration(ProcDeclaration ast, Object o) {
Frame frame = (Frame) o;
int jumpAddr = nextInstrAddr;
int argsSize = 0;
@ -320,7 +342,8 @@ public final class Encoder implements Visitor {
return new Integer(0);
}
public Object visitSequentialDeclaration(SequentialDeclaration ast, Object o) {
@Override
public Object visitSequentialDeclaration(SequentialDeclaration ast, Object o) {
Frame frame = (Frame) o;
int extraSize1, extraSize2;
@ -330,18 +353,21 @@ public final class Encoder implements Visitor {
return new Integer(extraSize1 + extraSize2);
}
public Object visitTypeDeclaration(TypeDeclaration ast, Object o) {
@Override
public Object visitTypeDeclaration(TypeDeclaration ast, Object o) {
// just to ensure the type's representation is decided
ast.T.visit(this, null);
return new Integer(0);
}
public Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast,
@Override
public Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast,
Object o) {
return new Integer(0);
}
public Object visitVarDeclaration(VarDeclaration ast, Object o) {
@Override
public Object visitVarDeclaration(VarDeclaration ast, Object o) {
Frame frame = (Frame) o;
int extraSize;
@ -353,7 +379,8 @@ public final class Encoder implements Visitor {
}
// Array Aggregates
public Object visitMultipleArrayAggregate(MultipleArrayAggregate ast,
@Override
public Object visitMultipleArrayAggregate(MultipleArrayAggregate ast,
Object o) {
Frame frame = (Frame) o;
int elemSize = ((Integer) ast.E.visit(this, frame)).intValue();
@ -362,12 +389,14 @@ public final class Encoder implements Visitor {
return new Integer(elemSize + arraySize);
}
public Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object o) {
@Override
public Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object o) {
return ast.E.visit(this, o);
}
// Record Aggregates
public Object visitMultipleRecordAggregate(MultipleRecordAggregate ast,
@Override
public Object visitMultipleRecordAggregate(MultipleRecordAggregate ast,
Object o) {
Frame frame = (Frame) o;
int fieldSize = ((Integer) ast.E.visit(this, frame)).intValue();
@ -376,13 +405,15 @@ public final class Encoder implements Visitor {
return new Integer(fieldSize + recordSize);
}
public Object visitSingleRecordAggregate(SingleRecordAggregate ast,
@Override
public Object visitSingleRecordAggregate(SingleRecordAggregate ast,
Object o) {
return ast.E.visit(this, o);
}
// Formal Parameters
public Object visitConstFormalParameter(ConstFormalParameter ast, Object o) {
@Override
public Object visitConstFormalParameter(ConstFormalParameter ast, Object o) {
Frame frame = (Frame) o;
int valSize = ((Integer) ast.T.visit(this, null)).intValue();
ast.entity = new UnknownValue(valSize, frame.level, -frame.size - valSize);
@ -390,7 +421,8 @@ public final class Encoder implements Visitor {
return new Integer(valSize);
}
public Object visitFuncFormalParameter(FuncFormalParameter ast, Object o) {
@Override
public Object visitFuncFormalParameter(FuncFormalParameter ast, Object o) {
Frame frame = (Frame) o;
int argsSize = Machine.closureSize;
ast.entity = new UnknownRoutine(Machine.closureSize, frame.level,
@ -399,7 +431,8 @@ public final class Encoder implements Visitor {
return new Integer(argsSize);
}
public Object visitProcFormalParameter(ProcFormalParameter ast, Object o) {
@Override
public Object visitProcFormalParameter(ProcFormalParameter ast, Object o) {
Frame frame = (Frame) o;
int argsSize = Machine.closureSize;
ast.entity = new UnknownRoutine(Machine.closureSize, frame.level,
@ -408,7 +441,8 @@ public final class Encoder implements Visitor {
return new Integer(argsSize);
}
public Object visitVarFormalParameter(VarFormalParameter ast, Object o) {
@Override
public Object visitVarFormalParameter(VarFormalParameter ast, Object o) {
Frame frame = (Frame) o;
ast.T.visit(this, null);
ast.entity = new UnknownAddress(Machine.addressSize, frame.level,
@ -417,12 +451,14 @@ public final class Encoder implements Visitor {
return new Integer(Machine.addressSize);
}
public Object visitEmptyFormalParameterSequence(
@Override
public Object visitEmptyFormalParameterSequence(
EmptyFormalParameterSequence ast, Object o) {
return new Integer(0);
}
public Object visitMultipleFormalParameterSequence(
@Override
public Object visitMultipleFormalParameterSequence(
MultipleFormalParameterSequence ast, Object o) {
Frame frame = (Frame) o;
int argsSize1 = ((Integer) ast.FPS.visit(this, frame)).intValue();
@ -431,17 +467,20 @@ public final class Encoder implements Visitor {
return new Integer(argsSize1 + argsSize2);
}
public Object visitSingleFormalParameterSequence(
@Override
public Object visitSingleFormalParameterSequence(
SingleFormalParameterSequence ast, Object o) {
return ast.FP.visit(this, o);
}
// Actual Parameters
public Object visitConstActualParameter(ConstActualParameter ast, Object o) {
@Override
public Object visitConstActualParameter(ConstActualParameter ast, Object o) {
return ast.E.visit(this, o);
}
public Object visitFuncActualParameter(FuncActualParameter ast, Object o) {
@Override
public Object visitFuncActualParameter(FuncActualParameter ast, Object o) {
Frame frame = (Frame) o;
if (ast.I.decl.entity instanceof KnownRoutine) {
ObjectAddress address = ((KnownRoutine) ast.I.decl.entity).address;
@ -461,7 +500,8 @@ public final class Encoder implements Visitor {
return new Integer(Machine.closureSize);
}
public Object visitProcActualParameter(ProcActualParameter ast, Object o) {
@Override
public Object visitProcActualParameter(ProcActualParameter ast, Object o) {
Frame frame = (Frame) o;
if (ast.I.decl.entity instanceof KnownRoutine) {
ObjectAddress address = ((KnownRoutine) ast.I.decl.entity).address;
@ -481,17 +521,20 @@ public final class Encoder implements Visitor {
return new Integer(Machine.closureSize);
}
public Object visitVarActualParameter(VarActualParameter ast, Object o) {
@Override
public Object visitVarActualParameter(VarActualParameter ast, Object o) {
encodeFetchAddress(ast.V, (Frame) o);
return new Integer(Machine.addressSize);
}
public Object visitEmptyActualParameterSequence(
@Override
public Object visitEmptyActualParameterSequence(
EmptyActualParameterSequence ast, Object o) {
return new Integer(0);
}
public Object visitMultipleActualParameterSequence(
@Override
public Object visitMultipleActualParameterSequence(
MultipleActualParameterSequence ast, Object o) {
Frame frame = (Frame) o;
int argsSize1 = ((Integer) ast.AP.visit(this, frame)).intValue();
@ -500,17 +543,20 @@ public final class Encoder implements Visitor {
return new Integer(argsSize1 + argsSize2);
}
public Object visitSingleActualParameterSequence(
@Override
public Object visitSingleActualParameterSequence(
SingleActualParameterSequence ast, Object o) {
return ast.AP.visit(this, o);
}
// Type Denoters
public Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object o) {
@Override
public Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object o) {
return new Integer(0);
}
public Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object o) {
@Override
public Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object o) {
int typeSize;
if (ast.entity == null) {
int elemSize = ((Integer) ast.T.visit(this, null)).intValue();
@ -522,7 +568,8 @@ public final class Encoder implements Visitor {
return new Integer(typeSize);
}
public Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object o) {
@Override
public Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object o) {
if (ast.entity == null) {
ast.entity = new TypeRepresentation(Machine.booleanSize);
writeTableDetails(ast);
@ -530,7 +577,8 @@ public final class Encoder implements Visitor {
return new Integer(Machine.booleanSize);
}
public Object visitCharTypeDenoter(CharTypeDenoter ast, Object o) {
@Override
public Object visitCharTypeDenoter(CharTypeDenoter ast, Object o) {
if (ast.entity == null) {
ast.entity = new TypeRepresentation(Machine.characterSize);
writeTableDetails(ast);
@ -538,16 +586,19 @@ public final class Encoder implements Visitor {
return new Integer(Machine.characterSize);
}
public Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object o) {
@Override
public Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object o) {
return new Integer(0);
}
public Object visitSimpleTypeDenoter(SimpleTypeDenoter ast,
@Override
public Object visitSimpleTypeDenoter(SimpleTypeDenoter ast,
Object o) {
return new Integer(0);
}
public Object visitIntTypeDenoter(IntTypeDenoter ast, Object o) {
@Override
public Object visitIntTypeDenoter(IntTypeDenoter ast, Object o) {
if (ast.entity == null) {
ast.entity = new TypeRepresentation(Machine.integerSize);
writeTableDetails(ast);
@ -555,7 +606,8 @@ public final class Encoder implements Visitor {
return new Integer(Machine.integerSize);
}
public Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object o) {
@Override
public Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object o) {
int typeSize;
if (ast.entity == null) {
typeSize = ((Integer) ast.FT.visit(this, new Integer(0))).intValue();
@ -566,7 +618,8 @@ public final class Encoder implements Visitor {
return new Integer(typeSize);
}
public Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast,
@Override
public Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast,
Object o) {
int offset = ((Integer) o).intValue();
int fieldSize;
@ -583,7 +636,8 @@ public final class Encoder implements Visitor {
return new Integer(fieldSize + recSize);
}
public Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast,
@Override
public Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast,
Object o) {
int offset = ((Integer) o).intValue();
int fieldSize;
@ -599,11 +653,13 @@ public final class Encoder implements Visitor {
}
// Literals, Identifiers and Operators
public Object visitCharacterLiteral(CharacterLiteral ast, Object o) {
@Override
public Object visitCharacterLiteral(CharacterLiteral ast, Object o) {
return null;
}
public Object visitIdentifier(Identifier ast, Object o) {
@Override
public Object visitIdentifier(Identifier ast, Object o) {
Frame frame = (Frame) o;
if (ast.decl.entity instanceof KnownRoutine) {
ObjectAddress address = ((KnownRoutine) ast.decl.entity).address;
@ -626,11 +682,13 @@ public final class Encoder implements Visitor {
return null;
}
public Object visitIntegerLiteral(IntegerLiteral ast, Object o) {
@Override
public Object visitIntegerLiteral(IntegerLiteral ast, Object o) {
return null;
}
public Object visitOperator(Operator ast, Object o) {
@Override
public Object visitOperator(Operator ast, Object o) {
Frame frame = (Frame) o;
if (ast.decl.entity instanceof KnownRoutine) {
ObjectAddress address = ((KnownRoutine) ast.decl.entity).address;
@ -654,7 +712,8 @@ public final class Encoder implements Visitor {
}
// Value-or-variable names
public Object visitDotVname(DotVname ast, Object o) {
@Override
public Object visitDotVname(DotVname ast, Object o) {
Frame frame = (Frame) o;
RuntimeEntity baseObject = (RuntimeEntity) ast.V.visit(this, frame);
ast.offset = ast.V.offset + ((Field) ast.I.decl.entity).fieldOffset;
@ -663,13 +722,15 @@ public final class Encoder implements Visitor {
return baseObject;
}
public Object visitSimpleVname(SimpleVname ast, Object o) {
@Override
public Object visitSimpleVname(SimpleVname ast, Object o) {
ast.offset = 0;
ast.indexed = false;
return ast.I.decl.entity;
}
public Object visitSubscriptVname(SubscriptVname ast, Object o) {
@Override
public Object visitSubscriptVname(SubscriptVname ast, Object o) {
Frame frame = (Frame) o;
RuntimeEntity baseObject;
int elemSize, indexSize;
@ -700,7 +761,8 @@ public final class Encoder implements Visitor {
}
// Programs
public Object visitProgram(Program ast, Object o) {
@Override
public Object visitProgram(Program ast, Object o) {
return ast.C.visit(this, o);
}

@ -93,7 +93,8 @@ public final class Checker implements Visitor {
// Always returns null. Does not use the given object.
public Object visitAssignCommand(AssignCommand ast, Object o) {
@Override
public Object visitAssignCommand(AssignCommand ast, Object o) {
TypeDenoter vType = (TypeDenoter) ast.V.visit(this, null);
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
if (!ast.V.variable)
@ -103,7 +104,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitCallCommand(CallCommand ast, Object o) {
@Override
public Object visitCallCommand(CallCommand ast, Object o) {
Declaration binding = (Declaration) ast.I.visit(this, null);
if (binding == null)
@ -118,11 +120,13 @@ public final class Checker implements Visitor {
return null;
}
public Object visitEmptyCommand(EmptyCommand ast, Object o) {
@Override
public Object visitEmptyCommand(EmptyCommand ast, Object o) {
return null;
}
public Object visitIfCommand(IfCommand ast, Object o) {
@Override
public Object visitIfCommand(IfCommand ast, Object o) {
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
if (!eType.equals(StdEnvironment.booleanType))
reporter.reportError("Boolean expression expected here", "", ast.E.position);
@ -131,7 +135,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitLetCommand(LetCommand ast, Object o) {
@Override
public Object visitLetCommand(LetCommand ast, Object o) {
idTable.openScope();
ast.D.visit(this, null);
ast.C.visit(this, null);
@ -139,13 +144,15 @@ public final class Checker implements Visitor {
return null;
}
public Object visitSequentialCommand(SequentialCommand ast, Object o) {
@Override
public Object visitSequentialCommand(SequentialCommand ast, Object o) {
ast.C1.visit(this, null);
ast.C2.visit(this, null);
return null;
}
public Object visitWhileCommand(WhileCommand ast, Object o) {
@Override
public Object visitWhileCommand(WhileCommand ast, Object o) {
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
if (!eType.equals(StdEnvironment.booleanType))
reporter.reportError("Boolean expression expected here", "", ast.E.position);
@ -158,7 +165,8 @@ public final class Checker implements Visitor {
// Returns the TypeDenoter denoting the type of the expression. Does
// not use the given object.
public Object visitArrayExpression(ArrayExpression ast, Object o) {
@Override
public Object visitArrayExpression(ArrayExpression ast, Object o) {
TypeDenoter elemType = (TypeDenoter) ast.AA.visit(this, null);
IntegerLiteral il = new IntegerLiteral(new Integer(ast.AA.elemCount).toString(),
ast.position);
@ -166,7 +174,8 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitBinaryExpression(BinaryExpression ast, Object o) {
@Override
public Object visitBinaryExpression(BinaryExpression ast, Object o) {
TypeDenoter e1Type = (TypeDenoter) ast.E1.visit(this, null);
TypeDenoter e2Type = (TypeDenoter) ast.E2.visit(this, null);
@ -195,7 +204,8 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitCallExpression(CallExpression ast, Object o) {
@Override
public Object visitCallExpression(CallExpression ast, Object o) {
Declaration binding = (Declaration) ast.I.visit(this, null);
if (binding == null) {
reportUndeclared(ast.I);
@ -212,17 +222,20 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitCharacterExpression(CharacterExpression ast, Object o) {
@Override
public Object visitCharacterExpression(CharacterExpression ast, Object o) {
ast.type = StdEnvironment.charType;
return ast.type;
}
public Object visitEmptyExpression(EmptyExpression ast, Object o) {
@Override
public Object visitEmptyExpression(EmptyExpression ast, Object o) {
ast.type = null;
return ast.type;
}
public Object visitIfExpression(IfExpression ast, Object o) {
@Override
public Object visitIfExpression(IfExpression ast, Object o) {
TypeDenoter e1Type = (TypeDenoter) ast.E1.visit(this, null);
if (!e1Type.equals(StdEnvironment.booleanType))
reporter.reportError("Boolean expression expected here", "",
@ -235,12 +248,14 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitIntegerExpression(IntegerExpression ast, Object o) {
@Override
public Object visitIntegerExpression(IntegerExpression ast, Object o) {
ast.type = StdEnvironment.integerType;
return ast.type;
}
public Object visitLetExpression(LetExpression ast, Object o) {
@Override
public Object visitLetExpression(LetExpression ast, Object o) {
idTable.openScope();
ast.D.visit(this, null);
ast.type = (TypeDenoter) ast.E.visit(this, null);
@ -248,13 +263,15 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitRecordExpression(RecordExpression ast, Object o) {
@Override
public Object visitRecordExpression(RecordExpression ast, Object o) {
FieldTypeDenoter rType = (FieldTypeDenoter) ast.RA.visit(this, null);
ast.type = new RecordTypeDenoter(rType, ast.position);
return ast.type;
}
public Object visitUnaryExpression(UnaryExpression ast, Object o) {
@Override
public Object visitUnaryExpression(UnaryExpression ast, Object o) {
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
Declaration binding = (Declaration) ast.O.visit(this, null);
@ -274,7 +291,8 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitVnameExpression(VnameExpression ast, Object o) {
@Override
public Object visitVnameExpression(VnameExpression ast, Object o) {
ast.type = (TypeDenoter) ast.V.visit(this, null);
return ast.type;
}
@ -282,11 +300,13 @@ public final class Checker implements Visitor {
// Declarations
// Always returns null. Does not use the given object.
public Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, Object o) {
@Override
public Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, Object o) {
return null;
}
public Object visitConstDeclaration(ConstDeclaration ast, Object o) {
@Override
public Object visitConstDeclaration(ConstDeclaration ast, Object o) {
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
idTable.enter(ast.I.spelling, ast);
if (ast.duplicated)
@ -295,7 +315,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitFuncDeclaration(FuncDeclaration ast, Object o) {
@Override
public Object visitFuncDeclaration(FuncDeclaration ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
idTable.enter(ast.I.spelling, ast); // permits recursion
if (ast.duplicated)
@ -311,7 +332,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitProcDeclaration(ProcDeclaration ast, Object o) {
@Override
public Object visitProcDeclaration(ProcDeclaration ast, Object o) {
idTable.enter(ast.I.spelling, ast); // permits recursion
if (ast.duplicated)
reporter.reportError("identifier \"%\" already declared",
@ -323,13 +345,15 @@ public final class Checker implements Visitor {
return null;
}
public Object visitSequentialDeclaration(SequentialDeclaration ast, Object o) {
@Override
public Object visitSequentialDeclaration(SequentialDeclaration ast, Object o) {
ast.D1.visit(this, null);
ast.D2.visit(this, null);
return null;
}
public Object visitTypeDeclaration(TypeDeclaration ast, Object o) {
@Override
public Object visitTypeDeclaration(TypeDeclaration ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
idTable.enter(ast.I.spelling, ast);
if (ast.duplicated)
@ -338,11 +362,13 @@ public final class Checker implements Visitor {
return null;
}
public Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, Object o) {
@Override
public Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, Object o) {
return null;
}
public Object visitVarDeclaration(VarDeclaration ast, Object o) {
@Override
public Object visitVarDeclaration(VarDeclaration ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
idTable.enter(ast.I.spelling, ast);
if (ast.duplicated)
@ -357,7 +383,8 @@ public final class Checker implements Visitor {
// Returns the TypeDenoter for the Array Aggregate. Does not use the
// given object.
public Object visitMultipleArrayAggregate(MultipleArrayAggregate ast, Object o) {
@Override
public Object visitMultipleArrayAggregate(MultipleArrayAggregate ast, Object o) {
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
TypeDenoter elemType = (TypeDenoter) ast.AA.visit(this, null);
ast.elemCount = ast.AA.elemCount + 1;
@ -366,7 +393,8 @@ public final class Checker implements Visitor {
return elemType;
}
public Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object o) {
@Override
public Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object o) {
TypeDenoter elemType = (TypeDenoter) ast.E.visit(this, null);
ast.elemCount = 1;
return elemType;
@ -377,7 +405,8 @@ public final class Checker implements Visitor {
// Returns the TypeDenoter for the Record Aggregate. Does not use the
// given object.
public Object visitMultipleRecordAggregate(MultipleRecordAggregate ast, Object o) {
@Override
public Object visitMultipleRecordAggregate(MultipleRecordAggregate ast, Object o) {
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
FieldTypeDenoter rType = (FieldTypeDenoter) ast.RA.visit(this, null);
TypeDenoter fType = checkFieldIdentifier(rType, ast.I);
@ -388,7 +417,8 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitSingleRecordAggregate(SingleRecordAggregate ast, Object o) {
@Override
public Object visitSingleRecordAggregate(SingleRecordAggregate ast, Object o) {
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
ast.type = new SingleFieldTypeDenoter(ast.I, eType, ast.position);
return ast.type;
@ -398,7 +428,8 @@ public final class Checker implements Visitor {
// Always returns null. Does not use the given object.
public Object visitConstFormalParameter(ConstFormalParameter ast, Object o) {
@Override
public Object visitConstFormalParameter(ConstFormalParameter ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
idTable.enter(ast.I.spelling, ast);
if (ast.duplicated)
@ -407,7 +438,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitFuncFormalParameter(FuncFormalParameter ast, Object o) {
@Override
public Object visitFuncFormalParameter(FuncFormalParameter ast, Object o) {
idTable.openScope();
ast.FPS.visit(this, null);
idTable.closeScope();
@ -419,7 +451,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitProcFormalParameter(ProcFormalParameter ast, Object o) {
@Override
public Object visitProcFormalParameter(ProcFormalParameter ast, Object o) {
idTable.openScope();
ast.FPS.visit(this, null);
idTable.closeScope();
@ -430,7 +463,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitVarFormalParameter(VarFormalParameter ast, Object o) {
@Override
public Object visitVarFormalParameter(VarFormalParameter ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
idTable.enter(ast.I.spelling, ast);
if (ast.duplicated)
@ -439,17 +473,20 @@ public final class Checker implements Visitor {
return null;
}
public Object visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, Object o) {
@Override
public Object visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, Object o) {
return null;
}
public Object visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, Object o) {
@Override
public Object visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, Object o) {
ast.FP.visit(this, null);
ast.FPS.visit(this, null);
return null;
}
public Object visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, Object o) {
@Override
public Object visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, Object o) {
ast.FP.visit(this, null);
return null;
}
@ -458,7 +495,8 @@ public final class Checker implements Visitor {
// Always returns null. Uses the given FormalParameter.
public Object visitConstActualParameter(ConstActualParameter ast, Object o) {
@Override
public Object visitConstActualParameter(ConstActualParameter ast, Object o) {
FormalParameter fp = (FormalParameter) o;
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
@ -471,7 +509,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitFuncActualParameter(FuncActualParameter ast, Object o) {
@Override
public Object visitFuncActualParameter(FuncActualParameter ast, Object o) {
FormalParameter fp = (FormalParameter) o;
Declaration binding = (Declaration) ast.I.visit(this, null);
@ -504,7 +543,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitProcActualParameter(ProcActualParameter ast, Object o) {
@Override
public Object visitProcActualParameter(ProcActualParameter ast, Object o) {
FormalParameter fp = (FormalParameter) o;
Declaration binding = (Declaration) ast.I.visit(this, null);
@ -530,7 +570,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitVarActualParameter(VarActualParameter ast, Object o) {
@Override
public Object visitVarActualParameter(VarActualParameter ast, Object o) {
FormalParameter fp = (FormalParameter) o;
TypeDenoter vType = (TypeDenoter) ast.V.visit(this, null);
@ -546,14 +587,16 @@ public final class Checker implements Visitor {
return null;
}
public Object visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, Object o) {
@Override
public Object visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, Object o) {
FormalParameterSequence fps = (FormalParameterSequence) o;
if (!(fps instanceof EmptyFormalParameterSequence))
reporter.reportError("too few actual parameters", "", ast.position);
return null;
}
public Object visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, Object o) {
@Override
public Object visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, Object o) {
FormalParameterSequence fps = (FormalParameterSequence) o;
if (!(fps instanceof MultipleFormalParameterSequence))
reporter.reportError("too many actual parameters", "", ast.position);
@ -564,7 +607,8 @@ public final class Checker implements Visitor {
return null;
}
public Object visitSingleActualParameterSequence(SingleActualParameterSequence ast, Object o) {
@Override
public Object visitSingleActualParameterSequence(SingleActualParameterSequence ast, Object o) {
FormalParameterSequence fps = (FormalParameterSequence) o;
if (!(fps instanceof SingleFormalParameterSequence))
reporter.reportError("incorrect number of actual parameters", "", ast.position);
@ -579,30 +623,36 @@ public final class Checker implements Visitor {
// Returns the expanded version of the TypeDenoter. Does not
// use the given object.
public Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object o) {
@Override
public Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object o) {
return StdEnvironment.anyType;
}
public Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object o) {
@Override
public Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
if ((Integer.valueOf(ast.IL.spelling).intValue()) == 0)
reporter.reportError("arrays must not be empty", "", ast.IL.position);
return ast;
}
public Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object o) {
@Override
public Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object o) {
return StdEnvironment.booleanType;
}
public Object visitCharTypeDenoter(CharTypeDenoter ast, Object o) {
@Override
public Object visitCharTypeDenoter(CharTypeDenoter ast, Object o) {
return StdEnvironment.charType;
}
public Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object o) {
@Override
public Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object o) {
return StdEnvironment.errorType;
}
public Object visitSimpleTypeDenoter(SimpleTypeDenoter ast, Object o) {
@Override
public Object visitSimpleTypeDenoter(SimpleTypeDenoter ast, Object o) {
Declaration binding = (Declaration) ast.I.visit(this, null);
if (binding == null) {
reportUndeclared(ast.I);
@ -615,43 +665,51 @@ public final class Checker implements Visitor {
return ((TypeDeclaration) binding).T;
}
public Object visitIntTypeDenoter(IntTypeDenoter ast, Object o) {
@Override
public Object visitIntTypeDenoter(IntTypeDenoter ast, Object o) {
return StdEnvironment.integerType;
}
public Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object o) {
@Override
public Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object o) {
ast.FT = (FieldTypeDenoter) ast.FT.visit(this, null);
return ast;
}
public Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, Object o) {
@Override
public Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
ast.FT.visit(this, null);
return ast;
}
public Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, Object o) {
@Override
public Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, Object o) {
ast.T = (TypeDenoter) ast.T.visit(this, null);
return ast;
}
// Literals, Identifiers and Operators
public Object visitCharacterLiteral(CharacterLiteral CL, Object o) {
@Override
public Object visitCharacterLiteral(CharacterLiteral CL, Object o) {
return StdEnvironment.charType;
}
public Object visitIdentifier(Identifier I, Object o) {
@Override
public Object visitIdentifier(Identifier I, Object o) {
Declaration binding = idTable.retrieve(I.spelling);
if (binding != null)
I.decl = binding;
return binding;
}
public Object visitIntegerLiteral(IntegerLiteral IL, Object o) {
@Override
public Object visitIntegerLiteral(IntegerLiteral IL, Object o) {
return StdEnvironment.integerType;
}
public Object visitOperator(Operator O, Object o) {
@Override
public Object visitOperator(Operator O, Object o) {
Declaration binding = idTable.retrieve(O.spelling);
if (binding != null)
O.decl = binding;
@ -679,7 +737,8 @@ public final class Checker implements Visitor {
// Returns the TypeDenoter of the Vname. Does not use the
// given object.
public Object visitDotVname(DotVname ast, Object o) {
@Override
public Object visitDotVname(DotVname ast, Object o) {
ast.type = null;
TypeDenoter vType = (TypeDenoter) ast.V.visit(this, null);
ast.variable = ast.V.variable;
@ -694,7 +753,8 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitSimpleVname(SimpleVname ast, Object o) {
@Override
public Object visitSimpleVname(SimpleVname ast, Object o) {
ast.variable = false;
ast.type = StdEnvironment.errorType;
Declaration binding = (Declaration) ast.I.visit(this, null);
@ -718,7 +778,8 @@ public final class Checker implements Visitor {
return ast.type;
}
public Object visitSubscriptVname(SubscriptVname ast, Object o) {
@Override
public Object visitSubscriptVname(SubscriptVname ast, Object o) {
TypeDenoter vType = (TypeDenoter) ast.V.visit(this, null);
ast.variable = ast.V.variable;
TypeDenoter eType = (TypeDenoter) ast.E.visit(this, null);
@ -737,7 +798,8 @@ public final class Checker implements Visitor {
// Programs
public Object visitProgram(Program ast, Object o) {
@Override
public Object visitProgram(Program ast, Object o) {
ast.C.visit(this, null);
return null;
}

@ -28,7 +28,8 @@ public class SourcePosition {
finish = f;
}
public String toString() {
@Override
public String toString() {
return "(" + start + ", " + finish + ")";
}
}

@ -18,7 +18,7 @@ class SyntaxError extends Exception {
SyntaxError() {
super();
};
}
SyntaxError(String s) {
super(s);

@ -50,7 +50,8 @@ final class Token extends Object {
return tokenTable[kind];
}
public String toString() {
@Override
public String toString() {
return "Kind=" + kind + ", spelling=" + spelling +
", position=" + position;
}

@ -39,6 +39,7 @@ class DrawerFrame extends JFrame {
addWindowListener(
new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}

@ -27,7 +27,8 @@ class DrawerPanel extends JPanel {
this.drawer = drawer;
}
public void paintComponent(Graphics g) {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
drawer.paintAST(g);
}

@ -57,8 +57,8 @@ public class DrawingTree {
pos.y + (height + FIXED_FONT_HEIGHT) / 2);
if (children != null) {
for (int i = 0; i < children.length; i++) {
children[i].paint(graphics);
for (DrawingTree child : children) {
child.paint(graphics);
}
}
@ -77,9 +77,9 @@ public class DrawingTree {
Point temp = new Point(this.pos.x, this.pos.y);
if (children != null) {
for (int i = 0; i < children.length; i++) {
children[i].position(temp);
temp.x += children[i].offset.x;
for (DrawingTree child : children) {
child.position(temp);
temp.x += child.offset.x;
temp.y = this.pos.y + children[0].offset.y;
}
}

@ -93,262 +93,324 @@ public class LayoutVisitor implements Visitor {
}
// Commands
public Object visitAssignCommand(AssignCommand ast, Object obj) {
@Override
public Object visitAssignCommand(AssignCommand ast, Object obj) {
return layoutBinary("AssignCom.", ast.V, ast.E);
}
public Object visitCallCommand(CallCommand ast, Object obj) {
@Override
public Object visitCallCommand(CallCommand ast, Object obj) {
return layoutBinary("CallCom.", ast.I, ast.APS);
}
public Object visitEmptyCommand(EmptyCommand ast, Object obj) {
@Override
public Object visitEmptyCommand(EmptyCommand ast, Object obj) {
return layoutNullary("EmptyCom.");
}
public Object visitIfCommand(IfCommand ast, Object obj) {
@Override
public Object visitIfCommand(IfCommand ast, Object obj) {
return layoutTernary("IfCom.", ast.E, ast.C1, ast.C2);
}
public Object visitLetCommand(LetCommand ast, Object obj) {
@Override
public Object visitLetCommand(LetCommand ast, Object obj) {
return layoutBinary("LetCom.", ast.D, ast.C);
}
public Object visitSequentialCommand(SequentialCommand ast, Object obj) {
@Override
public Object visitSequentialCommand(SequentialCommand ast, Object obj) {
return layoutBinary("Seq.Com.", ast.C1, ast.C2);
}
public Object visitWhileCommand(WhileCommand ast, Object obj) {
@Override
public Object visitWhileCommand(WhileCommand ast, Object obj) {
return layoutBinary("WhileCom.", ast.E, ast.C);
}
// Expressions
public Object visitArrayExpression(ArrayExpression ast, Object obj) {
@Override
public Object visitArrayExpression(ArrayExpression ast, Object obj) {
return layoutUnary("ArrayExpr.", ast.AA);
}
public Object visitBinaryExpression(BinaryExpression ast, Object obj) {
@Override
public Object visitBinaryExpression(BinaryExpression ast, Object obj) {
return layoutTernary("Bin.Expr.", ast.E1, ast.O, ast.E2);
}
public Object visitCallExpression(CallExpression ast, Object obj) {
@Override
public Object visitCallExpression(CallExpression ast, Object obj) {
return layoutBinary("CallExpr.", ast.I, ast.APS);
}
public Object visitCharacterExpression(CharacterExpression ast, Object obj) {
@Override
public Object visitCharacterExpression(CharacterExpression ast, Object obj) {
return layoutUnary("Char.Expr.", ast.CL);
}
public Object visitEmptyExpression(EmptyExpression ast, Object obj) {
@Override
public Object visitEmptyExpression(EmptyExpression ast, Object obj) {
return layoutNullary("EmptyExpr.");
}
public Object visitIfExpression(IfExpression ast, Object obj) {
@Override
public Object visitIfExpression(IfExpression ast, Object obj) {
return layoutTernary("IfExpr.", ast.E1, ast.E2, ast.E3);
}
public Object visitIntegerExpression(IntegerExpression ast, Object obj) {
@Override
public Object visitIntegerExpression(IntegerExpression ast, Object obj) {
return layoutUnary("Int.Expr.", ast.IL);
}
public Object visitLetExpression(LetExpression ast, Object obj) {
@Override
public Object visitLetExpression(LetExpression ast, Object obj) {
return layoutBinary("LetExpr.", ast.D, ast.E);
}
public Object visitRecordExpression(RecordExpression ast, Object obj) {
@Override
public Object visitRecordExpression(RecordExpression ast, Object obj) {
return layoutUnary("Rec.Expr.", ast.RA);
}
public Object visitUnaryExpression(UnaryExpression ast, Object obj) {
@Override
public Object visitUnaryExpression(UnaryExpression ast, Object obj) {
return layoutBinary("UnaryExpr.", ast.O, ast.E);
}
public Object visitVnameExpression(VnameExpression ast, Object obj) {
@Override
public Object visitVnameExpression(VnameExpression ast, Object obj) {
return layoutUnary("VnameExpr.", ast.V);
}
// Declarations
public Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, Object obj) {
@Override
public Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, Object obj) {
return layoutQuaternary("Bin.Op.Decl.", ast.O, ast.ARG1, ast.ARG2, ast.RES);
}
public Object visitConstDeclaration(ConstDeclaration ast, Object obj) {
@Override
public Object visitConstDeclaration(ConstDeclaration ast, Object obj) {
return layoutBinary("ConstDecl.", ast.I, ast.E);
}
public Object visitFuncDeclaration(FuncDeclaration ast, Object obj) {
@Override
public Object visitFuncDeclaration(FuncDeclaration ast, Object obj) {
return layoutQuaternary("FuncDecl.", ast.I, ast.FPS, ast.T, ast.E);
}
public Object visitProcDeclaration(ProcDeclaration ast, Object obj) {
@Override
public Object visitProcDeclaration(ProcDeclaration ast, Object obj) {
return layoutTernary("ProcDecl.", ast.I, ast.FPS, ast.C);
}
public Object visitSequentialDeclaration(SequentialDeclaration ast, Object obj) {
@Override
public Object visitSequentialDeclaration(SequentialDeclaration ast, Object obj) {
return layoutBinary("Seq.Decl.", ast.D1, ast.D2);
}
public Object visitTypeDeclaration(TypeDeclaration ast, Object obj) {
@Override
public Object visitTypeDeclaration(TypeDeclaration ast, Object obj) {
return layoutBinary("TypeDecl.", ast.I, ast.T);
}
public Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, Object obj) {
@Override
public Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, Object obj) {
return layoutTernary("UnaryOp.Decl.", ast.O, ast.ARG, ast.RES);
}
public Object visitVarDeclaration(VarDeclaration ast, Object obj) {
@Override
public Object visitVarDeclaration(VarDeclaration ast, Object obj) {
return layoutBinary("VarDecl.", ast.I, ast.T);
}
// Array Aggregates
public Object visitMultipleArrayAggregate(MultipleArrayAggregate ast, Object obj) {
@Override
public Object visitMultipleArrayAggregate(MultipleArrayAggregate ast, Object obj) {
return layoutBinary("Mult.ArrayAgg.", ast.E, ast.AA);
}
public Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object obj) {
@Override
public Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object obj) {
return layoutUnary("Sing.ArrayAgg.", ast.E);
}
// Record Aggregates
public Object visitMultipleRecordAggregate(MultipleRecordAggregate ast, Object obj) {
@Override
public Object visitMultipleRecordAggregate(MultipleRecordAggregate ast, Object obj) {
return layoutTernary("Mult.Rec.Agg.", ast.I, ast.E, ast.RA);
}
public Object visitSingleRecordAggregate(SingleRecordAggregate ast, Object obj) {
@Override
public Object visitSingleRecordAggregate(SingleRecordAggregate ast, Object obj) {
return layoutBinary("Sing.Rec.Agg.", ast.I, ast.E);
}
// Formal Parameters
public Object visitConstFormalParameter(ConstFormalParameter ast, Object obj) {
@Override
public Object visitConstFormalParameter(ConstFormalParameter ast, Object obj) {
return layoutBinary("ConstF.P.", ast.I, ast.T);
}
public Object visitFuncFormalParameter(FuncFormalParameter ast, Object obj) {
@Override
public Object visitFuncFormalParameter(FuncFormalParameter ast, Object obj) {
return layoutTernary("FuncF.P.", ast.I, ast.FPS, ast.T);
}
public Object visitProcFormalParameter(ProcFormalParameter ast, Object obj) {
@Override
public Object visitProcFormalParameter(ProcFormalParameter ast, Object obj) {
return layoutBinary("ProcF.P.", ast.I, ast.FPS);
}
public Object visitVarFormalParameter(VarFormalParameter ast, Object obj) {
@Override
public Object visitVarFormalParameter(VarFormalParameter ast, Object obj) {
return layoutBinary("VarF.P.", ast.I, ast.T);
}
public Object visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, Object obj) {
@Override
public Object visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, Object obj) {
return layoutNullary("EmptyF.P.S.");
}
public Object visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, Object obj) {
@Override
public Object visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, Object obj) {
return layoutBinary("Mult.F.P.S.", ast.FP, ast.FPS);
}
public Object visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, Object obj) {
@Override
public Object visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, Object obj) {
return layoutUnary("Sing.F.P.S.", ast.FP);
}
// Actual Parameters
public Object visitConstActualParameter(ConstActualParameter ast, Object obj) {
@Override
public Object visitConstActualParameter(ConstActualParameter ast, Object obj) {
return layoutUnary("ConstA.P.", ast.E);
}
public Object visitFuncActualParameter(FuncActualParameter ast, Object obj) {
@Override
public Object visitFuncActualParameter(FuncActualParameter ast, Object obj) {
return layoutUnary("FuncA.P.", ast.I);
}
public Object visitProcActualParameter(ProcActualParameter ast, Object obj) {
@Override
public Object visitProcActualParameter(ProcActualParameter ast, Object obj) {
return layoutUnary("ProcA.P.", ast.I);
}
public Object visitVarActualParameter(VarActualParameter ast, Object obj) {
@Override
public Object visitVarActualParameter(VarActualParameter ast, Object obj) {
return layoutUnary("VarA.P.", ast.V);
}
public Object visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, Object obj) {
@Override
public Object visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, Object obj) {
return layoutNullary("EmptyA.P.S.");
}
public Object visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, Object obj) {
@Override
public Object visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, Object obj) {
return layoutBinary("Mult.A.P.S.", ast.AP, ast.APS);
}
public Object visitSingleActualParameterSequence(SingleActualParameterSequence ast, Object obj) {
@Override
public Object visitSingleActualParameterSequence(SingleActualParameterSequence ast, Object obj) {
return layoutUnary("Sing.A.P.S.", ast.AP);
}
// Type Denoters
public Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object obj) {
@Override
public Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object obj) {
return layoutNullary("any");
}
public Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object obj) {
@Override
public Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object obj) {
return layoutBinary("ArrayTypeD.", ast.IL, ast.T);
}
public Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object obj) {
@Override
public Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object obj) {
return layoutNullary("bool");
}
public Object visitCharTypeDenoter(CharTypeDenoter ast, Object obj) {
@Override
public Object visitCharTypeDenoter(CharTypeDenoter ast, Object obj) {
return layoutNullary("char");
}
public Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object obj) {
@Override
public Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object obj) {
return layoutNullary("error");
}
public Object visitSimpleTypeDenoter(SimpleTypeDenoter ast, Object obj) {
@Override
public Object visitSimpleTypeDenoter(SimpleTypeDenoter ast, Object obj) {
return layoutUnary("Sim.TypeD.", ast.I);
}
public Object visitIntTypeDenoter(IntTypeDenoter ast, Object obj) {
@Override
public Object visitIntTypeDenoter(IntTypeDenoter ast, Object obj) {
return layoutNullary("int");
}
public Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object obj) {
@Override
public Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object obj) {
return layoutUnary("Rec.TypeD.", ast.FT);
}
public Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, Object obj) {
@Override
public Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, Object obj) {
return layoutTernary("Mult.F.TypeD.", ast.I, ast.T, ast.FT);
}
public Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, Object obj) {
@Override
public Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, Object obj) {
return layoutBinary("Sing.F.TypeD.", ast.I, ast.T);
}
// Literals, Identifiers and Operators
public Object visitCharacterLiteral(CharacterLiteral ast, Object obj) {
@Override
public Object visitCharacterLiteral(CharacterLiteral ast, Object obj) {
return layoutNullary(ast.spelling);
}
public Object visitIdentifier(Identifier ast, Object obj) {
@Override
public Object visitIdentifier(Identifier ast, Object obj) {
return layoutNullary(ast.spelling);
}
public Object visitIntegerLiteral(IntegerLiteral ast, Object obj) {
@Override
public Object visitIntegerLiteral(IntegerLiteral ast, Object obj) {
return layoutNullary(ast.spelling);
}
public Object visitOperator(Operator ast, Object obj) {
@Override
public Object visitOperator(Operator ast, Object obj) {
return layoutNullary(ast.spelling);
}
// Value-or-variable names
public Object visitDotVname(DotVname ast, Object obj) {
@Override
public Object visitDotVname(DotVname ast, Object obj) {
return layoutBinary("DotVname", ast.I, ast.V);
}
public Object visitSimpleVname(SimpleVname ast, Object obj) {
@Override
public Object visitSimpleVname(SimpleVname ast, Object obj) {
return layoutUnary("Sim.Vname", ast.I);
}
public Object visitSubscriptVname(SubscriptVname ast, Object obj) {
@Override
public Object visitSubscriptVname(SubscriptVname ast, Object obj) {
return layoutBinary("Sub.Vname",
ast.V, ast.E);
}
// Programs
public Object visitProgram(Program ast, Object obj) {
@Override
public Object visitProgram(Program ast, Object obj) {
return layoutUnary("Program", ast.C);
}

@ -23,4 +23,4 @@ class Polyline {
this.dy = dy;
this.link = link;
}
};
}