Archived
Format code and fix warnings.
This commit is contained in:
@@ -19,17 +19,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class AST {
|
||||
|
||||
public AST(SourcePosition thePosition) {
|
||||
position = thePosition;
|
||||
entity = null;
|
||||
}
|
||||
public AST(SourcePosition thePosition) {
|
||||
position = thePosition;
|
||||
entity = null;
|
||||
}
|
||||
|
||||
public SourcePosition getPosition() {
|
||||
return position;
|
||||
}
|
||||
public SourcePosition getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public abstract Object visit(Visitor v, Object o);
|
||||
public abstract Object visit(Visitor v, Object o);
|
||||
|
||||
public SourcePosition position;
|
||||
public RuntimeEntity entity;
|
||||
public SourcePosition position;
|
||||
public RuntimeEntity entity;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class ActualParameter extends AST {
|
||||
|
||||
public ActualParameter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public ActualParameter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class ActualParameterSequence extends AST {
|
||||
|
||||
public ActualParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public ActualParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class AnyTypeDenoter extends TypeDenoter {
|
||||
|
||||
public AnyTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public AnyTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitAnyTypeDenoter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitAnyTypeDenoter(this, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class ArrayAggregate extends AST {
|
||||
|
||||
public ArrayAggregate(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
elemCount = 0;
|
||||
}
|
||||
public ArrayAggregate(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
elemCount = 0;
|
||||
}
|
||||
|
||||
public int elemCount;
|
||||
public int elemCount;
|
||||
}
|
||||
|
||||
@@ -18,16 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ArrayExpression extends Expression {
|
||||
|
||||
public ArrayExpression(ArrayAggregate aaAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
AA = aaAST;
|
||||
}
|
||||
public ArrayExpression(ArrayAggregate aaAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
AA = aaAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitArrayExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitArrayExpression(this, o);
|
||||
}
|
||||
|
||||
public ArrayAggregate AA;
|
||||
public ArrayAggregate AA;
|
||||
}
|
||||
|
||||
+21
-22
@@ -18,29 +18,28 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ArrayTypeDenoter extends TypeDenoter {
|
||||
|
||||
public ArrayTypeDenoter(IntegerLiteral ilAST, TypeDenoter tAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
IL = ilAST;
|
||||
T = tAST;
|
||||
}
|
||||
public ArrayTypeDenoter(IntegerLiteral ilAST, TypeDenoter tAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
IL = ilAST;
|
||||
T = tAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitArrayTypeDenoter(this, o);
|
||||
}
|
||||
@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;
|
||||
else if (obj != null && obj instanceof ArrayTypeDenoter)
|
||||
return this.IL.spelling.compareTo(((ArrayTypeDenoter) obj).IL.spelling) == 0 &&
|
||||
this.T.equals(((ArrayTypeDenoter) obj).T);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof ErrorTypeDenoter)
|
||||
return true;
|
||||
else if (obj != null && obj instanceof ArrayTypeDenoter)
|
||||
return this.IL.spelling.compareTo(((ArrayTypeDenoter) obj).IL.spelling) == 0
|
||||
&& this.T.equals(((ArrayTypeDenoter) obj).T);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public IntegerLiteral IL;
|
||||
public TypeDenoter T;
|
||||
public IntegerLiteral IL;
|
||||
public TypeDenoter T;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class AssignCommand extends Command {
|
||||
|
||||
public AssignCommand(Vname vAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
E = eAST;
|
||||
}
|
||||
public AssignCommand(Vname vAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitAssignCommand(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitAssignCommand(this, o);
|
||||
}
|
||||
|
||||
public Vname V;
|
||||
public Expression E;
|
||||
public Vname V;
|
||||
public Expression E;
|
||||
}
|
||||
|
||||
+12
-13
@@ -18,19 +18,18 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class BinaryExpression extends Expression {
|
||||
|
||||
public BinaryExpression(Expression e1AST, Operator oAST, Expression e2AST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
E1 = e1AST;
|
||||
E2 = e2AST;
|
||||
}
|
||||
public BinaryExpression(Expression e1AST, Operator oAST, Expression e2AST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
E1 = e1AST;
|
||||
E2 = e2AST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitBinaryExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitBinaryExpression(this, o);
|
||||
}
|
||||
|
||||
public Expression E1, E2;
|
||||
public Operator O;
|
||||
public Expression E1, E2;
|
||||
public Operator O;
|
||||
}
|
||||
|
||||
+14
-15
@@ -18,21 +18,20 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class BinaryOperatorDeclaration extends Declaration {
|
||||
|
||||
public BinaryOperatorDeclaration(Operator oAST, TypeDenoter arg1AST,
|
||||
TypeDenoter arg2AST, TypeDenoter resultAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
ARG1 = arg1AST;
|
||||
ARG2 = arg2AST;
|
||||
RES = resultAST;
|
||||
}
|
||||
public BinaryOperatorDeclaration(Operator oAST, TypeDenoter arg1AST, TypeDenoter arg2AST, TypeDenoter resultAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
ARG1 = arg1AST;
|
||||
ARG2 = arg2AST;
|
||||
RES = resultAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitBinaryOperatorDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitBinaryOperatorDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Operator O;
|
||||
public TypeDenoter ARG1, ARG2, RES;
|
||||
public Operator O;
|
||||
public TypeDenoter ARG1, ARG2, RES;
|
||||
}
|
||||
|
||||
@@ -18,20 +18,20 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class BoolTypeDenoter extends TypeDenoter {
|
||||
|
||||
public BoolTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public BoolTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitBoolTypeDenoter(this, o);
|
||||
}
|
||||
@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;
|
||||
else
|
||||
return ((obj != null) && (obj instanceof BoolTypeDenoter));
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof ErrorTypeDenoter))
|
||||
return true;
|
||||
else
|
||||
return ((obj != null) && (obj instanceof BoolTypeDenoter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class CallCommand extends Command {
|
||||
|
||||
public CallCommand(Identifier iAST, ActualParameterSequence apsAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
APS = apsAST;
|
||||
}
|
||||
public CallCommand(Identifier iAST, ActualParameterSequence apsAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
APS = apsAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCallCommand(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCallCommand(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public ActualParameterSequence APS;
|
||||
public Identifier I;
|
||||
public ActualParameterSequence APS;
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class CallExpression extends Expression {
|
||||
|
||||
public CallExpression(Identifier iAST, ActualParameterSequence apsAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
APS = apsAST;
|
||||
}
|
||||
public CallExpression(Identifier iAST, ActualParameterSequence apsAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
APS = apsAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCallExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCallExpression(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public ActualParameterSequence APS;
|
||||
public Identifier I;
|
||||
public ActualParameterSequence APS;
|
||||
}
|
||||
|
||||
@@ -18,20 +18,20 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class CharTypeDenoter extends TypeDenoter {
|
||||
|
||||
public CharTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public CharTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCharTypeDenoter(this, o);
|
||||
}
|
||||
@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;
|
||||
else
|
||||
return (obj != null && obj instanceof CharTypeDenoter);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof ErrorTypeDenoter)
|
||||
return true;
|
||||
else
|
||||
return (obj != null && obj instanceof CharTypeDenoter);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class CharacterExpression extends Expression {
|
||||
|
||||
public CharacterExpression(CharacterLiteral clAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
CL = clAST;
|
||||
}
|
||||
public CharacterExpression(CharacterLiteral clAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
CL = clAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCharacterExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCharacterExpression(this, o);
|
||||
}
|
||||
|
||||
public CharacterLiteral CL;
|
||||
public CharacterLiteral CL;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class CharacterLiteral extends Terminal {
|
||||
|
||||
public CharacterLiteral(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
}
|
||||
public CharacterLiteral(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCharacterLiteral(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitCharacterLiteral(this, o);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class Command extends AST {
|
||||
|
||||
public Command(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public Command(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ConstActualParameter extends ActualParameter {
|
||||
|
||||
public ConstActualParameter(Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
}
|
||||
public ConstActualParameter(Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitConstActualParameter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitConstActualParameter(this, o);
|
||||
}
|
||||
|
||||
public Expression E;
|
||||
public Expression E;
|
||||
}
|
||||
|
||||
+11
-12
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ConstDeclaration extends Declaration {
|
||||
|
||||
public ConstDeclaration(Identifier iAST, Expression eAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
E = eAST;
|
||||
}
|
||||
public ConstDeclaration(Identifier iAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitConstDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitConstDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Expression E;
|
||||
public Identifier I;
|
||||
public Expression E;
|
||||
}
|
||||
|
||||
+19
-20
@@ -18,27 +18,26 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ConstFormalParameter extends FormalParameter {
|
||||
|
||||
public ConstFormalParameter(Identifier iAST, TypeDenoter tAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
public ConstFormalParameter(Identifier iAST, TypeDenoter tAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitConstFormalParameter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitConstFormalParameter(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object fpAST) {
|
||||
if (fpAST instanceof ConstFormalParameter) {
|
||||
ConstFormalParameter cfpAST = (ConstFormalParameter) fpAST;
|
||||
return T.equals(cfpAST.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object fpAST) {
|
||||
if (fpAST instanceof ConstFormalParameter) {
|
||||
ConstFormalParameter cfpAST = (ConstFormalParameter) fpAST;
|
||||
return T.equals(cfpAST.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class Declaration extends AST {
|
||||
|
||||
public Declaration(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
duplicated = false;
|
||||
}
|
||||
public Declaration(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
duplicated = false;
|
||||
}
|
||||
|
||||
public boolean duplicated;
|
||||
public boolean duplicated;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class DotVname extends Vname {
|
||||
|
||||
public DotVname(Vname vAST, Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
I = iAST;
|
||||
}
|
||||
public DotVname(Vname vAST, Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
I = iAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitDotVname(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitDotVname(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Vname V;
|
||||
public Identifier I;
|
||||
public Vname V;
|
||||
}
|
||||
|
||||
+7
-7
@@ -18,12 +18,12 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class EmptyActualParameterSequence extends ActualParameterSequence {
|
||||
|
||||
public EmptyActualParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public EmptyActualParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyActualParameterSequence(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyActualParameterSequence(this, o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class EmptyCommand extends Command {
|
||||
|
||||
public EmptyCommand(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public EmptyCommand(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyCommand(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyCommand(this, o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class EmptyExpression extends Expression {
|
||||
|
||||
public EmptyExpression(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public EmptyExpression(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyExpression(this, o);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class EmptyFormalParameterSequence extends FormalParameterSequence {
|
||||
|
||||
public EmptyFormalParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public EmptyFormalParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyFormalParameterSequence(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitEmptyFormalParameterSequence(this, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object fpsAST) {
|
||||
return (fpsAST instanceof EmptyFormalParameterSequence);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object fpsAST) {
|
||||
return (fpsAST instanceof EmptyFormalParameterSequence);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ErrorTypeDenoter extends TypeDenoter {
|
||||
|
||||
public ErrorTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public ErrorTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitErrorTypeDenoter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitErrorTypeDenoter(this, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class Expression extends AST {
|
||||
|
||||
public Expression(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
type = null;
|
||||
}
|
||||
public Expression(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
type = null;
|
||||
}
|
||||
|
||||
public TypeDenoter type;
|
||||
public TypeDenoter type;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class FieldTypeDenoter extends TypeDenoter {
|
||||
|
||||
public FieldTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public FieldTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object obj);
|
||||
@Override
|
||||
public abstract boolean equals(Object obj);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class FormalParameter extends Declaration {
|
||||
|
||||
public FormalParameter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public FormalParameter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object fpAST);
|
||||
@Override
|
||||
public abstract boolean equals(Object fpAST);
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -18,10 +18,10 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class FormalParameterSequence extends AST {
|
||||
|
||||
public FormalParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public FormalParameterSequence(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object fpsAST);
|
||||
@Override
|
||||
public abstract boolean equals(Object fpsAST);
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class FuncActualParameter extends ActualParameter {
|
||||
|
||||
public FuncActualParameter(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
public FuncActualParameter(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitFuncActualParameter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitFuncActualParameter(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Identifier I;
|
||||
}
|
||||
|
||||
@@ -18,23 +18,22 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class FuncDeclaration extends Declaration {
|
||||
|
||||
public FuncDeclaration(Identifier iAST, FormalParameterSequence fpsAST,
|
||||
TypeDenoter tAST, Expression eAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
T = tAST;
|
||||
E = eAST;
|
||||
}
|
||||
public FuncDeclaration(Identifier iAST, FormalParameterSequence fpsAST, TypeDenoter tAST, Expression eAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
T = tAST;
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitFuncDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitFuncDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
public TypeDenoter T;
|
||||
public Expression E;
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
public TypeDenoter T;
|
||||
public Expression E;
|
||||
}
|
||||
|
||||
+22
-22
@@ -18,29 +18,29 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class FuncFormalParameter extends FormalParameter {
|
||||
|
||||
public FuncFormalParameter(Identifier iAST, FormalParameterSequence fpsAST,
|
||||
TypeDenoter tAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
T = tAST;
|
||||
}
|
||||
public FuncFormalParameter(Identifier iAST, FormalParameterSequence fpsAST, TypeDenoter tAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
T = tAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitFuncFormalParameter(this, o);
|
||||
}
|
||||
@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;
|
||||
return FPS.equals(ffpAST.FPS) && T.equals(ffpAST.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object fpAST) {
|
||||
if (fpAST instanceof FuncFormalParameter) {
|
||||
FuncFormalParameter ffpAST = (FuncFormalParameter) fpAST;
|
||||
return FPS.equals(ffpAST.FPS) && T.equals(ffpAST.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
public TypeDenoter T;
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
public TypeDenoter T;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class Identifier extends Terminal {
|
||||
|
||||
public Identifier(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
type = null;
|
||||
decl = null;
|
||||
}
|
||||
public Identifier(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
type = null;
|
||||
decl = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIdentifier(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIdentifier(this, o);
|
||||
}
|
||||
|
||||
public TypeDenoter type;
|
||||
public AST decl; // Either a Declaration or a FieldTypeDenoter
|
||||
public TypeDenoter type;
|
||||
public AST decl; // Either a Declaration or a FieldTypeDenoter
|
||||
}
|
||||
|
||||
@@ -18,19 +18,18 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class IfCommand extends Command {
|
||||
|
||||
public IfCommand(Expression eAST, Command c1AST, Command c2AST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
C1 = c1AST;
|
||||
C2 = c2AST;
|
||||
}
|
||||
public IfCommand(Expression eAST, Command c1AST, Command c2AST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
C1 = c1AST;
|
||||
C2 = c2AST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIfCommand(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIfCommand(this, o);
|
||||
}
|
||||
|
||||
public Expression E;
|
||||
public Command C1, C2;
|
||||
public Expression E;
|
||||
public Command C1, C2;
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class IfExpression extends Expression {
|
||||
|
||||
public IfExpression(Expression e1AST, Expression e2AST, Expression e3AST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E1 = e1AST;
|
||||
E2 = e2AST;
|
||||
E3 = e3AST;
|
||||
}
|
||||
public IfExpression(Expression e1AST, Expression e2AST, Expression e3AST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E1 = e1AST;
|
||||
E2 = e2AST;
|
||||
E3 = e3AST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIfExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIfExpression(this, o);
|
||||
}
|
||||
|
||||
public Expression E1, E2, E3;
|
||||
public Expression E1, E2, E3;
|
||||
}
|
||||
|
||||
@@ -18,20 +18,20 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class IntTypeDenoter extends TypeDenoter {
|
||||
|
||||
public IntTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public IntTypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIntTypeDenoter(this, o);
|
||||
}
|
||||
@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;
|
||||
else
|
||||
return (obj != null && obj instanceof IntTypeDenoter);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof ErrorTypeDenoter)
|
||||
return true;
|
||||
else
|
||||
return (obj != null && obj instanceof IntTypeDenoter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class IntegerExpression extends Expression {
|
||||
|
||||
public IntegerExpression(IntegerLiteral ilAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
IL = ilAST;
|
||||
}
|
||||
public IntegerExpression(IntegerLiteral ilAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
IL = ilAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIntegerExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIntegerExpression(this, o);
|
||||
}
|
||||
|
||||
public IntegerLiteral IL;
|
||||
public IntegerLiteral IL;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class IntegerLiteral extends Terminal {
|
||||
|
||||
public IntegerLiteral(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
}
|
||||
public IntegerLiteral(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIntegerLiteral(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitIntegerLiteral(this, o);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class LetCommand extends Command {
|
||||
|
||||
public LetCommand(Declaration dAST, Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
D = dAST;
|
||||
C = cAST;
|
||||
}
|
||||
public LetCommand(Declaration dAST, Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
D = dAST;
|
||||
C = cAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitLetCommand(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitLetCommand(this, o);
|
||||
}
|
||||
|
||||
public Declaration D;
|
||||
public Command C;
|
||||
public Declaration D;
|
||||
public Command C;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class LetExpression extends Expression {
|
||||
|
||||
public LetExpression(Declaration dAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
D = dAST;
|
||||
E = eAST;
|
||||
}
|
||||
public LetExpression(Declaration dAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
D = dAST;
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitLetExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitLetExpression(this, o);
|
||||
}
|
||||
|
||||
public Declaration D;
|
||||
public Expression E;
|
||||
public Declaration D;
|
||||
public Expression E;
|
||||
}
|
||||
|
||||
+12
-12
@@ -18,18 +18,18 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class MultipleActualParameterSequence extends ActualParameterSequence {
|
||||
|
||||
public MultipleActualParameterSequence(ActualParameter apAST, ActualParameterSequence apsAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
AP = apAST;
|
||||
APS = apsAST;
|
||||
}
|
||||
public MultipleActualParameterSequence(ActualParameter apAST, ActualParameterSequence apsAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
AP = apAST;
|
||||
APS = apsAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleActualParameterSequence(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleActualParameterSequence(this, o);
|
||||
}
|
||||
|
||||
public ActualParameter AP;
|
||||
public ActualParameterSequence APS;
|
||||
public ActualParameter AP;
|
||||
public ActualParameterSequence APS;
|
||||
}
|
||||
|
||||
+11
-12
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class MultipleArrayAggregate extends ArrayAggregate {
|
||||
|
||||
public MultipleArrayAggregate(Expression eAST, ArrayAggregate aaAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
AA = aaAST;
|
||||
}
|
||||
public MultipleArrayAggregate(Expression eAST, ArrayAggregate aaAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
AA = aaAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleArrayAggregate(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleArrayAggregate(this, o);
|
||||
}
|
||||
|
||||
public Expression E;
|
||||
public ArrayAggregate AA;
|
||||
public Expression E;
|
||||
public ArrayAggregate AA;
|
||||
}
|
||||
|
||||
+22
-24
@@ -18,31 +18,29 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class MultipleFieldTypeDenoter extends FieldTypeDenoter {
|
||||
|
||||
public MultipleFieldTypeDenoter(Identifier iAST, TypeDenoter tAST, FieldTypeDenoter ftAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
FT = ftAST;
|
||||
}
|
||||
public MultipleFieldTypeDenoter(Identifier iAST, TypeDenoter tAST, FieldTypeDenoter ftAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
FT = ftAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleFieldTypeDenoter(this, o);
|
||||
}
|
||||
@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;
|
||||
return (this.I.spelling.compareTo(ft.I.spelling) == 0) &&
|
||||
this.T.equals(ft.T) &&
|
||||
this.FT.equals(ft.FT);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof MultipleFieldTypeDenoter) {
|
||||
MultipleFieldTypeDenoter ft = (MultipleFieldTypeDenoter) obj;
|
||||
return (this.I.spelling.compareTo(ft.I.spelling) == 0) && this.T.equals(ft.T) && this.FT.equals(ft.FT);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
public FieldTypeDenoter FT;
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
public FieldTypeDenoter FT;
|
||||
}
|
||||
|
||||
+20
-20
@@ -18,27 +18,27 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class MultipleFormalParameterSequence extends FormalParameterSequence {
|
||||
|
||||
public MultipleFormalParameterSequence(FormalParameter fpAST, FormalParameterSequence fpsAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
FP = fpAST;
|
||||
FPS = fpsAST;
|
||||
}
|
||||
public MultipleFormalParameterSequence(FormalParameter fpAST, FormalParameterSequence fpsAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
FP = fpAST;
|
||||
FPS = fpsAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleFormalParameterSequence(this, o);
|
||||
}
|
||||
@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;
|
||||
return FP.equals(mfpsAST.FP) && FPS.equals(mfpsAST.FPS);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object fpsAST) {
|
||||
if (fpsAST instanceof MultipleFormalParameterSequence) {
|
||||
MultipleFormalParameterSequence mfpsAST = (MultipleFormalParameterSequence) fpsAST;
|
||||
return FP.equals(mfpsAST.FP) && FPS.equals(mfpsAST.FPS);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
public FormalParameter FP;
|
||||
public FormalParameterSequence FPS;
|
||||
public FormalParameter FP;
|
||||
public FormalParameterSequence FPS;
|
||||
}
|
||||
|
||||
+14
-14
@@ -18,20 +18,20 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class MultipleRecordAggregate extends RecordAggregate {
|
||||
|
||||
public MultipleRecordAggregate(Identifier iAST, Expression eAST, RecordAggregate raAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
E = eAST;
|
||||
RA = raAST;
|
||||
}
|
||||
public MultipleRecordAggregate(Identifier iAST, Expression eAST, RecordAggregate raAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
E = eAST;
|
||||
RA = raAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleRecordAggregate(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitMultipleRecordAggregate(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Expression E;
|
||||
public RecordAggregate RA;
|
||||
public Identifier I;
|
||||
public Expression E;
|
||||
public RecordAggregate RA;
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class Operator extends Terminal {
|
||||
|
||||
public Operator(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
decl = null;
|
||||
}
|
||||
public Operator(String theSpelling, SourcePosition thePosition) {
|
||||
super(theSpelling, thePosition);
|
||||
decl = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitOperator(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitOperator(this, o);
|
||||
}
|
||||
|
||||
public Declaration decl;
|
||||
public Declaration decl;
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ProcActualParameter extends ActualParameter {
|
||||
|
||||
public ProcActualParameter(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
public ProcActualParameter(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProcActualParameter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProcActualParameter(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Identifier I;
|
||||
}
|
||||
|
||||
@@ -18,20 +18,19 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ProcDeclaration extends Declaration {
|
||||
|
||||
public ProcDeclaration(Identifier iAST, FormalParameterSequence fpsAST,
|
||||
Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
C = cAST;
|
||||
}
|
||||
public ProcDeclaration(Identifier iAST, FormalParameterSequence fpsAST, Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
C = cAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProcDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProcDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
public Command C;
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
public Command C;
|
||||
}
|
||||
|
||||
+19
-20
@@ -18,27 +18,26 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ProcFormalParameter extends FormalParameter {
|
||||
|
||||
public ProcFormalParameter(Identifier iAST, FormalParameterSequence fpsAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
}
|
||||
public ProcFormalParameter(Identifier iAST, FormalParameterSequence fpsAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
FPS = fpsAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProcFormalParameter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProcFormalParameter(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
public Identifier I;
|
||||
public FormalParameterSequence FPS;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object fpAST) {
|
||||
if (fpAST instanceof ProcFormalParameter) {
|
||||
ProcFormalParameter pfpAST = (ProcFormalParameter) fpAST;
|
||||
return FPS.equals(pfpAST.FPS);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object fpAST) {
|
||||
if (fpAST instanceof ProcFormalParameter) {
|
||||
ProcFormalParameter pfpAST = (ProcFormalParameter) fpAST;
|
||||
return FPS.equals(pfpAST.FPS);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class Program extends AST {
|
||||
|
||||
public Program(Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
C = cAST;
|
||||
}
|
||||
public Program(Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
C = cAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProgram(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitProgram(this, o);
|
||||
}
|
||||
|
||||
public Command C;
|
||||
public Command C;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class RecordAggregate extends AST {
|
||||
|
||||
public RecordAggregate(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
type = null;
|
||||
}
|
||||
public RecordAggregate(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
type = null;
|
||||
}
|
||||
|
||||
public FieldTypeDenoter type;
|
||||
public FieldTypeDenoter type;
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class RecordExpression extends Expression {
|
||||
|
||||
public RecordExpression(RecordAggregate raAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
RA = raAST;
|
||||
}
|
||||
public RecordExpression(RecordAggregate raAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
RA = raAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitRecordExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitRecordExpression(this, o);
|
||||
}
|
||||
|
||||
public RecordAggregate RA;
|
||||
public RecordAggregate RA;
|
||||
}
|
||||
|
||||
+18
-18
@@ -18,25 +18,25 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class RecordTypeDenoter extends TypeDenoter {
|
||||
|
||||
public RecordTypeDenoter(FieldTypeDenoter ftAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
FT = ftAST;
|
||||
}
|
||||
public RecordTypeDenoter(FieldTypeDenoter ftAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
FT = ftAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitRecordTypeDenoter(this, o);
|
||||
}
|
||||
@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;
|
||||
else if (obj != null && obj instanceof RecordTypeDenoter)
|
||||
return this.FT.equals(((RecordTypeDenoter) obj).FT);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof ErrorTypeDenoter)
|
||||
return true;
|
||||
else if (obj != null && obj instanceof RecordTypeDenoter)
|
||||
return this.FT.equals(((RecordTypeDenoter) obj).FT);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public FieldTypeDenoter FT;
|
||||
public FieldTypeDenoter FT;
|
||||
}
|
||||
|
||||
+10
-10
@@ -18,16 +18,16 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SequentialCommand extends Command {
|
||||
|
||||
public SequentialCommand(Command c1AST, Command c2AST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
C1 = c1AST;
|
||||
C2 = c2AST;
|
||||
}
|
||||
public SequentialCommand(Command c1AST, Command c2AST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
C1 = c1AST;
|
||||
C2 = c2AST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSequentialCommand(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSequentialCommand(this, o);
|
||||
}
|
||||
|
||||
public Command C1, C2;
|
||||
public Command C1, C2;
|
||||
}
|
||||
|
||||
+10
-11
@@ -18,17 +18,16 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SequentialDeclaration extends Declaration {
|
||||
|
||||
public SequentialDeclaration(Declaration d1AST, Declaration d2AST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
D1 = d1AST;
|
||||
D2 = d2AST;
|
||||
}
|
||||
public SequentialDeclaration(Declaration d1AST, Declaration d2AST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
D1 = d1AST;
|
||||
D2 = d2AST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSequentialDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSequentialDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Declaration D1, D2;
|
||||
public Declaration D1, D2;
|
||||
}
|
||||
|
||||
+13
-13
@@ -18,20 +18,20 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SimpleTypeDenoter extends TypeDenoter {
|
||||
|
||||
public SimpleTypeDenoter(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
public SimpleTypeDenoter(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSimpleTypeDenoter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSimpleTypeDenoter(this, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return false; // should not happen
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return false; // should not happen
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Identifier I;
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SimpleVname extends Vname {
|
||||
|
||||
public SimpleVname(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
public SimpleVname(Identifier iAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSimpleVname(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSimpleVname(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Identifier I;
|
||||
}
|
||||
|
||||
+9
-10
@@ -18,16 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SingleActualParameterSequence extends ActualParameterSequence {
|
||||
|
||||
public SingleActualParameterSequence(ActualParameter apAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
AP = apAST;
|
||||
}
|
||||
public SingleActualParameterSequence(ActualParameter apAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
AP = apAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleActualParameterSequence(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleActualParameterSequence(this, o);
|
||||
}
|
||||
|
||||
public ActualParameter AP;
|
||||
public ActualParameter AP;
|
||||
}
|
||||
|
||||
+9
-10
@@ -18,16 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SingleArrayAggregate extends ArrayAggregate {
|
||||
|
||||
public SingleArrayAggregate(Expression eAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
}
|
||||
public SingleArrayAggregate(Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleArrayAggregate(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleArrayAggregate(this, o);
|
||||
}
|
||||
|
||||
public Expression E;
|
||||
public Expression E;
|
||||
}
|
||||
|
||||
+19
-21
@@ -18,28 +18,26 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SingleFieldTypeDenoter extends FieldTypeDenoter {
|
||||
|
||||
public SingleFieldTypeDenoter(Identifier iAST, TypeDenoter tAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
public SingleFieldTypeDenoter(Identifier iAST, TypeDenoter tAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleFieldTypeDenoter(this, o);
|
||||
}
|
||||
@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;
|
||||
return (this.I.spelling.compareTo(ft.I.spelling) == 0) &&
|
||||
this.T.equals(ft.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof SingleFieldTypeDenoter) {
|
||||
SingleFieldTypeDenoter ft = (SingleFieldTypeDenoter) obj;
|
||||
return (this.I.spelling.compareTo(ft.I.spelling) == 0) && this.T.equals(ft.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
}
|
||||
|
||||
+17
-18
@@ -18,25 +18,24 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SingleFormalParameterSequence extends FormalParameterSequence {
|
||||
|
||||
public SingleFormalParameterSequence(FormalParameter fpAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
FP = fpAST;
|
||||
}
|
||||
public SingleFormalParameterSequence(FormalParameter fpAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
FP = fpAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleFormalParameterSequence(this, o);
|
||||
}
|
||||
@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;
|
||||
return FP.equals(sfpsAST.FP);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object fpsAST) {
|
||||
if (fpsAST instanceof SingleFormalParameterSequence) {
|
||||
SingleFormalParameterSequence sfpsAST = (SingleFormalParameterSequence) fpsAST;
|
||||
return FP.equals(sfpsAST.FP);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
public FormalParameter FP;
|
||||
public FormalParameter FP;
|
||||
}
|
||||
|
||||
+11
-12
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SingleRecordAggregate extends RecordAggregate {
|
||||
|
||||
public SingleRecordAggregate(Identifier iAST, Expression eAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
E = eAST;
|
||||
}
|
||||
public SingleRecordAggregate(Identifier iAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleRecordAggregate(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSingleRecordAggregate(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public Expression E;
|
||||
public Identifier I;
|
||||
public Expression E;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class SubscriptVname extends Vname {
|
||||
|
||||
public SubscriptVname(Vname vAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
E = eAST;
|
||||
}
|
||||
public SubscriptVname(Vname vAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSubscriptVname(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitSubscriptVname(this, o);
|
||||
}
|
||||
|
||||
public Expression E;
|
||||
public Vname V;
|
||||
public Expression E;
|
||||
public Vname V;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
abstract public class Terminal extends AST {
|
||||
|
||||
public Terminal(String theSpelling, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
spelling = theSpelling;
|
||||
}
|
||||
public Terminal(String theSpelling, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
spelling = theSpelling;
|
||||
}
|
||||
|
||||
public String spelling;
|
||||
public String spelling;
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class TypeDeclaration extends Declaration {
|
||||
|
||||
public TypeDeclaration(Identifier iAST, TypeDenoter tAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
public TypeDeclaration(Identifier iAST, TypeDenoter tAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitTypeDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitTypeDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class TypeDenoter extends AST {
|
||||
|
||||
public TypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
public TypeDenoter(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object obj);
|
||||
@Override
|
||||
public abstract boolean equals(Object obj);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class UnaryExpression extends Expression {
|
||||
|
||||
public UnaryExpression(Operator oAST, Expression eAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
E = eAST;
|
||||
}
|
||||
public UnaryExpression(Operator oAST, Expression eAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
E = eAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitUnaryExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitUnaryExpression(this, o);
|
||||
}
|
||||
|
||||
public Expression E;
|
||||
public Operator O;
|
||||
public Expression E;
|
||||
public Operator O;
|
||||
}
|
||||
|
||||
+13
-13
@@ -18,19 +18,19 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class UnaryOperatorDeclaration extends Declaration {
|
||||
|
||||
public UnaryOperatorDeclaration(Operator oAST, TypeDenoter argAST,
|
||||
TypeDenoter resultAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
ARG = argAST;
|
||||
RES = resultAST;
|
||||
}
|
||||
public UnaryOperatorDeclaration(Operator oAST, TypeDenoter argAST, TypeDenoter resultAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
O = oAST;
|
||||
ARG = argAST;
|
||||
RES = resultAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitUnaryOperatorDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitUnaryOperatorDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Operator O;
|
||||
public TypeDenoter ARG, RES;
|
||||
public Operator O;
|
||||
public TypeDenoter ARG, RES;
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class VarActualParameter extends ActualParameter {
|
||||
|
||||
public VarActualParameter(Vname vAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
}
|
||||
public VarActualParameter(Vname vAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVarActualParameter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVarActualParameter(this, o);
|
||||
}
|
||||
|
||||
public Vname V;
|
||||
public Vname V;
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class VarDeclaration extends Declaration {
|
||||
|
||||
public VarDeclaration(Identifier iAST, TypeDenoter tAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
public VarDeclaration(Identifier iAST, TypeDenoter tAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVarDeclaration(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVarDeclaration(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
}
|
||||
|
||||
+19
-20
@@ -18,27 +18,26 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class VarFormalParameter extends FormalParameter {
|
||||
|
||||
public VarFormalParameter(Identifier iAST, TypeDenoter tAST,
|
||||
SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
public VarFormalParameter(Identifier iAST, TypeDenoter tAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
I = iAST;
|
||||
T = tAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVarFormalParameter(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVarFormalParameter(this, o);
|
||||
}
|
||||
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
public Identifier I;
|
||||
public TypeDenoter T;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object fpAST) {
|
||||
if (fpAST instanceof VarFormalParameter) {
|
||||
VarFormalParameter vfpAST = (VarFormalParameter) fpAST;
|
||||
return T.equals(vfpAST.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object fpAST) {
|
||||
if (fpAST instanceof VarFormalParameter) {
|
||||
VarFormalParameter vfpAST = (VarFormalParameter) fpAST;
|
||||
return T.equals(vfpAST.T);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,139 +16,139 @@ package Triangle.AbstractSyntaxTrees;
|
||||
|
||||
public interface Visitor {
|
||||
|
||||
// Commands
|
||||
public abstract Object visitAssignCommand(AssignCommand ast, Object o);
|
||||
// Commands
|
||||
public abstract Object visitAssignCommand(AssignCommand ast, Object o);
|
||||
|
||||
public abstract Object visitCallCommand(CallCommand ast, Object o);
|
||||
public abstract Object visitCallCommand(CallCommand ast, Object o);
|
||||
|
||||
public abstract Object visitEmptyCommand(EmptyCommand ast, Object o);
|
||||
public abstract Object visitEmptyCommand(EmptyCommand ast, Object o);
|
||||
|
||||
public abstract Object visitIfCommand(IfCommand ast, Object o);
|
||||
public abstract Object visitIfCommand(IfCommand ast, Object o);
|
||||
|
||||
public abstract Object visitLetCommand(LetCommand ast, Object o);
|
||||
public abstract Object visitLetCommand(LetCommand ast, Object o);
|
||||
|
||||
public abstract Object visitSequentialCommand(SequentialCommand ast, Object o);
|
||||
public abstract Object visitSequentialCommand(SequentialCommand ast, Object o);
|
||||
|
||||
public abstract Object visitWhileCommand(WhileCommand ast, Object o);
|
||||
public abstract Object visitWhileCommand(WhileCommand ast, Object o);
|
||||
|
||||
// Expressions
|
||||
public abstract Object visitArrayExpression(ArrayExpression ast, Object o);
|
||||
// Expressions
|
||||
public abstract Object visitArrayExpression(ArrayExpression ast, Object o);
|
||||
|
||||
public abstract Object visitBinaryExpression(BinaryExpression ast, Object o);
|
||||
public abstract Object visitBinaryExpression(BinaryExpression ast, Object o);
|
||||
|
||||
public abstract Object visitCallExpression(CallExpression ast, Object o);
|
||||
public abstract Object visitCallExpression(CallExpression ast, Object o);
|
||||
|
||||
public abstract Object visitCharacterExpression(CharacterExpression ast, Object o);
|
||||
public abstract Object visitCharacterExpression(CharacterExpression ast, Object o);
|
||||
|
||||
public abstract Object visitEmptyExpression(EmptyExpression ast, Object o);
|
||||
public abstract Object visitEmptyExpression(EmptyExpression ast, Object o);
|
||||
|
||||
public abstract Object visitIfExpression(IfExpression ast, Object o);
|
||||
public abstract Object visitIfExpression(IfExpression ast, Object o);
|
||||
|
||||
public abstract Object visitIntegerExpression(IntegerExpression ast, Object o);
|
||||
public abstract Object visitIntegerExpression(IntegerExpression ast, Object o);
|
||||
|
||||
public abstract Object visitLetExpression(LetExpression ast, Object o);
|
||||
public abstract Object visitLetExpression(LetExpression ast, Object o);
|
||||
|
||||
public abstract Object visitRecordExpression(RecordExpression ast, Object o);
|
||||
public abstract Object visitRecordExpression(RecordExpression ast, Object o);
|
||||
|
||||
public abstract Object visitUnaryExpression(UnaryExpression ast, Object o);
|
||||
public abstract Object visitUnaryExpression(UnaryExpression ast, Object o);
|
||||
|
||||
public abstract Object visitVnameExpression(VnameExpression ast, Object o);
|
||||
public abstract Object visitVnameExpression(VnameExpression ast, Object o);
|
||||
|
||||
// Declarations
|
||||
public abstract Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, Object o);
|
||||
// Declarations
|
||||
public abstract Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, Object o);
|
||||
|
||||
public abstract Object visitConstDeclaration(ConstDeclaration ast, Object o);
|
||||
public abstract Object visitConstDeclaration(ConstDeclaration ast, Object o);
|
||||
|
||||
public abstract Object visitFuncDeclaration(FuncDeclaration ast, Object o);
|
||||
public abstract Object visitFuncDeclaration(FuncDeclaration ast, Object o);
|
||||
|
||||
public abstract Object visitProcDeclaration(ProcDeclaration ast, Object o);
|
||||
public abstract Object visitProcDeclaration(ProcDeclaration ast, Object o);
|
||||
|
||||
public abstract Object visitSequentialDeclaration(SequentialDeclaration ast, Object o);
|
||||
public abstract Object visitSequentialDeclaration(SequentialDeclaration ast, Object o);
|
||||
|
||||
public abstract Object visitTypeDeclaration(TypeDeclaration ast, Object o);
|
||||
public abstract Object visitTypeDeclaration(TypeDeclaration ast, Object o);
|
||||
|
||||
public abstract Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, Object o);
|
||||
public abstract Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, Object o);
|
||||
|
||||
public abstract Object visitVarDeclaration(VarDeclaration ast, Object o);
|
||||
public abstract Object visitVarDeclaration(VarDeclaration ast, Object o);
|
||||
|
||||
// Array Aggregates
|
||||
public abstract Object visitMultipleArrayAggregate(MultipleArrayAggregate ast, Object o);
|
||||
// Array Aggregates
|
||||
public abstract Object visitMultipleArrayAggregate(MultipleArrayAggregate ast, Object o);
|
||||
|
||||
public abstract Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object o);
|
||||
public abstract Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object o);
|
||||
|
||||
// Record Aggregates
|
||||
public abstract Object visitMultipleRecordAggregate(MultipleRecordAggregate ast, Object o);
|
||||
// Record Aggregates
|
||||
public abstract Object visitMultipleRecordAggregate(MultipleRecordAggregate ast, Object o);
|
||||
|
||||
public abstract Object visitSingleRecordAggregate(SingleRecordAggregate ast, Object o);
|
||||
public abstract Object visitSingleRecordAggregate(SingleRecordAggregate ast, Object o);
|
||||
|
||||
// Formal Parameters
|
||||
public abstract Object visitConstFormalParameter(ConstFormalParameter ast, Object o);
|
||||
// Formal Parameters
|
||||
public abstract Object visitConstFormalParameter(ConstFormalParameter ast, Object o);
|
||||
|
||||
public abstract Object visitFuncFormalParameter(FuncFormalParameter ast, Object o);
|
||||
public abstract Object visitFuncFormalParameter(FuncFormalParameter ast, Object o);
|
||||
|
||||
public abstract Object visitProcFormalParameter(ProcFormalParameter ast, Object o);
|
||||
public abstract Object visitProcFormalParameter(ProcFormalParameter ast, Object o);
|
||||
|
||||
public abstract Object visitVarFormalParameter(VarFormalParameter ast, Object o);
|
||||
public abstract Object visitVarFormalParameter(VarFormalParameter ast, Object o);
|
||||
|
||||
public abstract Object visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, Object o);
|
||||
public abstract Object visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, Object o);
|
||||
|
||||
public abstract Object visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, Object o);
|
||||
public abstract Object visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, Object o);
|
||||
|
||||
public abstract Object visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, Object o);
|
||||
public abstract Object visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, Object o);
|
||||
|
||||
// Actual Parameters
|
||||
public abstract Object visitConstActualParameter(ConstActualParameter ast, Object o);
|
||||
// Actual Parameters
|
||||
public abstract Object visitConstActualParameter(ConstActualParameter ast, Object o);
|
||||
|
||||
public abstract Object visitFuncActualParameter(FuncActualParameter ast, Object o);
|
||||
public abstract Object visitFuncActualParameter(FuncActualParameter ast, Object o);
|
||||
|
||||
public abstract Object visitProcActualParameter(ProcActualParameter ast, Object o);
|
||||
public abstract Object visitProcActualParameter(ProcActualParameter ast, Object o);
|
||||
|
||||
public abstract Object visitVarActualParameter(VarActualParameter ast, Object o);
|
||||
public abstract Object visitVarActualParameter(VarActualParameter ast, Object o);
|
||||
|
||||
public abstract Object visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, Object o);
|
||||
public abstract Object visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, Object o);
|
||||
|
||||
public abstract Object visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, Object o);
|
||||
public abstract Object visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, Object o);
|
||||
|
||||
public abstract Object visitSingleActualParameterSequence(SingleActualParameterSequence ast, Object o);
|
||||
public abstract Object visitSingleActualParameterSequence(SingleActualParameterSequence ast, Object o);
|
||||
|
||||
// Type Denoters
|
||||
public abstract Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object o);
|
||||
// Type Denoters
|
||||
public abstract Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object o);
|
||||
public abstract Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object o);
|
||||
public abstract Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitCharTypeDenoter(CharTypeDenoter ast, Object o);
|
||||
public abstract Object visitCharTypeDenoter(CharTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object o);
|
||||
public abstract Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitSimpleTypeDenoter(SimpleTypeDenoter ast, Object o);
|
||||
public abstract Object visitSimpleTypeDenoter(SimpleTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitIntTypeDenoter(IntTypeDenoter ast, Object o);
|
||||
public abstract Object visitIntTypeDenoter(IntTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object o);
|
||||
public abstract Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, Object o);
|
||||
public abstract Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, Object o);
|
||||
|
||||
public abstract Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, Object o);
|
||||
public abstract Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, Object o);
|
||||
|
||||
// Literals, Identifiers and Operators
|
||||
public abstract Object visitCharacterLiteral(CharacterLiteral ast, Object o);
|
||||
// Literals, Identifiers and Operators
|
||||
public abstract Object visitCharacterLiteral(CharacterLiteral ast, Object o);
|
||||
|
||||
public abstract Object visitIdentifier(Identifier ast, Object o);
|
||||
public abstract Object visitIdentifier(Identifier ast, Object o);
|
||||
|
||||
public abstract Object visitIntegerLiteral(IntegerLiteral ast, Object o);
|
||||
public abstract Object visitIntegerLiteral(IntegerLiteral ast, Object o);
|
||||
|
||||
public abstract Object visitOperator(Operator ast, Object o);
|
||||
public abstract Object visitOperator(Operator ast, Object o);
|
||||
|
||||
// Value-or-variable names
|
||||
public abstract Object visitDotVname(DotVname ast, Object o);
|
||||
// Value-or-variable names
|
||||
public abstract Object visitDotVname(DotVname ast, Object o);
|
||||
|
||||
public abstract Object visitSimpleVname(SimpleVname ast, Object o);
|
||||
public abstract Object visitSimpleVname(SimpleVname ast, Object o);
|
||||
|
||||
public abstract Object visitSubscriptVname(SubscriptVname ast, Object o);
|
||||
public abstract Object visitSubscriptVname(SubscriptVname ast, Object o);
|
||||
|
||||
// Programs
|
||||
public abstract Object visitProgram(Program ast, Object o);
|
||||
// Programs
|
||||
public abstract Object visitProgram(Program ast, Object o);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public abstract class Vname extends AST {
|
||||
|
||||
public Vname(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
variable = false;
|
||||
type = null;
|
||||
}
|
||||
public Vname(SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
variable = false;
|
||||
type = null;
|
||||
}
|
||||
|
||||
public boolean variable, indexed;
|
||||
public int offset;
|
||||
public TypeDenoter type;
|
||||
public boolean variable, indexed;
|
||||
public int offset;
|
||||
public TypeDenoter type;
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class VnameExpression extends Expression {
|
||||
|
||||
public VnameExpression(Vname vAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
}
|
||||
public VnameExpression(Vname vAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
V = vAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVnameExpression(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitVnameExpression(this, o);
|
||||
}
|
||||
|
||||
public Vname V;
|
||||
public Vname V;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class WhileCommand extends Command {
|
||||
|
||||
public WhileCommand(Expression eAST, Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
C = cAST;
|
||||
}
|
||||
public WhileCommand(Expression eAST, Command cAST, SourcePosition thePosition) {
|
||||
super(thePosition);
|
||||
E = eAST;
|
||||
C = cAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitWhileCommand(this, o);
|
||||
}
|
||||
@Override
|
||||
public Object visit(Visitor v, Object o) {
|
||||
return v.visitWhileCommand(this, o);
|
||||
}
|
||||
|
||||
public Expression E;
|
||||
public Command C;
|
||||
public Expression E;
|
||||
public Command C;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,15 +16,15 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class EqualityRoutine extends RuntimeEntity {
|
||||
|
||||
public EqualityRoutine() {
|
||||
super();
|
||||
}
|
||||
public EqualityRoutine() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EqualityRoutine(int size, int displacement) {
|
||||
super(size);
|
||||
this.displacement = displacement;
|
||||
}
|
||||
public EqualityRoutine(int size, int displacement) {
|
||||
super(size);
|
||||
this.displacement = displacement;
|
||||
}
|
||||
|
||||
public int displacement;
|
||||
public int displacement;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class Field extends RuntimeEntity {
|
||||
|
||||
public Field() {
|
||||
super();
|
||||
fieldOffset = 0;
|
||||
}
|
||||
public Field() {
|
||||
super();
|
||||
fieldOffset = 0;
|
||||
}
|
||||
|
||||
public Field(int size, int fieldOffset) {
|
||||
super(size);
|
||||
this.fieldOffset = fieldOffset;
|
||||
}
|
||||
public Field(int size, int fieldOffset) {
|
||||
super(size);
|
||||
this.fieldOffset = fieldOffset;
|
||||
}
|
||||
|
||||
public int fieldOffset;
|
||||
public int fieldOffset;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,31 +16,31 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class Frame {
|
||||
|
||||
public Frame() {
|
||||
this.level = 0;
|
||||
this.size = 0;
|
||||
}
|
||||
public Frame() {
|
||||
this.level = 0;
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
public Frame(int level, Integer size) {
|
||||
this.level = level;
|
||||
this.size = size.intValue();
|
||||
}
|
||||
public Frame(int level, Integer size) {
|
||||
this.level = level;
|
||||
this.size = size.intValue();
|
||||
}
|
||||
|
||||
public Frame(int level, int size) {
|
||||
this.level = level;
|
||||
this.size = size;
|
||||
}
|
||||
public Frame(int level, int size) {
|
||||
this.level = level;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Frame(Frame frame, int sizeIncrement) {
|
||||
this.level = frame.level;
|
||||
this.size = frame.size + sizeIncrement;
|
||||
}
|
||||
public Frame(Frame frame, int sizeIncrement) {
|
||||
this.level = frame.level;
|
||||
this.size = frame.size + sizeIncrement;
|
||||
}
|
||||
|
||||
public Frame(Frame frame, Integer sizeIncrement) {
|
||||
this.level = frame.level;
|
||||
this.size = frame.size + sizeIncrement.intValue();
|
||||
}
|
||||
public Frame(Frame frame, Integer sizeIncrement) {
|
||||
this.level = frame.level;
|
||||
this.size = frame.size + sizeIncrement.intValue();
|
||||
}
|
||||
|
||||
protected int level;
|
||||
protected int size;
|
||||
protected int level;
|
||||
protected int size;
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class KnownAddress extends RuntimeEntity {
|
||||
|
||||
public KnownAddress() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
public KnownAddress() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
|
||||
public KnownAddress(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
public KnownAddress(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
|
||||
public ObjectAddress address;
|
||||
public ObjectAddress address;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class KnownRoutine extends RuntimeEntity {
|
||||
|
||||
public KnownRoutine() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
public KnownRoutine() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
|
||||
public KnownRoutine(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
public KnownRoutine(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
|
||||
public ObjectAddress address;
|
||||
public ObjectAddress address;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class KnownValue extends RuntimeEntity {
|
||||
|
||||
public KnownValue() {
|
||||
super();
|
||||
value = 0;
|
||||
}
|
||||
public KnownValue() {
|
||||
super();
|
||||
value = 0;
|
||||
}
|
||||
|
||||
public KnownValue(int size, int value) {
|
||||
super(size);
|
||||
this.value = value;
|
||||
}
|
||||
public KnownValue(int size, int value) {
|
||||
super(size);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value;
|
||||
public int value;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public final class ObjectAddress {
|
||||
|
||||
public ObjectAddress(int level, int displacement) {
|
||||
this.level = level;
|
||||
this.displacement = displacement;
|
||||
}
|
||||
public ObjectAddress(int level, int displacement) {
|
||||
this.level = level;
|
||||
this.displacement = displacement;
|
||||
}
|
||||
|
||||
public int level, displacement;
|
||||
public int level, displacement;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class PrimitiveRoutine extends RuntimeEntity {
|
||||
|
||||
public PrimitiveRoutine() {
|
||||
super();
|
||||
displacement = 0;
|
||||
}
|
||||
public PrimitiveRoutine() {
|
||||
super();
|
||||
displacement = 0;
|
||||
}
|
||||
|
||||
public PrimitiveRoutine(int size, int displacement) {
|
||||
super(size);
|
||||
this.displacement = displacement;
|
||||
}
|
||||
public PrimitiveRoutine(int size, int displacement) {
|
||||
super(size);
|
||||
this.displacement = displacement;
|
||||
}
|
||||
|
||||
public int displacement;
|
||||
public int displacement;
|
||||
|
||||
}
|
||||
|
||||
@@ -18,16 +18,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public abstract class RuntimeEntity {
|
||||
|
||||
public final static int maxRoutineLevel = 7;
|
||||
public final static int maxRoutineLevel = 7;
|
||||
|
||||
public RuntimeEntity() {
|
||||
size = 0;
|
||||
}
|
||||
public RuntimeEntity() {
|
||||
size = 0;
|
||||
}
|
||||
|
||||
public RuntimeEntity(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
public RuntimeEntity(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public int size;
|
||||
public int size;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class TypeRepresentation extends RuntimeEntity {
|
||||
|
||||
public TypeRepresentation(int size) {
|
||||
super(size);
|
||||
}
|
||||
public TypeRepresentation(int size) {
|
||||
super(size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class UnknownAddress extends RuntimeEntity {
|
||||
|
||||
public UnknownAddress() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
public UnknownAddress() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
|
||||
public UnknownAddress(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
public UnknownAddress(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
|
||||
public ObjectAddress address;
|
||||
public ObjectAddress address;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class UnknownRoutine extends RuntimeEntity {
|
||||
|
||||
public UnknownRoutine() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
public UnknownRoutine() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
|
||||
public UnknownRoutine(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
public UnknownRoutine(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
|
||||
public ObjectAddress address;
|
||||
public ObjectAddress address;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,16 +16,16 @@ package Triangle.CodeGenerator;
|
||||
|
||||
public class UnknownValue extends RuntimeEntity {
|
||||
|
||||
public UnknownValue() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
public UnknownValue() {
|
||||
super();
|
||||
address = null;
|
||||
}
|
||||
|
||||
public UnknownValue(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
public UnknownValue(int size, int level, int displacement) {
|
||||
super(size);
|
||||
address = new ObjectAddress(level, displacement);
|
||||
}
|
||||
|
||||
public ObjectAddress address;
|
||||
public ObjectAddress address;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,98 +30,94 @@ import Triangle.TreeDrawer.Drawer;
|
||||
*/
|
||||
public class Compiler {
|
||||
|
||||
/** The filename for the object program, normally obj.tam. */
|
||||
static String objectName = "obj.tam";
|
||||
/** The filename for the object program, normally obj.tam. */
|
||||
static String objectName = "obj.tam";
|
||||
|
||||
private static Scanner scanner;
|
||||
private static Parser parser;
|
||||
private static Checker checker;
|
||||
private static Encoder encoder;
|
||||
private static ErrorReporter reporter;
|
||||
private static Drawer drawer;
|
||||
private static Scanner scanner;
|
||||
private static Parser parser;
|
||||
private static Checker checker;
|
||||
private static Encoder encoder;
|
||||
private static ErrorReporter reporter;
|
||||
private static Drawer drawer;
|
||||
|
||||
/** The AST representing the source program. */
|
||||
private static Program theAST;
|
||||
/** The AST representing the source program. */
|
||||
private static Program theAST;
|
||||
|
||||
/**
|
||||
* Compile the source program to TAM machine code.
|
||||
*
|
||||
* @param sourceName the name of the file containing the
|
||||
* source program.
|
||||
* @param objectName the name of the file containing the
|
||||
* object program.
|
||||
* @param showingAST true iff the AST is to be displayed after
|
||||
* contextual analysis (not currently implemented).
|
||||
* @param showingTable true iff the object description details are to
|
||||
* be displayed during code generation (not
|
||||
* currently implemented).
|
||||
* @return true iff the source program is free of compile-time errors,
|
||||
* otherwise false.
|
||||
*/
|
||||
static boolean compileProgram(String sourceName, String objectName,
|
||||
boolean showingAST, boolean showingTable) {
|
||||
/**
|
||||
* Compile the source program to TAM machine code.
|
||||
*
|
||||
* @param sourceName the name of the file containing the source program.
|
||||
* @param objectName the name of the file containing the object program.
|
||||
* @param showingAST true iff the AST is to be displayed after contextual
|
||||
* analysis (not currently implemented).
|
||||
* @param showingTable true iff the object description details are to be
|
||||
* displayed during code generation (not currently
|
||||
* implemented).
|
||||
* @return true iff the source program is free of compile-time errors, otherwise
|
||||
* false.
|
||||
*/
|
||||
static boolean compileProgram(String sourceName, String objectName, boolean showingAST, boolean showingTable) {
|
||||
|
||||
System.out.println("********** " +
|
||||
"Triangle Compiler (Java Version 2.1)" +
|
||||
" **********");
|
||||
System.out.println("********** " + "Triangle Compiler (Java Version 2.1)" + " **********");
|
||||
|
||||
System.out.println("Syntactic Analysis ...");
|
||||
SourceFile source = new SourceFile(sourceName);
|
||||
System.out.println("Syntactic Analysis ...");
|
||||
SourceFile source = SourceFile.ofPath(sourceName);
|
||||
|
||||
if (source == null) {
|
||||
System.out.println("Can't access source file " + sourceName);
|
||||
System.exit(1);
|
||||
}
|
||||
if (source == null) {
|
||||
System.out.println("Can't access source file " + sourceName);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
scanner = new Scanner(source);
|
||||
reporter = new ErrorReporter();
|
||||
parser = new Parser(scanner, reporter);
|
||||
checker = new Checker(reporter);
|
||||
encoder = new Encoder(reporter);
|
||||
drawer = new Drawer();
|
||||
scanner = new Scanner(source);
|
||||
reporter = new ErrorReporter();
|
||||
parser = new Parser(scanner, reporter);
|
||||
checker = new Checker(reporter);
|
||||
encoder = new Encoder(reporter);
|
||||
drawer = new Drawer();
|
||||
|
||||
// scanner.enableDebugging();
|
||||
theAST = parser.parseProgram(); // 1st pass
|
||||
if (reporter.numErrors == 0) {
|
||||
// if (showingAST) {
|
||||
// drawer.draw(theAST);
|
||||
// }
|
||||
System.out.println("Contextual Analysis ...");
|
||||
checker.check(theAST); // 2nd pass
|
||||
if (showingAST) {
|
||||
drawer.draw(theAST);
|
||||
}
|
||||
if (reporter.numErrors == 0) {
|
||||
System.out.println("Code Generation ...");
|
||||
encoder.encodeRun(theAST, showingTable); // 3rd pass
|
||||
}
|
||||
}
|
||||
// scanner.enableDebugging();
|
||||
theAST = parser.parseProgram(); // 1st pass
|
||||
if (reporter.numErrors == 0) {
|
||||
// if (showingAST) {
|
||||
// drawer.draw(theAST);
|
||||
// }
|
||||
System.out.println("Contextual Analysis ...");
|
||||
checker.check(theAST); // 2nd pass
|
||||
if (showingAST) {
|
||||
drawer.draw(theAST);
|
||||
}
|
||||
if (reporter.numErrors == 0) {
|
||||
System.out.println("Code Generation ...");
|
||||
encoder.encodeRun(theAST, showingTable); // 3rd pass
|
||||
}
|
||||
}
|
||||
|
||||
boolean successful = (reporter.numErrors == 0);
|
||||
if (successful) {
|
||||
encoder.saveObjectProgram(objectName);
|
||||
System.out.println("Compilation was successful.");
|
||||
} else {
|
||||
System.out.println("Compilation was unsuccessful.");
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
boolean successful = (reporter.numErrors == 0);
|
||||
if (successful) {
|
||||
encoder.saveObjectProgram(objectName);
|
||||
System.out.println("Compilation was successful.");
|
||||
} else {
|
||||
System.out.println("Compilation was unsuccessful.");
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triangle compiler main program.
|
||||
*
|
||||
* @param args the only command-line argument to the program specifies
|
||||
* the source filename.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
boolean compiledOK;
|
||||
/**
|
||||
* Triangle compiler main program.
|
||||
*
|
||||
* @param args the only command-line argument to the program specifies the
|
||||
* source filename.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
System.out.println("Usage: tc filename");
|
||||
System.exit(1);
|
||||
}
|
||||
if (args.length != 1) {
|
||||
System.out.println("Usage: tc filename");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
String sourceName = args[0];
|
||||
compiledOK = compileProgram(sourceName, objectName, false, false);
|
||||
}
|
||||
String sourceName = args[0];
|
||||
var compiledOK = compileProgram(sourceName, objectName, false, false);
|
||||
|
||||
System.exit(compiledOK ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,16 +18,16 @@ import Triangle.AbstractSyntaxTrees.Declaration;
|
||||
|
||||
public class IdEntry {
|
||||
|
||||
protected String id;
|
||||
protected Declaration attr;
|
||||
protected int level;
|
||||
protected IdEntry previous;
|
||||
protected String id;
|
||||
protected Declaration attr;
|
||||
protected int level;
|
||||
protected IdEntry previous;
|
||||
|
||||
IdEntry(String id, Declaration attr, int level, IdEntry previous) {
|
||||
this.id = id;
|
||||
this.attr = attr;
|
||||
this.level = level;
|
||||
this.previous = previous;
|
||||
}
|
||||
IdEntry(String id, Declaration attr, int level, IdEntry previous) {
|
||||
this.id = id;
|
||||
this.attr = attr;
|
||||
this.level = level;
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+68
-68
@@ -18,91 +18,91 @@ import Triangle.AbstractSyntaxTrees.Declaration;
|
||||
|
||||
public final class IdentificationTable {
|
||||
|
||||
private int level;
|
||||
private IdEntry latest;
|
||||
private int level;
|
||||
private IdEntry latest;
|
||||
|
||||
public IdentificationTable() {
|
||||
level = 0;
|
||||
latest = null;
|
||||
}
|
||||
public IdentificationTable() {
|
||||
level = 0;
|
||||
latest = null;
|
||||
}
|
||||
|
||||
// Opens a new level in the identification table, 1 higher than the
|
||||
// current topmost level.
|
||||
// Opens a new level in the identification table, 1 higher than the
|
||||
// current topmost level.
|
||||
|
||||
public void openScope() {
|
||||
public void openScope() {
|
||||
|
||||
level++;
|
||||
}
|
||||
level++;
|
||||
}
|
||||
|
||||
// Closes the topmost level in the identification table, discarding
|
||||
// all entries belonging to that level.
|
||||
// Closes the topmost level in the identification table, discarding
|
||||
// all entries belonging to that level.
|
||||
|
||||
public void closeScope() {
|
||||
public void closeScope() {
|
||||
|
||||
IdEntry entry, local;
|
||||
IdEntry entry, local;
|
||||
|
||||
// Presumably, idTable.level > 0.
|
||||
entry = this.latest;
|
||||
while (entry.level == this.level) {
|
||||
local = entry;
|
||||
entry = local.previous;
|
||||
}
|
||||
this.level--;
|
||||
this.latest = entry;
|
||||
}
|
||||
// Presumably, idTable.level > 0.
|
||||
entry = this.latest;
|
||||
while (entry.level == this.level) {
|
||||
local = entry;
|
||||
entry = local.previous;
|
||||
}
|
||||
this.level--;
|
||||
this.latest = entry;
|
||||
}
|
||||
|
||||
// Makes a new entry in the identification table for the given identifier
|
||||
// and attribute. The new entry belongs to the current level.
|
||||
// duplicated is set to to true iff there is already an entry for the
|
||||
// same identifier at the current level.
|
||||
// Makes a new entry in the identification table for the given identifier
|
||||
// and attribute. The new entry belongs to the current level.
|
||||
// duplicated is set to to true iff there is already an entry for the
|
||||
// same identifier at the current level.
|
||||
|
||||
public void enter(String id, Declaration attr) {
|
||||
public void enter(String id, Declaration attr) {
|
||||
|
||||
IdEntry entry = this.latest;
|
||||
boolean present = false, searching = true;
|
||||
IdEntry entry = this.latest;
|
||||
boolean present = false, searching = true;
|
||||
|
||||
// Check for duplicate entry ...
|
||||
while (searching) {
|
||||
if (entry == null || entry.level < this.level)
|
||||
searching = false;
|
||||
else if (entry.id.equals(id)) {
|
||||
present = true;
|
||||
searching = false;
|
||||
} else
|
||||
entry = entry.previous;
|
||||
}
|
||||
// Check for duplicate entry ...
|
||||
while (searching) {
|
||||
if (entry == null || entry.level < this.level)
|
||||
searching = false;
|
||||
else if (entry.id.equals(id)) {
|
||||
present = true;
|
||||
searching = false;
|
||||
} else
|
||||
entry = entry.previous;
|
||||
}
|
||||
|
||||
attr.duplicated = present;
|
||||
// Add new entry ...
|
||||
entry = new IdEntry(id, attr, this.level, this.latest);
|
||||
this.latest = entry;
|
||||
}
|
||||
attr.duplicated = present;
|
||||
// Add new entry ...
|
||||
entry = new IdEntry(id, attr, this.level, this.latest);
|
||||
this.latest = entry;
|
||||
}
|
||||
|
||||
// Finds an entry for the given identifier in the identification table,
|
||||
// if any. If there are several entries for that identifier, finds the
|
||||
// entry at the highest level, in accordance with the scope rules.
|
||||
// Returns null iff no entry is found.
|
||||
// otherwise returns the attribute field of the entry found.
|
||||
// Finds an entry for the given identifier in the identification table,
|
||||
// if any. If there are several entries for that identifier, finds the
|
||||
// entry at the highest level, in accordance with the scope rules.
|
||||
// Returns null iff no entry is found.
|
||||
// otherwise returns the attribute field of the entry found.
|
||||
|
||||
public Declaration retrieve(String id) {
|
||||
public Declaration retrieve(String id) {
|
||||
|
||||
IdEntry entry;
|
||||
Declaration attr = null;
|
||||
boolean present = false, searching = true;
|
||||
IdEntry entry;
|
||||
Declaration attr = null;
|
||||
boolean present = false, searching = true;
|
||||
|
||||
entry = this.latest;
|
||||
while (searching) {
|
||||
if (entry == null)
|
||||
searching = false;
|
||||
else if (entry.id.equals(id)) {
|
||||
present = true;
|
||||
searching = false;
|
||||
attr = entry.attr;
|
||||
} else
|
||||
entry = entry.previous;
|
||||
}
|
||||
entry = this.latest;
|
||||
while (searching) {
|
||||
if (entry == null)
|
||||
searching = false;
|
||||
else if (entry.id.equals(id)) {
|
||||
present = true;
|
||||
searching = false;
|
||||
attr = entry.attr;
|
||||
} else
|
||||
entry = entry.previous;
|
||||
}
|
||||
|
||||
return attr;
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,25 +18,25 @@ import Triangle.SyntacticAnalyzer.SourcePosition;
|
||||
|
||||
public class ErrorReporter {
|
||||
|
||||
int numErrors;
|
||||
int numErrors;
|
||||
|
||||
ErrorReporter() {
|
||||
numErrors = 0;
|
||||
}
|
||||
ErrorReporter() {
|
||||
numErrors = 0;
|
||||
}
|
||||
|
||||
public void reportError(String message, String tokenName, SourcePosition pos) {
|
||||
System.out.print("ERROR: ");
|
||||
public void reportError(String message, String tokenName, SourcePosition pos) {
|
||||
System.out.print("ERROR: ");
|
||||
|
||||
for (int p = 0; p < message.length(); p++)
|
||||
if (message.charAt(p) == '%')
|
||||
System.out.print(tokenName);
|
||||
else
|
||||
System.out.print(message.charAt(p));
|
||||
System.out.println(" " + pos.start + ".." + pos.finish);
|
||||
numErrors++;
|
||||
}
|
||||
for (int p = 0; p < message.length(); p++)
|
||||
if (message.charAt(p) == '%')
|
||||
System.out.print(tokenName);
|
||||
else
|
||||
System.out.print(message.charAt(p));
|
||||
System.out.println(" " + pos.start + ".." + pos.finish);
|
||||
numErrors++;
|
||||
}
|
||||
|
||||
public void reportRestriction(String message) {
|
||||
System.out.println("RESTRICTION: " + message);
|
||||
}
|
||||
public void reportRestriction(String message) {
|
||||
System.out.println("RESTRICTION: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,24 +24,23 @@ import Triangle.AbstractSyntaxTrees.UnaryOperatorDeclaration;
|
||||
|
||||
public final class StdEnvironment {
|
||||
|
||||
// These are small ASTs representing standard types.
|
||||
// These are small ASTs representing standard types.
|
||||
|
||||
public static TypeDenoter booleanType, charType, integerType, anyType, errorType;
|
||||
public static TypeDenoter booleanType, charType, integerType, anyType, errorType;
|
||||
|
||||
public static TypeDeclaration booleanDecl, charDecl, integerDecl;
|
||||
public static TypeDeclaration booleanDecl, charDecl, integerDecl;
|
||||
|
||||
// These are small ASTs representing "declarations" of standard entities.
|
||||
// These are small ASTs representing "declarations" of standard entities.
|
||||
|
||||
public static ConstDeclaration falseDecl, trueDecl, maxintDecl;
|
||||
public static ConstDeclaration falseDecl, trueDecl, maxintDecl;
|
||||
|
||||
public static UnaryOperatorDeclaration notDecl;
|
||||
public static UnaryOperatorDeclaration notDecl;
|
||||
|
||||
public static BinaryOperatorDeclaration andDecl, orDecl,
|
||||
addDecl, subtractDecl, multiplyDecl, divideDecl, moduloDecl,
|
||||
equalDecl, unequalDecl, lessDecl, notlessDecl, greaterDecl, notgreaterDecl;
|
||||
public static BinaryOperatorDeclaration andDecl, orDecl, addDecl, subtractDecl, multiplyDecl, divideDecl,
|
||||
moduloDecl, equalDecl, unequalDecl, lessDecl, notlessDecl, greaterDecl, notgreaterDecl;
|
||||
|
||||
public static ProcDeclaration getDecl, putDecl, getintDecl, putintDecl, geteolDecl, puteolDecl;
|
||||
public static ProcDeclaration getDecl, putDecl, getintDecl, putintDecl, geteolDecl, puteolDecl;
|
||||
|
||||
public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl;
|
||||
public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl;
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,258 +16,253 @@ package Triangle.SyntacticAnalyzer;
|
||||
|
||||
public final class Scanner {
|
||||
|
||||
private SourceFile sourceFile;
|
||||
private boolean debug;
|
||||
private SourceFile sourceFile;
|
||||
private boolean debug;
|
||||
|
||||
private char currentChar;
|
||||
private StringBuffer currentSpelling;
|
||||
private boolean currentlyScanningToken;
|
||||
private char currentChar;
|
||||
private StringBuffer currentSpelling;
|
||||
private boolean currentlyScanningToken;
|
||||
|
||||
private boolean isLetter(char c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
private boolean isLetter(char c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
private boolean isDigit(char c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
private boolean isDigit(char c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
// isOperator returns true iff the given character is an operator character.
|
||||
// isOperator returns true iff the given character is an operator character.
|
||||
|
||||
private boolean isOperator(char c) {
|
||||
return (c == '+' || c == '-' || c == '*' || c == '/' ||
|
||||
c == '=' || c == '<' || c == '>' || c == '\\' ||
|
||||
c == '&' || c == '@' || c == '%' || c == '^' ||
|
||||
c == '?');
|
||||
}
|
||||
private boolean isOperator(char c) {
|
||||
return (c == '+' || c == '-' || c == '*' || c == '/' || c == '=' || c == '<' || c == '>' || c == '\\'
|
||||
|| c == '&' || c == '@' || c == '%' || c == '^' || c == '?');
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Scanner(SourceFile source) {
|
||||
sourceFile = source;
|
||||
currentChar = sourceFile.getSource();
|
||||
debug = false;
|
||||
}
|
||||
public Scanner(SourceFile source) {
|
||||
sourceFile = source;
|
||||
currentChar = sourceFile.getSource();
|
||||
debug = false;
|
||||
}
|
||||
|
||||
public void enableDebugging() {
|
||||
debug = true;
|
||||
}
|
||||
public void enableDebugging() {
|
||||
debug = true;
|
||||
}
|
||||
|
||||
// takeIt appends the current character to the current token, and gets
|
||||
// the next character from the source program.
|
||||
// takeIt appends the current character to the current token, and gets
|
||||
// the next character from the source program.
|
||||
|
||||
private void takeIt() {
|
||||
if (currentlyScanningToken)
|
||||
currentSpelling.append(currentChar);
|
||||
currentChar = sourceFile.getSource();
|
||||
}
|
||||
private void takeIt() {
|
||||
if (currentlyScanningToken)
|
||||
currentSpelling.append(currentChar);
|
||||
currentChar = sourceFile.getSource();
|
||||
}
|
||||
|
||||
// scanSeparator skips a single separator.
|
||||
// scanSeparator skips a single separator.
|
||||
|
||||
private void scanSeparator() {
|
||||
switch (currentChar) {
|
||||
case '!': {
|
||||
takeIt();
|
||||
while ((currentChar != SourceFile.EOL) && (currentChar != SourceFile.EOT))
|
||||
takeIt();
|
||||
if (currentChar == SourceFile.EOL)
|
||||
takeIt();
|
||||
}
|
||||
break;
|
||||
private void scanSeparator() {
|
||||
switch (currentChar) {
|
||||
case '!': {
|
||||
takeIt();
|
||||
while ((currentChar != SourceFile.EOL) && (currentChar != SourceFile.EOT))
|
||||
takeIt();
|
||||
if (currentChar == SourceFile.EOL)
|
||||
takeIt();
|
||||
}
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t':
|
||||
takeIt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ' ':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t':
|
||||
takeIt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private int scanToken() {
|
||||
private int scanToken() {
|
||||
|
||||
switch (currentChar) {
|
||||
switch (currentChar) {
|
||||
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'h':
|
||||
case 'i':
|
||||
case 'j':
|
||||
case 'k':
|
||||
case 'l':
|
||||
case 'm':
|
||||
case 'n':
|
||||
case 'o':
|
||||
case 'p':
|
||||
case 'q':
|
||||
case 'r':
|
||||
case 's':
|
||||
case 't':
|
||||
case 'u':
|
||||
case 'v':
|
||||
case 'w':
|
||||
case 'x':
|
||||
case 'y':
|
||||
case 'z':
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
case 'G':
|
||||
case 'H':
|
||||
case 'I':
|
||||
case 'J':
|
||||
case 'K':
|
||||
case 'L':
|
||||
case 'M':
|
||||
case 'N':
|
||||
case 'O':
|
||||
case 'P':
|
||||
case 'Q':
|
||||
case 'R':
|
||||
case 'S':
|
||||
case 'T':
|
||||
case 'U':
|
||||
case 'V':
|
||||
case 'W':
|
||||
case 'X':
|
||||
case 'Y':
|
||||
case 'Z':
|
||||
takeIt();
|
||||
while (isLetter(currentChar) || isDigit(currentChar))
|
||||
takeIt();
|
||||
return Token.IDENTIFIER;
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'h':
|
||||
case 'i':
|
||||
case 'j':
|
||||
case 'k':
|
||||
case 'l':
|
||||
case 'm':
|
||||
case 'n':
|
||||
case 'o':
|
||||
case 'p':
|
||||
case 'q':
|
||||
case 'r':
|
||||
case 's':
|
||||
case 't':
|
||||
case 'u':
|
||||
case 'v':
|
||||
case 'w':
|
||||
case 'x':
|
||||
case 'y':
|
||||
case 'z':
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
case 'G':
|
||||
case 'H':
|
||||
case 'I':
|
||||
case 'J':
|
||||
case 'K':
|
||||
case 'L':
|
||||
case 'M':
|
||||
case 'N':
|
||||
case 'O':
|
||||
case 'P':
|
||||
case 'Q':
|
||||
case 'R':
|
||||
case 'S':
|
||||
case 'T':
|
||||
case 'U':
|
||||
case 'V':
|
||||
case 'W':
|
||||
case 'X':
|
||||
case 'Y':
|
||||
case 'Z':
|
||||
takeIt();
|
||||
while (isLetter(currentChar) || isDigit(currentChar))
|
||||
takeIt();
|
||||
return Token.IDENTIFIER;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
takeIt();
|
||||
while (isDigit(currentChar))
|
||||
takeIt();
|
||||
return Token.INTLITERAL;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
takeIt();
|
||||
while (isDigit(currentChar))
|
||||
takeIt();
|
||||
return Token.INTLITERAL;
|
||||
|
||||
case '+':
|
||||
case '-':
|
||||
case '*':
|
||||
case '/':
|
||||
case '=':
|
||||
case '<':
|
||||
case '>':
|
||||
case '\\':
|
||||
case '&':
|
||||
case '@':
|
||||
case '%':
|
||||
case '^':
|
||||
case '?':
|
||||
takeIt();
|
||||
while (isOperator(currentChar))
|
||||
takeIt();
|
||||
return Token.OPERATOR;
|
||||
case '+':
|
||||
case '-':
|
||||
case '*':
|
||||
case '/':
|
||||
case '=':
|
||||
case '<':
|
||||
case '>':
|
||||
case '\\':
|
||||
case '&':
|
||||
case '@':
|
||||
case '%':
|
||||
case '^':
|
||||
case '?':
|
||||
takeIt();
|
||||
while (isOperator(currentChar))
|
||||
takeIt();
|
||||
return Token.OPERATOR;
|
||||
|
||||
case '\'':
|
||||
takeIt();
|
||||
takeIt(); // the quoted character
|
||||
if (currentChar == '\'') {
|
||||
takeIt();
|
||||
return Token.CHARLITERAL;
|
||||
} else
|
||||
return Token.ERROR;
|
||||
case '\'':
|
||||
takeIt();
|
||||
takeIt(); // the quoted character
|
||||
if (currentChar == '\'') {
|
||||
takeIt();
|
||||
return Token.CHARLITERAL;
|
||||
} else
|
||||
return Token.ERROR;
|
||||
|
||||
case '.':
|
||||
takeIt();
|
||||
return Token.DOT;
|
||||
case '.':
|
||||
takeIt();
|
||||
return Token.DOT;
|
||||
|
||||
case ':':
|
||||
takeIt();
|
||||
if (currentChar == '=') {
|
||||
takeIt();
|
||||
return Token.BECOMES;
|
||||
} else
|
||||
return Token.COLON;
|
||||
case ':':
|
||||
takeIt();
|
||||
if (currentChar == '=') {
|
||||
takeIt();
|
||||
return Token.BECOMES;
|
||||
} else
|
||||
return Token.COLON;
|
||||
|
||||
case ';':
|
||||
takeIt();
|
||||
return Token.SEMICOLON;
|
||||
case ';':
|
||||
takeIt();
|
||||
return Token.SEMICOLON;
|
||||
|
||||
case ',':
|
||||
takeIt();
|
||||
return Token.COMMA;
|
||||
case ',':
|
||||
takeIt();
|
||||
return Token.COMMA;
|
||||
|
||||
case '~':
|
||||
takeIt();
|
||||
return Token.IS;
|
||||
case '~':
|
||||
takeIt();
|
||||
return Token.IS;
|
||||
|
||||
case '(':
|
||||
takeIt();
|
||||
return Token.LPAREN;
|
||||
case '(':
|
||||
takeIt();
|
||||
return Token.LPAREN;
|
||||
|
||||
case ')':
|
||||
takeIt();
|
||||
return Token.RPAREN;
|
||||
case ')':
|
||||
takeIt();
|
||||
return Token.RPAREN;
|
||||
|
||||
case '[':
|
||||
takeIt();
|
||||
return Token.LBRACKET;
|
||||
case '[':
|
||||
takeIt();
|
||||
return Token.LBRACKET;
|
||||
|
||||
case ']':
|
||||
takeIt();
|
||||
return Token.RBRACKET;
|
||||
case ']':
|
||||
takeIt();
|
||||
return Token.RBRACKET;
|
||||
|
||||
case '{':
|
||||
takeIt();
|
||||
return Token.LCURLY;
|
||||
case '{':
|
||||
takeIt();
|
||||
return Token.LCURLY;
|
||||
|
||||
case '}':
|
||||
takeIt();
|
||||
return Token.RCURLY;
|
||||
case '}':
|
||||
takeIt();
|
||||
return Token.RCURLY;
|
||||
|
||||
case SourceFile.EOT:
|
||||
return Token.EOT;
|
||||
case SourceFile.EOT:
|
||||
return Token.EOT;
|
||||
|
||||
default:
|
||||
takeIt();
|
||||
return Token.ERROR;
|
||||
}
|
||||
}
|
||||
default:
|
||||
takeIt();
|
||||
return Token.ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
public Token scan() {
|
||||
Token tok;
|
||||
SourcePosition pos;
|
||||
int kind;
|
||||
public Token scan() {
|
||||
Token tok;
|
||||
SourcePosition pos;
|
||||
int kind;
|
||||
|
||||
currentlyScanningToken = false;
|
||||
while (currentChar == '!'
|
||||
|| currentChar == ' '
|
||||
|| currentChar == '\n'
|
||||
|| currentChar == '\r'
|
||||
|| currentChar == '\t')
|
||||
scanSeparator();
|
||||
currentlyScanningToken = false;
|
||||
while (currentChar == '!' || currentChar == ' ' || currentChar == '\n' || currentChar == '\r'
|
||||
|| currentChar == '\t')
|
||||
scanSeparator();
|
||||
|
||||
currentlyScanningToken = true;
|
||||
currentSpelling = new StringBuffer("");
|
||||
pos = new SourcePosition();
|
||||
pos.start = sourceFile.getCurrentLine();
|
||||
currentlyScanningToken = true;
|
||||
currentSpelling = new StringBuffer("");
|
||||
pos = new SourcePosition();
|
||||
pos.start = sourceFile.getCurrentLine();
|
||||
|
||||
kind = scanToken();
|
||||
kind = scanToken();
|
||||
|
||||
pos.finish = sourceFile.getCurrentLine();
|
||||
tok = new Token(kind, currentSpelling.toString(), pos);
|
||||
if (debug)
|
||||
System.out.println(tok);
|
||||
return tok;
|
||||
}
|
||||
pos.finish = sourceFile.getCurrentLine();
|
||||
tok = new Token(kind, currentSpelling.toString(), pos);
|
||||
if (debug)
|
||||
System.out.println(tok);
|
||||
return tok;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,41 +16,43 @@ package Triangle.SyntacticAnalyzer;
|
||||
|
||||
public class SourceFile {
|
||||
|
||||
public static final char EOL = '\n';
|
||||
public static final char EOT = '\u0000';
|
||||
public static final char EOL = '\n';
|
||||
public static final char EOT = '\u0000';
|
||||
|
||||
java.io.File sourceFile;
|
||||
java.io.FileInputStream source;
|
||||
int currentLine;
|
||||
java.io.File sourceFile;
|
||||
java.io.FileInputStream source;
|
||||
int currentLine;
|
||||
|
||||
public SourceFile(String filename) {
|
||||
try {
|
||||
sourceFile = new java.io.File(filename);
|
||||
source = new java.io.FileInputStream(sourceFile);
|
||||
currentLine = 1;
|
||||
} catch (java.io.IOException s) {
|
||||
sourceFile = null;
|
||||
source = null;
|
||||
currentLine = 0;
|
||||
}
|
||||
}
|
||||
public static SourceFile ofPath(String pathname) {
|
||||
try {
|
||||
return new SourceFile(pathname);
|
||||
} catch (java.io.IOException s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
char getSource() {
|
||||
try {
|
||||
int c = source.read();
|
||||
private SourceFile(String pathname) throws java.io.FileNotFoundException {
|
||||
sourceFile = new java.io.File(pathname);
|
||||
source = new java.io.FileInputStream(sourceFile);
|
||||
currentLine = 1;
|
||||
}
|
||||
|
||||
if (c == -1) {
|
||||
c = EOT;
|
||||
} else if (c == EOL) {
|
||||
currentLine++;
|
||||
}
|
||||
return (char) c;
|
||||
} catch (java.io.IOException s) {
|
||||
return EOT;
|
||||
}
|
||||
}
|
||||
char getSource() {
|
||||
try {
|
||||
int c = source.read();
|
||||
|
||||
int getCurrentLine() {
|
||||
return currentLine;
|
||||
}
|
||||
if (c == -1) {
|
||||
c = EOT;
|
||||
} else if (c == EOL) {
|
||||
currentLine++;
|
||||
}
|
||||
return (char) c;
|
||||
} catch (java.io.IOException s) {
|
||||
return EOT;
|
||||
}
|
||||
}
|
||||
|
||||
int getCurrentLine() {
|
||||
return currentLine;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user