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. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/AnyTypeDenoter.java
  3. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ArrayExpression.java
  4. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ArrayTypeDenoter.java
  5. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/AssignCommand.java
  6. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/BinaryExpression.java
  7. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/BinaryOperatorDeclaration.java
  8. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/BoolTypeDenoter.java
  9. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CallCommand.java
  10. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CallExpression.java
  11. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CharTypeDenoter.java
  12. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CharacterExpression.java
  13. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/CharacterLiteral.java
  14. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ConstActualParameter.java
  15. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ConstDeclaration.java
  16. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ConstFormalParameter.java
  17. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/DotVname.java
  18. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyActualParameterSequence.java
  19. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyCommand.java
  20. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyExpression.java
  21. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/EmptyFormalParameterSequence.java
  22. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ErrorTypeDenoter.java
  23. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FieldTypeDenoter.java
  24. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FormalParameter.java
  25. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FormalParameterSequence.java
  26. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FuncActualParameter.java
  27. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FuncDeclaration.java
  28. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/FuncFormalParameter.java
  29. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/Identifier.java
  30. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IfCommand.java
  31. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IfExpression.java
  32. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IntTypeDenoter.java
  33. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IntegerExpression.java
  34. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/IntegerLiteral.java
  35. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/LetCommand.java
  36. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/LetExpression.java
  37. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleActualParameterSequence.java
  38. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleArrayAggregate.java
  39. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleFieldTypeDenoter.java
  40. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleFormalParameterSequence.java
  41. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/MultipleRecordAggregate.java
  42. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/Operator.java
  43. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ProcActualParameter.java
  44. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ProcDeclaration.java
  45. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/ProcFormalParameter.java
  46. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/Program.java
  47. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/RecordExpression.java
  48. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/RecordTypeDenoter.java
  49. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SequentialCommand.java
  50. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SequentialDeclaration.java
  51. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SimpleTypeDenoter.java
  52. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SimpleVname.java
  53. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleActualParameterSequence.java
  54. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleArrayAggregate.java
  55. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleFieldTypeDenoter.java
  56. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleFormalParameterSequence.java
  57. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SingleRecordAggregate.java
  58. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/SubscriptVname.java
  59. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/TypeDeclaration.java
  60. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/TypeDenoter.java
  61. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/UnaryExpression.java
  62. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/UnaryOperatorDeclaration.java
  63. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VarActualParameter.java
  64. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VarDeclaration.java
  65. 2
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VarFormalParameter.java
  66. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/VnameExpression.java
  67. 1
      Triangle.Compiler/src/main/java/Triangle/AbstractSyntaxTrees/WhileCommand.java
  68. 62
      Triangle.Compiler/src/main/java/Triangle/CodeGenerator/Encoder.java
  69. 62
      Triangle.Compiler/src/main/java/Triangle/ContextualAnalyzer/Checker.java
  70. 1
      Triangle.Compiler/src/main/java/Triangle/SyntacticAnalyzer/SourcePosition.java
  71. 2
      Triangle.Compiler/src/main/java/Triangle/SyntacticAnalyzer/SyntaxError.java
  72. 1
      Triangle.Compiler/src/main/java/Triangle/SyntacticAnalyzer/Token.java
  73. 1
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/DrawerFrame.java
  74. 1
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/DrawerPanel.java
  75. 10
      Triangle.Compiler/src/main/java/Triangle/TreeDrawer/DrawingTree.java
  76. 62
      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) { } catch (java.io.IOException s) {
status = failedIOError; status = failedIOError;
} }
data[addr] = (int) currentChar; data[addr] = currentChar;
break; break;
case Machine.putDisplacement: case Machine.putDisplacement:
ST = ST - 1; ST = ST - 1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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