Clean up source code using default Eclipse settings.

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

@ -377,7 +377,7 @@ public class Interpreter {
} catch (java.io.IOException s) { } 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,11 +22,13 @@ public class AnyTypeDenoter extends TypeDenoter {
super(thePosition); super(thePosition);
} }
public Object visit(Visitor v, Object o) { @Override
public Object visit(Visitor v, Object o) {
return v.visitAnyTypeDenoter(this, o); return v.visitAnyTypeDenoter(this, o);
} }
public boolean equals(Object obj) { @Override
public boolean equals(Object obj) {
return false; return false;
} }
} }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -26,11 +26,13 @@ public class MultipleFieldTypeDenoter extends FieldTypeDenoter {
FT = ftAST; FT = ftAST;
} }
public Object visit(Visitor v, Object o) { @Override
public Object visit(Visitor v, Object o) {
return v.visitMultipleFieldTypeDenoter(this, o); return v.visitMultipleFieldTypeDenoter(this, o);
} }
public boolean equals(Object obj) { @Override
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;
return (this.I.spelling.compareTo(ft.I.spelling) == 0) && return (this.I.spelling.compareTo(ft.I.spelling) == 0) &&

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -25,11 +25,13 @@ public class SingleFieldTypeDenoter extends FieldTypeDenoter {
T = tAST; T = tAST;
} }
public Object visit(Visitor v, Object o) { @Override
public Object visit(Visitor v, Object o) {
return v.visitSingleFieldTypeDenoter(this, o); return v.visitSingleFieldTypeDenoter(this, o);
} }
public boolean equals(Object obj) { @Override
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;
return (this.I.spelling.compareTo(ft.I.spelling) == 0) && return (this.I.spelling.compareTo(ft.I.spelling) == 0) &&

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

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

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

@ -25,7 +25,8 @@ public class TypeDeclaration extends Declaration {
T = tAST; T = tAST;
} }
public Object visit(Visitor v, Object o) { @Override
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);
} }
public abstract boolean equals(Object obj); @Override
public abstract boolean equals(Object obj);
} }

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

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

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

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

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

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

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

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

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

@ -28,7 +28,8 @@ public class SourcePosition {
finish = f; finish = f;
} }
public String toString() { @Override
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,7 +50,8 @@ final class Token extends Object {
return tokenTable[kind]; return tokenTable[kind];
} }
public String toString() { @Override
public String toString() {
return "Kind=" + kind + ", spelling=" + spelling + return "Kind=" + kind + ", spelling=" + spelling +
", position=" + position; ", position=" + position;
} }

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

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