// package programs; /* * Copyright (C) 2006,2010 Anders Nilsson <anders.nilsson@control.lth.se> * * This file is part of OntologyCompiler. * * OntologyCompiler is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * OntologyCompiler is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with OntologyCompiler. If not, see <http://www.gnu.org/licenses/>. */ import AST.Start; import java.io.File; import java.io.PrintStream; public class GenCompiler extends Parser { public static void main(String args[]) { String name = "default"; String dirName = "default"; String owlFile = ""; int i = 0; while (i<args.length) { if (args[i].equals("-d")) { dirName = args[++i]; i++; } else if (args[i].equals("-n")) { name = args[++i]; i++; } else { owlFile = args[i++]; } } Start ast = parse(owlFile); ast.setGrammarName(name); File siarasDir = new File(dirName); if (!siarasDir.isDirectory()) { siarasDir.mkdir(); } String fileName = null; try { // Generate JastAdd abstract grammar fileName = dirName+"/"+name+".ast"; PrintStream pStream = new PrintStream(new File(fileName)); ast.genAbsGrammar(pStream); // Generate Parser.java fileName = dirName+"/Parser.java"; pStream = new PrintStream(new File(fileName)); ast.genParser(pStream); // Generate aspects fileName = dirName+"/GeneratedAspects.jrag"; pStream = new PrintStream(new File(fileName)); ast.genAspects(pStream); } catch (java.io.FileNotFoundException e) { System.out.println("Could not create file: "+fileName); e.printStackTrace(); } } }