From f9b26267c63e7e1af4b793337543fc3c1dd29fab Mon Sep 17 00:00:00 2001 From: Johannes Mey <johannes.mey@tu-dresden.de> Date: Sat, 4 Jan 2020 16:58:13 +0100 Subject: [PATCH] fix CLI, add option --ast for scope4j --- scope4j/build.gradle | 3 +++ scope4m/build.gradle | 3 +++ .../src/main/java/org/jmodelica/ScopeAnalysis.java | 14 ++++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scope4j/build.gradle b/scope4j/build.gradle index dc2f600..869de2a 100644 --- a/scope4j/build.gradle +++ b/scope4j/build.gradle @@ -140,6 +140,9 @@ jastadd { run { mainClassName = 'org.extendj.ScopeAnalysis' + if (project.hasProperty("appArgs")) { + args Eval.me(appArgs) + } } task preprocess(type: JavaExec) { diff --git a/scope4m/build.gradle b/scope4m/build.gradle index 6cdb37b..25c2567 100644 --- a/scope4m/build.gradle +++ b/scope4m/build.gradle @@ -105,6 +105,9 @@ jastadd { run { mainClassName = 'org.jmodelica.SimpleMain' + if (project.hasProperty("appArgs")) { + args Eval.me(appArgs) + } } task preprocess(type: JavaExec) { diff --git a/scope4m/src/main/java/org/jmodelica/ScopeAnalysis.java b/scope4m/src/main/java/org/jmodelica/ScopeAnalysis.java index a7dd42d..916b6d9 100644 --- a/scope4m/src/main/java/org/jmodelica/ScopeAnalysis.java +++ b/scope4m/src/main/java/org/jmodelica/ScopeAnalysis.java @@ -35,15 +35,16 @@ public class ScopeAnalysis { boolean debug = arguments.isEmpty() || arguments.remove("--debug"); boolean tree = arguments.remove("--tree"); boolean warnings = arguments.remove("--warnings"); + boolean ast = arguments.remove("--ast"); if (arguments.size() > 1) { - System.out.println("usage: ScopeAnalysis [--debug] [--tree] [--warnings] <directory with modelica files>"); + System.out.println("usage: ScopeAnalysis [--debug] [--tree] [--warnings] [--ast] <directory with modelica files>"); System.exit(-1); } - String path = arguments.isEmpty() ? "../testprograms/modelica/simple" : arguments.get(arguments.size() - 1); + String path = arguments.isEmpty() ? "../testprograms/modelica/simple" : arguments.get(0); if (debug) { - new ScopeAnalysis().analyze(path, tree, warnings); + new ScopeAnalysis().analyze(path, tree, warnings, ast); } else { new ScopeAnalysis().analyzeTimed(path); } @@ -97,7 +98,7 @@ public class ScopeAnalysis { } - public Set<AbstractFinding> analyze(String path, boolean tree, boolean warnings) { + public Set<AbstractFinding> analyze(String path, boolean tree, boolean warnings, boolean ast) { try { List<String> files = Files.walk(Paths.get(path)) .filter(Files::isRegularFile) @@ -112,8 +113,9 @@ public class ScopeAnalysis { } - // TODO just temp debug output: - sourceRoot.printAST(); + if (ast) { + sourceRoot.printAST(); + } if (warnings) { // TODO find out if there are compiler warnings in JModelica -- GitLab