From 1a9f3be58fb394fd7389a853e871ce6c162366cb Mon Sep 17 00:00:00 2001 From: Recolic Keghart <root@recolic.net> Date: Mon, 1 Apr 2019 18:37:20 -0700 Subject: [PATCH] update running settings --- .gitlab-ci.yml | 7 ++++--- run.sh | 17 +++++++++++++++++ .../java/chocopy/pa2/DeclarationAnalyzer.java | 10 +++++----- 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100755 run.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39e6b7d..ec25d71 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,15 +24,16 @@ test-assignment: stage: test dependencies: - build-jdk8 - script: "java -cp chocopy-ref.jar:target/assignment.jar chocopy.ChocoPy --pass=.s --dir src/test/data/pa2/sample --test" + script: + - ./run.sh ass test-positive-whole: stage: test dependencies: - build-jdk8 script: - - java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy --pass=rs --out /tmp/out.o src/test/data/pa2/sample/ast_coverage.py - - diff /tmp/out.o src/test/data/pa2/sample/ast_coverage.py.ast.typed || echo 'Ignoring failed test...' + - ./run.sh type src/test/data/pa2/sample/ast_coverage.py /tmp/out.o + - diff /tmp/out.o src/test/data/pa2/sample/ast_coverage.py.ast.typed allow_failure: true code_quality: diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e42c387 --- /dev/null +++ b/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +task="$1" +input="$2" +output="$3" + +if [[ "$task" = parse ]]; then + java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy --pass=r --out "$output" "$input" +elif [[ "$task" = type ]]; then + java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy --pass=.s --out "$output" "$input" +elif [[ "$task" = ass ]]; then + java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy --pass=.s --dir src/test/data/pa2/sample --test +fi + +exit $? + + diff --git a/src/main/java/chocopy/pa2/DeclarationAnalyzer.java b/src/main/java/chocopy/pa2/DeclarationAnalyzer.java index 92f0203..5f0814a 100644 --- a/src/main/java/chocopy/pa2/DeclarationAnalyzer.java +++ b/src/main/java/chocopy/pa2/DeclarationAnalyzer.java @@ -82,25 +82,25 @@ public class DeclarationAnalyzer extends AbstractNodeAnalyzer<SymbolType> { case ">=": case "<=": if(left_type != ValueType.INT_TYPE || right_type != ValueType.INT_TYPE) - throw new RuntimeException("Syntax Error: operand should be INT"); + node.setErrorMsg("Syntax Error: operand should be INT"); break; case "and": case "or": if(left_type != ValueType.BOOL_TYPE || right_type != ValueType.BOOL_TYPE) - throw new RuntimeException("Syntax Error: operand should be BOOL"); + node.setErrorMsg("Syntax Error: operand should be BOOL"); break; case "+": if(left_type != ValueType.INT_TYPE && left_type != ValueType.STR_TYPE && ! left_type.isListType()) - throw new RuntimeException("Syntax Error: operand of + should be INT or STR or LIST"); + node.setErrorMsg("Syntax Error: operand of + should be INT or STR or LIST"); // fallthrough case "==": case "!=": case "is": if(node.left.getInferredType() != node.right.getInferredType()) - throw new RuntimeException("Syntax Error: binary operator operand type mismatch"); + node.setErrorMsg("Syntax Error: binary operator operand type mismatch"); break; default: - throw new RuntimeException("Syntax Error: binary operator operand type not supported."); + node.setErrorMsg("Syntax Error: binary operator operand type not supported."); } // Now set target type. -- GitLab