Clean up source code using default Eclipse settings.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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