public String mainModule(FileUtil files) { if (mainModule == null) { return FilenameUtils.getBaseName(outerParsing.mainDefinitionFile(files).getName()).toUpperCase(); } return mainModule; }
@Override public void accept(CompiledDefinition def) { String kore = getKompiledString(def); File defFile = kompileOptions.outerParsing.mainDefinitionFile(files); String name = defFile.getName(); String basename = FilenameUtils.removeExtension(name); files.saveToDefinitionDirectory(basename + ".kore", kore); }
@Provides @DefinitionDir File definitionDir(@WorkingDir File workingDir, OuterParsingOptions options) { if (options.directory == null) { // bootstrap the part of FileUtil we need return options.mainDefinitionFile(new FileUtil(null, null, workingDir, null, null, null)).getParentFile(); } File f = new File(options.directory); if (f.isAbsolute()) return f; return new File(workingDir, options.directory); }
@Override protected int run() { List<org.kframework.kil.Module> modules = new ArrayList<>(); Source source = Source.apply(options.mainDefinitionFile(files).getAbsolutePath()); File currentDirectory = options.mainDefinitionFile(files).getParentFile(); List<File> lookupDirectories = ListUtils.union(options.includes.stream() .map(files::resolveWorkingDirectory).collect(Collectors.toList()), modules.addAll(parser.slurp(FileUtil.load(options.mainDefinitionFile(files)), source, currentDirectory,
@Provides @KompiledDir File kompiledDir(@DefinitionDir File defDir, OuterParsingOptions options, @WorkingDir File workingDir, @TempDir File tempDir) { // bootstrap the part of FileUtil we need return new File(defDir, FilenameUtils.removeExtension(options.mainDefinitionFile(new FileUtil(null, null, workingDir, null, null, null)).getName()) + "-kompiled"); } }
private void parse(String... args) { new JCommander(options, args); options.outerParsing.mainDefinitionFile(files); options.mainModule(files); options.syntaxModule(files); }
@Override public int run() { if (!options.outerParsing.mainDefinitionFile(files).exists()) { throw KEMException.criticalError("Definition file doesn't exist: " + options.outerParsing.mainDefinitionFile(files).getAbsolutePath()); } Kompile kompile = new Kompile(options, files, kem, sw); Backend backend = koreBackend.get(); CompiledDefinition def = kompile.run(options.outerParsing.mainDefinitionFile(files), options.mainModule(files), options.syntaxModule(files), backend.steps(), backend.excludedModuleTags()); sw.printIntermediate("Kompile to kore"); loader.saveOrDie(files.resolveKompiled("compiled.bin"), def); sw.printIntermediate("Save to disk"); backend.accept(def); sw.printIntermediate("Backend"); loader.saveOrDie(files.resolveKompiled("timestamp"), ""); sw.printTotal("Total"); return 0; } }