end of prac3 no bonus
This commit is contained in:
		
							parent
							
								
									841a7c9af2
								
							
						
					
					
						commit
						b1da248676
					
				| @ -1,2 +1,13 @@ | |||||||
| connection.project.dir=.. | arguments= | ||||||
|  | auto.sync=false | ||||||
|  | build.scans.enabled=false | ||||||
|  | connection.gradle.distribution=GRADLE_DISTRIBUTION(LOCAL_INSTALLATION(/usr/share/java/gradle)) | ||||||
|  | connection.project.dir= | ||||||
| eclipse.preferences.version=1 | eclipse.preferences.version=1 | ||||||
|  | gradle.user.home= | ||||||
|  | java.home=/usr/lib/jvm/java-11-openjdk | ||||||
|  | jvm.arguments= | ||||||
|  | offline.mode=false | ||||||
|  | override.workspace.settings=true | ||||||
|  | show.console.view=true | ||||||
|  | show.executions.view=true | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ public final class StdEnvironment { | |||||||
| 
 | 
 | ||||||
| 	public static ConstDeclaration falseDecl, trueDecl, maxintDecl; | 	public static ConstDeclaration falseDecl, trueDecl, maxintDecl; | ||||||
| 
 | 
 | ||||||
| 	public static UnaryOperatorDeclaration notDecl; | 	public static UnaryOperatorDeclaration notDecl, barDecl; | ||||||
| 
 | 
 | ||||||
| 	public static BinaryOperatorDeclaration andDecl, orDecl, addDecl, subtractDecl, multiplyDecl, divideDecl, | 	public static BinaryOperatorDeclaration andDecl, orDecl, addDecl, subtractDecl, multiplyDecl, divideDecl, | ||||||
| 			moduloDecl, equalDecl, unequalDecl, lessDecl, notlessDecl, greaterDecl, notgreaterDecl; | 			moduloDecl, equalDecl, unequalDecl, lessDecl, notlessDecl, greaterDecl, notgreaterDecl; | ||||||
| @ -43,4 +43,6 @@ public final class StdEnvironment { | |||||||
| 
 | 
 | ||||||
| 	public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl; | 	public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl; | ||||||
| 
 | 
 | ||||||
|  | 	//public static Object barDecl; | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -954,6 +954,9 @@ public final class Checker implements ActualParameterVisitor<FormalParameter, Vo | |||||||
| 		StdEnvironment.notlessDecl = declareStdBinaryOp(">=", StdEnvironment.integerType, StdEnvironment.integerType, | 		StdEnvironment.notlessDecl = declareStdBinaryOp(">=", StdEnvironment.integerType, StdEnvironment.integerType, | ||||||
| 				StdEnvironment.booleanType); | 				StdEnvironment.booleanType); | ||||||
| 		 | 		 | ||||||
|  | 		//PRAC3 # Here we are adding the barDecl, Unary op. that takes 1 val and returns 1 val | ||||||
|  | 		StdEnvironment.barDecl = declareStdUnaryOp("|", StdEnvironment.integerType, StdEnvironment.integerType); | ||||||
|  | 
 | ||||||
| 		StdEnvironment.charDecl = declareStdType("Char", StdEnvironment.charType); | 		StdEnvironment.charDecl = declareStdType("Char", StdEnvironment.charType); | ||||||
| 		StdEnvironment.chrDecl = declareStdFunc("chr", | 		StdEnvironment.chrDecl = declareStdFunc("chr", | ||||||
| 				new SingleFormalParameterSequence( | 				new SingleFormalParameterSequence( | ||||||
|  | |||||||
| @ -162,7 +162,9 @@ public class LayoutVisitor implements ActualParameterVisitor<Void, DrawingTree>, | |||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public DrawingTree visitRepeatCommand(RepeatCommand ast, Void obj) { | 	public DrawingTree visitRepeatCommand(RepeatCommand ast, Void obj) { | ||||||
| 		return null; | 		var d1 = ast.E.visit(this); | ||||||
|  | 		var d2 = ast.C.visit(this); | ||||||
|  | 		return layoutBinary("RepeatCom.", d1, d2); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Expressions | 	// Expressions | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										19
									
								
								programs/run
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								programs/run
									
									
									
									
									
								
							| @ -1,16 +1,17 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| # Term colours for output | # Term. colours for output | ||||||
| RED='\033[0;31m'   # Red | RED='\033[0;31m'   # Red | ||||||
| GRN='\033[0;32m'   # Green | GRN='\033[0;32m'   # Green | ||||||
|  | YLLW='\033[0;33m'  # Yellow | ||||||
| NC='\033[0m'       # No Color | NC='\033[0m'       # No Color | ||||||
| 
 | 
 | ||||||
| TRI="" | TRI="" #.tri file | ||||||
| 
 | 
 | ||||||
| # Check if the input in arg 1 ($1) is empty | # Check if the input in arg 1 ($1) is empty | ||||||
| if [ -z "$1" ] | if [ -z "$1" ] | ||||||
|     then # if empty... |     then # if empty... | ||||||
|         printf "${RED}Usage: $0 *.tri file (optional: $0 *.tri tree)${NC}" |         printf "${YLLW}Usage: $0 *.tri file (optional: $0 *.tri tree)${NC}" | ||||||
|         exit 1 # Exit with code 1, failure |         exit 1 # Exit with code 1, failure | ||||||
|     else |     else | ||||||
|         TRI=$1 |         TRI=$1 | ||||||
| @ -19,25 +20,23 @@ fi | |||||||
| #Remove the extension of the file | #Remove the extension of the file | ||||||
| FILENAME=$(echo $TRI | cut -f 1 -d '.') | FILENAME=$(echo $TRI | cut -f 1 -d '.') | ||||||
| 
 | 
 | ||||||
| #TODO: implement tree command | printf "${YLLW}[INFO] Compiling file: $FILENAME.tri to $FILENAME.tam ...${NC}\n" | ||||||
| printf "${GRN}[INFO] Compiling file: $FILENAME.tri to $FILENAME.tam ...${NC}\n" |  | ||||||
| 
 | 
 | ||||||
| # Compile to tam | # Compile to tam | ||||||
| if java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam &> /dev/null #quiet | if java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam &> /dev/null #quiet | ||||||
|     then if [ -z "$2" ] |     then if [ -z "$2" ] | ||||||
|             then #if empty |             then #if second arg empty (really im not checking if you put tree) | ||||||
|                 printf "${GRN}[INFO] Running file: $FILENAME.tam ...${NC}\n" |                 printf "${GRN}[INFO] Running file: $FILENAME.tam ...${NC}\n" | ||||||
|                 java -cp ../build/libs/Triangle-Tools.jar triangle.abstractMachine.Interpreter $FILENAME.tam |                 java -cp ../build/libs/Triangle-Tools.jar triangle.abstractMachine.Interpreter $FILENAME.tam | ||||||
|                 exit 0 |                 exit 0 | ||||||
|             else |             else #youve put tree, so lets see it! | ||||||
|                 printf "${GRN}[INFO] Running file: $FILENAME.tam ... and displaying AST${NC}\n" |                 printf "${GRN}[INFO] Running file: $FILENAME.tam ... and displaying AST${NC}\n" | ||||||
|                 java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri tree -o=$FILENAME.tam &> /dev/null #quiet |                 java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri tree -o=$FILENAME.tam &> /dev/null #quiet | ||||||
|                 exit 0 |                 exit 0 | ||||||
|          fi |          fi | ||||||
| 
 |     else #error msg | ||||||
|     else |  | ||||||
|         printf "${RED}[ERROR] Could not complie $FILENAME.tri ...${NC}" |         printf "${RED}[ERROR] Could not complie $FILENAME.tri ...${NC}" | ||||||
|         err=$(java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam) |         err=$(java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam) | ||||||
|         printf "${RED}\n$err\n${NC}" |         printf "${RED}\n$err\n${NC}" | ||||||
|         exit 1 |         exit 1 #exit with 1, failure | ||||||
| fi | fi | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user