Skip to content

Commit

Permalink
support --within option
Browse files Browse the repository at this point in the history
  • Loading branch information
lenaRB committed Apr 12, 2024
1 parent 1edcf22 commit 90e710b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/main/java/crml/compiler/CRMLC.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public static void main( String[] args ) throws Exception {
for (String test : testFiles) {
if(test.endsWith(".crml")) {
logger.trace("Translating: " + test);
parse_file(path, test, cmd.outputDir, cmd.stacktrace, cmd.printAST , cmd.generateExternal);
parse_file(path, test, cmd.outputDir, cmd.stacktrace, cmd.printAST ,
cmd.generateExternal, cmd.within);
if(cmd.simulate!=null){
OMCmsg msg;
try {
Expand All @@ -115,7 +116,8 @@ public static void main( String[] args ) throws Exception {
}
} else if (file.isFile()){
logger.trace("Translating: " + file);
parse_file("", path, cmd.outputDir, cmd.stacktrace, cmd.printAST ,cmd.generateExternal);
parse_file("", path, cmd.outputDir, cmd.stacktrace,
cmd.printAST ,cmd.generateExternal, cmd.within);
if(cmd.simulate!=null){
OMCmsg msg;
try {
Expand All @@ -137,7 +139,8 @@ public static void main( String[] args ) throws Exception {
public static void parse_file (
String dir, String file,
String gen_dir, Boolean testMode, Boolean printAST,
Boolean generateExternal) throws Exception {
Boolean generateExternal,
String within) throws Exception {

try {
String fullName = dir + java.io.File.separator + file;
Expand Down Expand Up @@ -179,6 +182,8 @@ public static void parse_file (
out_file.getParentFile().mkdirs();

BufferedWriter writer = new BufferedWriter(new FileWriter(out_file));
if(!within.isEmpty())
writer.write("within " + within + ";\n");
writer.write(result.contents);
writer.close();
logger.trace("Translated: " + file);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/crml/compiler/CommandLineArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public class CommandLineArgs {
@Parameter(names = "--simulate", description = "simulate the files passed in parameters, takes the path to the additional omc files")
public String simulate = null;

@Parameter(names = "--verify", description = "verify the files passed in parameters, takes the path to the reference files")
@Parameter(names = "--verify", description = "verify the files passed in parameters, takes the path to the reference files")
public String verify = null;

@Parameter(names = "--testsuiteETL", description = "run just the ETL tests")
@Parameter(names = "--testsuiteETL", description = "run just the ETL tests")
public boolean testsuiteETL;


@Parameter(names = "--within", description = "generate the translated modelica model within a given class")
public String within = "";
}
2 changes: 1 addition & 1 deletion src/test/java/ctests/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static OMCmsg runTest( final String fileName,
try {

crml.compiler.CRMLC.parse_file(cs.testFolderIn, fileName, out_dir,
true, false, true);
true, false, true, "");

} catch (Exception e) {
fail("Unable to translate " + fileName + " to Modelica\n", e);
Expand Down

0 comments on commit 90e710b

Please sign in to comment.