+++ /dev/null
-#!/usr/bin/env bash
-/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -cp /var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:jvm:jvm/Arithmetic_Echo.jar Arithmetic_Echo $@
+++ /dev/null
-#!/usr/bin/env bash
-/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -cp /var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:jvm:jvm/Arithmetic_Echo__Test.jar Arithmetic_Echo__Test $@
--- /dev/null
+#!/usr/bin/env bash
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -cp /var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm/Arithmetic_Syntax.jar Arithmetic_Syntax $@
--- /dev/null
+#!/usr/bin/env bash
+/var/user_data/Thomas-developer/GQL_to_Cypher/tool/jdk-22.0.1+8/bin/java -cp /var/user_data/Thomas-developer/GQL_to_Cypher/tool/executor/antlr-4.11.1-complete.jar:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm:/var/user_data/Thomas-developer/GQL_to_Cypher/developer/jvm/Arithmetic_Syntax__Test.jar Arithmetic_Syntax__Test $@
--- /dev/null
+#!/usr/bin/env bash
+
+# Check if any arguments are provided (input files or directories)
+if [ $# -eq 0 ]; then
+ echo "Usage: $0 <file1> [file2 ...]"
+ exit 1
+fi
+
+# Loop through all provided arguments (files or directories)
+for file in "$@"; do
+ if [ -f "$file" ]; then
+ echo "#--------------------------------------------------------------------------------"
+ echo "# Filename: ${file}"
+ echo "#"
+ cat "$file"
+ fi
+done
--- /dev/null
+# Creating env_GP file in the executor directory
+cat << 'EOF' > ../executor/env_GP
+#!/bin/bash
+# Environment setup for GP
+export GP_PROMPT="GP> "
+export PS1="\[$(tput setaf 2)\]\u@\h:\w$GP_PROMPT\[$(tput sgr0)\] "
+export PROJECT_HOME="/var/user_data/Thomas-developer/GQL_to_Cypher/developer"
+cd $PROJECT_HOME/experiment
+EOF
+
+# Make the file executable
+chmod +x ../executor/env_GP
+
+# Source the env_GP file to set up the environment
+source ../executor/env_GP
+
+# Verify that the environment is set up correctly
+pwd
# Note these suffixes:
# _FL = File List
+# _FP = File Path
# _FPL = File Path List
# _DL = Directory List
+# _DP = Directory path
+# _DPL = Directory path list
# _PRIMARY = stuff not built
# _IN things input to some program
Arithmetic_Echo\
Arithmetic_Echo__Test\
Arithmetic_Syntax\
+ Arithmetic_Syntax__Test\
20240412_Syntax\
"
# JVM
export JVM_IN_DIR="${JAVA_COMP_OUT_DIR}"
-export CLASSPATH="${CLASSPATH}:${JVM_IN_DIR}"
+
+# The generated build scripts might need arguments that are fully specified paths.
+export DEVELOPER_HOME_DP="/var/user_data/Thomas-developer/GQL_to_Cypher/developer"
+export JVM_IN_DP="$DEVELOPER_HOME_DP/jvm"
+export EXECUTOR_IN_DP="$DEVELOPER_HOME_DP/executor"
+export CLASSPATH="${CLASSPATH}:${JVM_IN_DP}"
#--------------------------------------------------------------------------------
# tools used
fi
make $(EXECUTOR_IN_DIR)/Arithmetic_Syntax
+Arithmetic_Syntax__Test: $(ANTLR_OUT_Arithmetic_FPL)
+ @if [ -z "$(ANTLR_OUT_Arithmetic_FPL)" ]; then \
+ echo "variable ANTLR_OUT_Arithmetic_FPL empty."; \
+ exit 1; \
+ fi
+ make $(EXECUTOR_IN_DIR)/Arithmetic_Syntax__Test
+
Tree_20240412: $(ANTLR_OUT_GQL_20240412_FPL)
@if [ -z "$(ANTLR_OUT_GQL_20240412_FPL)" ]; then \
echo "variable ANTLR_OUT_GQL_20240412_FPL empty."; \
$(JAVA_ARCHIVE) cf $@ -C $(JAVA_COMP_OUT_DIR) $*.class
@echo "Created $@"
-$(EXECUTOR_IN_DIR)/%: $(JAVA_COMP_OUT_DIR)/%.jar
+$(EXECUTOR_IN_DIR)/%: $(JVM_IN_DIR)/%.jar
@echo "Creating script for $*..."
@echo "#!/usr/bin/env bash" > $(EXECUTOR_IN_DIR)/$*
- @echo "$(JAVA_INTERP) -cp ${CLASSPATH}:$(JAVA_COMP_OUT_DIR):$< $*" \$$\@ >> $(EXECUTOR_IN_DIR)/$*
+ @echo "$(JAVA_INTERP) -cp ${CLASSPATH}:${JVM_IN_DP}:$(JVM_IN_DP)/$*.jar $*" \$$\@ >> $(EXECUTOR_IN_DIR)/$*
chmod +x $(EXECUTOR_IN_DIR)/$*
@echo "Created script $(EXECUTOR_IN_DIR)/$*"
--- /dev/null
+# Create the env_GP file in the executor directory
+cat << 'EOF' > ../executor/env_GP
+#!/bin/bash
+# Environment setup for GP
+export GP_PROMPT="GP> "
+export PS1="\[$(tput setaf 2)\]\u@\h:\w$GP_PROMPT\[$(tput sgr0)\] "
+EOF
+
+# Make sure the file is executable
+chmod +x ../executor/env_GP
+
+# Source the env_GP file to set up the environment
+source ../executor/env_GP
+
+# Now let's see the current directory contents
+ls -l
public class Arithmetic_Echo__Test {
- public static boolean PrintVisitor_0() {
+ public static boolean Arithmetic_Echo_0() {
// Simple smoke test
try {
String input = "3 + 5";
}
}
- public static boolean PrintVisitor_1() {
+ public static boolean Arithmetic_Echo_1() {
// Test with multiplication
try {
String input = "2 * 3";
}
}
- public static boolean PrintVisitor_2() {
+ public static boolean Arithmetic_Echo_2() {
// Test with parentheses
try {
String input = "2 * (3 + 4)";
}
}
- public static boolean PrintVisitor_3() {
+ public static boolean Arithmetic_Echo_3() {
// Test with division
try {
String input = "10 / 2";
}
}
- public static boolean PrintVisitor_4() {
+ public static boolean Arithmetic_Echo_4() {
// Test with complex expression
try {
String input = "3 + 5 * (10 - 4)";
String expectedOutput = "(3 + (5 * (10 - 4)))";
String actualOutput = runSyntax(input);
// Uncomment the print statement for debugging
- // System.out.println("PrintVisitor_4 - Expected: " + expectedOutput + ", Actual: " + actualOutput);
+ // System.out.println("Arithmetic_Echo_4 - Expected: " + expectedOutput + ", Actual: " + actualOutput);
return expectedOutput.equals(actualOutput);
} catch (Exception e) {
return false;
public static void main(String[] args) {
Map<String, Boolean> tests = new HashMap<>();
- tests.put("PrintVisitor_0", PrintVisitor_0());
- tests.put("PrintVisitor_1", PrintVisitor_1());
- tests.put("PrintVisitor_2", PrintVisitor_2());
- tests.put("PrintVisitor_3", PrintVisitor_3());
- tests.put("PrintVisitor_4", PrintVisitor_4());
+ tests.put("Arithmetic_Echo_0", Arithmetic_Echo_0());
+ tests.put("Arithmetic_Echo_1", Arithmetic_Echo_1());
+ tests.put("Arithmetic_Echo_2", Arithmetic_Echo_2());
+ tests.put("Arithmetic_Echo_3", Arithmetic_Echo_3());
+ tests.put("Arithmetic_Echo_4", Arithmetic_Echo_4());
TestBench.runTests(tests);
}
import java.nio.file.Files;
import java.nio.file.Paths;
-public class Arithmetic_Syntax{
+public class Arithmetic_Syntax {
public static void main(String[] args) throws IOException {
if (args.length != 1) {
ArithmeticParser parser = new ArithmeticParser(tokens);
// Directly calling the start rule method
- ParseSyntax tree = parser.program(); // Assuming 'program' is the start rule
+ ParseTree tree = parser.program(); // Assuming 'program' is the start rule
- PrintVisitor visitor = new PrintVisitor(parser.getRuleNames());
+ Arithmetic_Syntax_PrintVisitor visitor = new Arithmetic_Syntax_PrintVisitor(parser.getRuleNames());
String syntaxSyntax = visitor.visit(tree);
System.out.println(syntaxSyntax);
} catch (Exception e) {
-import org.antlr.v4.runtime.tree.AbstractParseSyntaxVisitor;
+import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
public class Arithmetic_Syntax_PrintVisitor extends ArithmeticBaseVisitor<String> {
private final String[] ruleNames;
- public PrintVisitor(String[] ruleNames) {
+ public Arithmetic_Syntax_PrintVisitor(String[] ruleNames) {
this.ruleNames = ruleNames;
}
--- /dev/null
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.tree.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class Arithmetic_Syntax__Test {
+
+ public static boolean Arithmetic_Syntax_0() {
+ return runTest(
+ "Arithmetic_Syntax__Test_0.txt"
+ ,"program(expression(INT(3) operator(+) INT(5)))"
+ );
+ }
+
+ public static boolean Arithmetic_Syntax_1() {
+ return runTest(
+ "Arithmetic_Syntax__Test_1.txt"
+ ,"program(expression(INT(3) operator(+) INT(5)))"
+ );
+ }
+
+ public static boolean Arithmetic_Syntax_2() {
+ return runTest(
+ "Arithmetic_Syntax__Test_2.txt"
+ ,"program(expression(INT(2) operator(*) expression(INT(3) operator(+) INT(4))))"
+ );
+ }
+
+ public static boolean Arithmetic_Syntax_3() {
+ return runTest(
+ "Arithmetic_Syntax__Test_3.txt"
+ ,"program(expression(INT(10) operator(/) INT(2)))"
+ );
+ }
+
+ public static boolean Arithmetic_Syntax_4() {
+ return runTest(
+ "Arithmetic_Syntax__Test_4.txt"
+ ,"program(expression(INT(3) operator(+) expression(INT(5) operator(*) expression(INT(10) operator(-) INT(4)))))"
+ );
+ }
+
+ private static boolean runTest(String filename ,String expectedOutput) {
+ try {
+ String input = Files.readString(Paths.get(filename));
+ String actualOutput = runSyntax(input);
+ return expectedOutput.equals(actualOutput);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ private static String runSyntax(String input) throws Exception {
+ Lexer lexer = new ArithmeticLexer(CharStreams.fromString(input));
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ ArithmeticParser parser = new ArithmeticParser(tokens);
+ ParseTree tree = parser.program(); // Directly calling the start rule method
+
+ Arithmetic_Syntax_PrintVisitor visitor = new Arithmetic_Syntax_PrintVisitor(parser.getRuleNames());
+ return visitor.visit(tree);
+ }
+
+ public static void main(String[] args) {
+ // Use LinkedHashMap to maintain order of test results
+ Map<String ,Boolean> tests = new LinkedHashMap<>();
+ tests.put("Arithmetic_Syntax_0" ,Arithmetic_Syntax_0());
+ tests.put("Arithmetic_Syntax_1" ,Arithmetic_Syntax_1());
+ tests.put("Arithmetic_Syntax_2" ,Arithmetic_Syntax_2());
+ tests.put("Arithmetic_Syntax_3" ,Arithmetic_Syntax_3());
+ tests.put("Arithmetic_Syntax_4" ,Arithmetic_Syntax_4());
+
+ TestBench.runTests(tests);
+ }
+}
--- /dev/null
+2 * (3 + 4)
+
--- /dev/null
+3 + 5 * (10 - 4)
+
--- /dev/null
+#!/bin/bash
+# Environment setup for GP
+export GP_PROMPT="GP> "
+export PS1="\[$(tput setaf 2)\]\u@\h:\w$GP_PROMPT\[$(tput sgr0)\] "
+export PROJECT_HOME="/var/user_data/Thomas-developer/GQL_to_Cypher/developer"
+cd $PROJECT_HOME/experiment