Skip to content

Commit

Permalink
Update VDM2C CLI to accept VDM++ files
Browse files Browse the repository at this point in the history
Closes #84
  • Loading branch information
peterwvj committed Mar 31, 2017
1 parent 52ae1b8 commit 52c71f8
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions core/vdm2c/src/main/java/org/overture/codegen/vdm2c/CGenMain.java
Expand Up @@ -23,6 +23,7 @@
import org.overture.codegen.utils.GeneratedData;
import org.overture.codegen.utils.GeneratedModule;
import org.overture.codegen.vdm2c.sourceformat.ISourceFileFormatter;
import org.overture.config.Release;
import org.overture.config.Settings;
import org.overture.typechecker.util.TypeCheckerUtil;
import org.overture.typechecker.util.TypeCheckerUtil.TypeCheckResult;
Expand All @@ -33,7 +34,7 @@ public class CGenMain

public static void main(String[] args)
{
Settings.dialect = Dialect.VDM_RT;
Settings.release = Release.VDM_10;

LogManager.getRootLogger().setLevel(Level.ERROR);

Expand Down Expand Up @@ -127,7 +128,7 @@ public static void main(String[] args)

if(filterFiles == null || filterFiles.isEmpty())
{
usage(options, sourceOpt, "No VDM-RT source files found in " + path);
usage(options, sourceOpt, "No VDM++/VDM-RT source files found in " + path);
}

files.addAll(filterFiles);
Expand All @@ -154,15 +155,21 @@ public static void main(String[] args)
for (String s : remainingArguments)
{
File f = new File(s);
if (f.exists() && f.isFile())
if (f.exists() && f.isFile() && (isPpFile(f) || isRtFile(f)))
{
files.add(f);
} else
{
error("Not a file: " + s);
error("Not a VDM++/VDM-RT file: " + s);
return;
}
}

if (!files.isEmpty() && isPpFile(files.get(0))) {
Settings.dialect = Dialect.VDM_PP;
} else {
Settings.dialect = Dialect.VDM_RT;
}

try
{
Expand Down Expand Up @@ -267,7 +274,7 @@ private static List<File> filterFiles(List<File> files)

for (File f : files)
{
if (isRtFile(f))
if (isPpFile(f) || isRtFile(f))
{
filtered.add(f);
}
Expand All @@ -280,6 +287,11 @@ private static boolean isRtFile(File f)
{
return f.getName().endsWith(".vdmrt") || f.getName().endsWith(".vrt");
}

private static boolean isPpFile(File f)
{
return f.getName().endsWith(".vdmpp") || f.getName().endsWith(".vpp");
}

private static void usage(Options options, Option opt, String string)
{
Expand Down

0 comments on commit 52c71f8

Please sign in to comment.