parent
1db90b20a8
commit
55f6b2d105
@ -0,0 +1,5 @@ |
||||
package Triangle.AbstractMachine; |
||||
|
||||
public enum OpCode { |
||||
LOAD, LOADA, LOADI, LOADL, STORE, STOREI, CALL, CALLI, RETURN, PUSH, POP, JUMP, JUMPI, JUMPIF, HALT |
||||
} |
@ -0,0 +1,6 @@ |
||||
package Triangle.AbstractMachine; |
||||
|
||||
public enum Primitive { |
||||
ID, NOT, AND, OR, SUCC, PRED, NEG, ADD, SUB, MULT, DIV, MOD, LT, LE, GE, GT, EQ, NE, EOL, EOF, GET, PUT, GETEOL, |
||||
PUTEOL, GETINT, PUTINT, NEW, DISPOSE |
||||
} |
@ -0,0 +1,5 @@ |
||||
package Triangle.AbstractMachine; |
||||
|
||||
public enum Register { |
||||
CB, CT, PB, PT, SB, ST, HB, HT, LB, L1, L2, L3, L4, L5, L6, CP |
||||
} |
@ -1,154 +0,0 @@ |
||||
/* |
||||
* @(#)Visitor.java 2.1 2003/10/07 |
||||
* |
||||
* Copyright (C) 1999, 2003 D.A. Watt and D.F. Brown |
||||
* Dept. of Computing Science, University of Glasgow, Glasgow G12 8QQ Scotland |
||||
* and School of Computer and Math Sciences, The Robert Gordon University, |
||||
* St. Andrew Street, Aberdeen AB25 1HG, Scotland. |
||||
* All rights reserved. |
||||
* |
||||
* This software is provided free for educational use only. It may |
||||
* not be used for commercial purposes without the prior written permission |
||||
* of the authors. |
||||
*/ |
||||
|
||||
package Triangle.AbstractSyntaxTrees; |
||||
|
||||
public interface Visitor { |
||||
|
||||
// Commands
|
||||
Object visitAssignCommand(AssignCommand ast, Object o); |
||||
|
||||
Object visitCallCommand(CallCommand ast, Object o); |
||||
|
||||
Object visitEmptyCommand(EmptyCommand ast, Object o); |
||||
|
||||
Object visitIfCommand(IfCommand ast, Object o); |
||||
|
||||
Object visitLetCommand(LetCommand ast, Object o); |
||||
|
||||
Object visitSequentialCommand(SequentialCommand ast, Object o); |
||||
|
||||
Object visitWhileCommand(WhileCommand ast, Object o); |
||||
|
||||
// Expressions
|
||||
Object visitArrayExpression(ArrayExpression ast, Object o); |
||||
|
||||
Object visitBinaryExpression(BinaryExpression ast, Object o); |
||||
|
||||
Object visitCallExpression(CallExpression ast, Object o); |
||||
|
||||
Object visitCharacterExpression(CharacterExpression ast, Object o); |
||||
|
||||
Object visitEmptyExpression(EmptyExpression ast, Object o); |
||||
|
||||
Object visitIfExpression(IfExpression ast, Object o); |
||||
|
||||
Object visitIntegerExpression(IntegerExpression ast, Object o); |
||||
|
||||
Object visitLetExpression(LetExpression ast, Object o); |
||||
|
||||
Object visitRecordExpression(RecordExpression ast, Object o); |
||||
|
||||
Object visitUnaryExpression(UnaryExpression ast, Object o); |
||||
|
||||
Object visitVnameExpression(VnameExpression ast, Object o); |
||||
|
||||
// Declarations
|
||||
Object visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, Object o); |
||||
|
||||
Object visitConstDeclaration(ConstDeclaration ast, Object o); |
||||
|
||||
Object visitFuncDeclaration(FuncDeclaration ast, Object o); |
||||
|
||||
Object visitProcDeclaration(ProcDeclaration ast, Object o); |
||||
|
||||
Object visitSequentialDeclaration(SequentialDeclaration ast, Object o); |
||||
|
||||
Object visitTypeDeclaration(TypeDeclaration ast, Object o); |
||||
|
||||
Object visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, Object o); |
||||
|
||||
Object visitVarDeclaration(VarDeclaration ast, Object o); |
||||
|
||||
// Array Aggregates
|
||||
Object visitMultipleArrayAggregate(MultipleArrayAggregate ast, Object o); |
||||
|
||||
Object visitSingleArrayAggregate(SingleArrayAggregate ast, Object o); |
||||
|
||||
// Record Aggregates
|
||||
Object visitMultipleRecordAggregate(MultipleRecordAggregate ast, Object o); |
||||
|
||||
Object visitSingleRecordAggregate(SingleRecordAggregate ast, Object o); |
||||
|
||||
// Formal Parameters
|
||||
Object visitConstFormalParameter(ConstFormalParameter ast, Object o); |
||||
|
||||
Object visitFuncFormalParameter(FuncFormalParameter ast, Object o); |
||||
|
||||
Object visitProcFormalParameter(ProcFormalParameter ast, Object o); |
||||
|
||||
Object visitVarFormalParameter(VarFormalParameter ast, Object o); |
||||
|
||||
Object visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, Object o); |
||||
|
||||
Object visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, Object o); |
||||
|
||||
Object visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, Object o); |
||||
|
||||
// Actual Parameters
|
||||
Object visitConstActualParameter(ConstActualParameter ast, Object o); |
||||
|
||||
Object visitFuncActualParameter(FuncActualParameter ast, Object o); |
||||
|
||||
Object visitProcActualParameter(ProcActualParameter ast, Object o); |
||||
|
||||
Object visitVarActualParameter(VarActualParameter ast, Object o); |
||||
|
||||
Object visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, Object o); |
||||
|
||||
Object visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, Object o); |
||||
|
||||
Object visitSingleActualParameterSequence(SingleActualParameterSequence ast, Object o); |
||||
|
||||
// Type Denoters
|
||||
Object visitAnyTypeDenoter(AnyTypeDenoter ast, Object o); |
||||
|
||||
Object visitArrayTypeDenoter(ArrayTypeDenoter ast, Object o); |
||||
|
||||
Object visitBoolTypeDenoter(BoolTypeDenoter ast, Object o); |
||||
|
||||
Object visitCharTypeDenoter(CharTypeDenoter ast, Object o); |
||||
|
||||
Object visitErrorTypeDenoter(ErrorTypeDenoter ast, Object o); |
||||
|
||||
Object visitSimpleTypeDenoter(SimpleTypeDenoter ast, Object o); |
||||
|
||||
Object visitIntTypeDenoter(IntTypeDenoter ast, Object o); |
||||
|
||||
Object visitRecordTypeDenoter(RecordTypeDenoter ast, Object o); |
||||
|
||||
Object visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, Object o); |
||||
|
||||
Object visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, Object o); |
||||
|
||||
// Literals, Identifiers and Operators
|
||||
Object visitCharacterLiteral(CharacterLiteral ast, Object o); |
||||
|
||||
Object visitIdentifier(Identifier ast, Object o); |
||||
|
||||
Object visitIntegerLiteral(IntegerLiteral ast, Object o); |
||||
|
||||
Object visitOperator(Operator ast, Object o); |
||||
|
||||
// Value-or-variable names
|
||||
Object visitDotVname(DotVname ast, Object o); |
||||
|
||||
Object visitSimpleVname(SimpleVname ast, Object o); |
||||
|
||||
Object visitSubscriptVname(SubscriptVname ast, Object o); |
||||
|
||||
// Programs
|
||||
Object visitProgram(Program ast, Object o); |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Actuals.EmptyActualParameterSequence; |
||||
import Triangle.AbstractSyntaxTrees.Actuals.MultipleActualParameterSequence; |
||||
import Triangle.AbstractSyntaxTrees.Actuals.SingleActualParameterSequence; |
||||
|
||||
public interface ActualParameterSequenceVisitor<TArg, TResult> { |
||||
|
||||
TResult visitEmptyActualParameterSequence(EmptyActualParameterSequence ast, TArg arg); |
||||
|
||||
TResult visitMultipleActualParameterSequence(MultipleActualParameterSequence ast, TArg arg); |
||||
|
||||
TResult visitSingleActualParameterSequence(SingleActualParameterSequence ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Actuals.ConstActualParameter; |
||||
import Triangle.AbstractSyntaxTrees.Actuals.FuncActualParameter; |
||||
import Triangle.AbstractSyntaxTrees.Actuals.ProcActualParameter; |
||||
import Triangle.AbstractSyntaxTrees.Actuals.VarActualParameter; |
||||
|
||||
public interface ActualParameterVisitor<TArg, TResult> { |
||||
|
||||
TResult visitConstActualParameter(ConstActualParameter ast, TArg arg); |
||||
|
||||
TResult visitFuncActualParameter(FuncActualParameter ast, TArg arg); |
||||
|
||||
TResult visitProcActualParameter(ProcActualParameter ast, TArg arg); |
||||
|
||||
TResult visitVarActualParameter(VarActualParameter ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Aggregates.MultipleArrayAggregate; |
||||
import Triangle.AbstractSyntaxTrees.Aggregates.SingleArrayAggregate; |
||||
|
||||
public interface ArrayAggregateVisitor<TArg, TResult> { |
||||
|
||||
TResult visitMultipleArrayAggregate(MultipleArrayAggregate ast, TArg arg); |
||||
|
||||
TResult visitSingleArrayAggregate(SingleArrayAggregate ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Commands.AssignCommand; |
||||
import Triangle.AbstractSyntaxTrees.Commands.CallCommand; |
||||
import Triangle.AbstractSyntaxTrees.Commands.EmptyCommand; |
||||
import Triangle.AbstractSyntaxTrees.Commands.IfCommand; |
||||
import Triangle.AbstractSyntaxTrees.Commands.LetCommand; |
||||
import Triangle.AbstractSyntaxTrees.Commands.SequentialCommand; |
||||
import Triangle.AbstractSyntaxTrees.Commands.WhileCommand; |
||||
|
||||
public interface CommandVisitor<TArg, TResult> { |
||||
|
||||
TResult visitAssignCommand(AssignCommand ast, TArg arg); |
||||
|
||||
TResult visitCallCommand(CallCommand ast, TArg arg); |
||||
|
||||
TResult visitEmptyCommand(EmptyCommand ast, TArg arg); |
||||
|
||||
TResult visitIfCommand(IfCommand ast, TArg arg); |
||||
|
||||
TResult visitLetCommand(LetCommand ast, TArg arg); |
||||
|
||||
TResult visitSequentialCommand(SequentialCommand ast, TArg arg); |
||||
|
||||
TResult visitWhileCommand(WhileCommand ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Declarations.BinaryOperatorDeclaration; |
||||
import Triangle.AbstractSyntaxTrees.Declarations.ConstDeclaration; |
||||
import Triangle.AbstractSyntaxTrees.Declarations.FuncDeclaration; |
||||
import Triangle.AbstractSyntaxTrees.Declarations.ProcDeclaration; |
||||
import Triangle.AbstractSyntaxTrees.Declarations.SequentialDeclaration; |
||||
import Triangle.AbstractSyntaxTrees.Declarations.UnaryOperatorDeclaration; |
||||
import Triangle.AbstractSyntaxTrees.Declarations.VarDeclaration; |
||||
import Triangle.AbstractSyntaxTrees.Types.TypeDeclaration; |
||||
|
||||
public interface DeclarationVisitor<TArg, TResult> extends FormalParameterVisitor<TArg, TResult> { |
||||
|
||||
TResult visitBinaryOperatorDeclaration(BinaryOperatorDeclaration ast, TArg arg); |
||||
|
||||
TResult visitConstDeclaration(ConstDeclaration ast, TArg arg); |
||||
|
||||
TResult visitFuncDeclaration(FuncDeclaration ast, TArg arg); |
||||
|
||||
TResult visitProcDeclaration(ProcDeclaration ast, TArg arg); |
||||
|
||||
TResult visitSequentialDeclaration(SequentialDeclaration ast, TArg arg); |
||||
|
||||
TResult visitTypeDeclaration(TypeDeclaration ast, TArg arg); |
||||
|
||||
TResult visitUnaryOperatorDeclaration(UnaryOperatorDeclaration ast, TArg arg); |
||||
|
||||
TResult visitVarDeclaration(VarDeclaration ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,39 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Expressions.ArrayExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.BinaryExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.CallExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.CharacterExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.EmptyExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.IfExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.IntegerExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.LetExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.RecordExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.UnaryExpression; |
||||
import Triangle.AbstractSyntaxTrees.Expressions.VnameExpression; |
||||
|
||||
public interface ExpressionVisitor<TArg, TResult> { |
||||
|
||||
TResult visitArrayExpression(ArrayExpression ast, TArg arg); |
||||
|
||||
TResult visitBinaryExpression(BinaryExpression ast, TArg arg); |
||||
|
||||
TResult visitCallExpression(CallExpression ast, TArg arg); |
||||
|
||||
TResult visitCharacterExpression(CharacterExpression ast, TArg arg); |
||||
|
||||
TResult visitEmptyExpression(EmptyExpression ast, TArg arg); |
||||
|
||||
TResult visitIfExpression(IfExpression ast, TArg arg); |
||||
|
||||
TResult visitIntegerExpression(IntegerExpression ast, TArg arg); |
||||
|
||||
TResult visitLetExpression(LetExpression ast, TArg arg); |
||||
|
||||
TResult visitRecordExpression(RecordExpression ast, TArg arg); |
||||
|
||||
TResult visitUnaryExpression(UnaryExpression ast, TArg arg); |
||||
|
||||
TResult visitVnameExpression(VnameExpression ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Types.MultipleFieldTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.SingleFieldTypeDenoter; |
||||
|
||||
public interface FieldTypeDenoterVisitor<TArg, TResult> { |
||||
|
||||
TResult visitMultipleFieldTypeDenoter(MultipleFieldTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitSingleFieldTypeDenoter(SingleFieldTypeDenoter ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Formals.EmptyFormalParameterSequence; |
||||
import Triangle.AbstractSyntaxTrees.Formals.MultipleFormalParameterSequence; |
||||
import Triangle.AbstractSyntaxTrees.Formals.SingleFormalParameterSequence; |
||||
|
||||
public interface FormalParameterSequenceVisitor<TArg, TResult> { |
||||
|
||||
TResult visitEmptyFormalParameterSequence(EmptyFormalParameterSequence ast, TArg arg); |
||||
|
||||
TResult visitMultipleFormalParameterSequence(MultipleFormalParameterSequence ast, TArg arg); |
||||
|
||||
TResult visitSingleFormalParameterSequence(SingleFormalParameterSequence ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Formals.ConstFormalParameter; |
||||
import Triangle.AbstractSyntaxTrees.Formals.FuncFormalParameter; |
||||
import Triangle.AbstractSyntaxTrees.Formals.ProcFormalParameter; |
||||
import Triangle.AbstractSyntaxTrees.Formals.VarFormalParameter; |
||||
|
||||
public interface FormalParameterVisitor<TArg, TResult> { |
||||
|
||||
TResult visitConstFormalParameter(ConstFormalParameter ast, TArg arg); |
||||
|
||||
TResult visitFuncFormalParameter(FuncFormalParameter ast, TArg arg); |
||||
|
||||
TResult visitProcFormalParameter(ProcFormalParameter ast, TArg arg); |
||||
|
||||
TResult visitVarFormalParameter(VarFormalParameter ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,9 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Terminals.Identifier; |
||||
|
||||
public interface IdentifierVisitor<TArg, TResult> { |
||||
|
||||
TResult visitIdentifier(Identifier ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Terminals.CharacterLiteral; |
||||
import Triangle.AbstractSyntaxTrees.Terminals.IntegerLiteral; |
||||
|
||||
public interface LiteralVisitor<TArg, TResult> { |
||||
|
||||
TResult visitCharacterLiteral(CharacterLiteral ast, TArg arg); |
||||
|
||||
TResult visitIntegerLiteral(IntegerLiteral ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,9 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Terminals.Operator; |
||||
|
||||
public interface OperatorVisitor<TArg, TResult> { |
||||
|
||||
TResult visitOperator(Operator ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,9 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Program; |
||||
|
||||
public interface ProgramVisitor<TArg, TResult> { |
||||
|
||||
TResult visitProgram(Program ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Aggregates.MultipleRecordAggregate; |
||||
import Triangle.AbstractSyntaxTrees.Aggregates.SingleRecordAggregate; |
||||
|
||||
public interface RecordAggregateVisitor<TArg, TResult> { |
||||
|
||||
TResult visitMultipleRecordAggregate(MultipleRecordAggregate ast, TArg arg); |
||||
|
||||
TResult visitSingleRecordAggregate(SingleRecordAggregate ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Types.AnyTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.ArrayTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.BoolTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.CharTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.ErrorTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.IntTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.RecordTypeDenoter; |
||||
import Triangle.AbstractSyntaxTrees.Types.SimpleTypeDenoter; |
||||
|
||||
public interface TypeDenoterVisitor<TArg, TResult> extends FieldTypeDenoterVisitor<TArg, TResult> { |
||||
|
||||
TResult visitAnyTypeDenoter(AnyTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitArrayTypeDenoter(ArrayTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitBoolTypeDenoter(BoolTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitCharTypeDenoter(CharTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitErrorTypeDenoter(ErrorTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitSimpleTypeDenoter(SimpleTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitIntTypeDenoter(IntTypeDenoter ast, TArg arg); |
||||
|
||||
TResult visitRecordTypeDenoter(RecordTypeDenoter ast, TArg arg); |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
package Triangle.AbstractSyntaxTrees.Visitors; |
||||
|
||||
import Triangle.AbstractSyntaxTrees.Vnames.DotVname; |
||||
import Triangle.AbstractSyntaxTrees.Vnames.SimpleVname; |
||||
import Triangle.AbstractSyntaxTrees.Vnames.SubscriptVname; |
||||
|
||||
public interface VnameVisitor<TArg, TResult> { |
||||
|
||||
TResult visitDotVname(DotVname ast, TArg arg); |
||||
|
||||
TResult visitSimpleVname(SimpleVname ast, TArg arg); |
||||
|
||||
TResult visitSubscriptVname(SubscriptVname ast, TArg arg); |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Reference in new issue