From 310414cd0446352b33ce7f2c9d782551345e3f02 Mon Sep 17 00:00:00 2001
From: Anders Nilsson <anders.nilsson@control.lth.se>
Date: Wed, 4 May 2011 13:59:44 +0200
Subject: [PATCH] Simplified usage.

---
 GenCompiler.java | 104 ++++++++++++++++++++++++-----------------------
 1 file changed, 53 insertions(+), 51 deletions(-)

diff --git a/GenCompiler.java b/GenCompiler.java
index 2170f04..9d8ac13 100644
--- a/GenCompiler.java
+++ b/GenCompiler.java
@@ -17,7 +17,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with XMLSchemaCompiler.  If not, see <http://www.gnu.org/licenses/>.
-*/
+ */
 
 import AST.Start;
 import java.io.File;
@@ -26,71 +26,73 @@ import java.io.PrintStream;
 public class GenCompiler extends Parser {
     public static void main(String args[]) {
 
-        String dir = "examples/x3d";
-        String outName = "x3d";
+        String dir = "generated";
+        String outName = "generated";
         String[] schema = new String[1];
-	String grammarName = new String();
+		String grammarName = new String();
         boolean first = true;
 
         for (int i=0; i<args.length; i++) {
             if (args[i].equals("-d")) {
                 dir = args[++i];
-		System.out.println("dir: "+dir);
-	    } else if (args[i].equals("-g")) {
-		grammarName = args[++i];
-		System.out.println("grammar: "+grammarName);
-	    } else if (args[i].equals("-o")) {
-		outName = args[++i];
-		System.out.println("outName: "+outName);
-	    } else {
-		// OK, we suppose the remaing arg to be parsed.
-		schema[0] = args[i++];
-		System.out.println("schema: "+schema[0]);
-	    }
-	}
-	Start ast = parse(schema);
+				// System.out.println("dir: "+dir);
+			} else if (args[i].equals("-g")) {
+				grammarName = args[++i];
+				dir = grammarName;
+				outName = grammarName;
+				// System.out.println("grammar: "+grammarName);
+			} else if (args[i].equals("-o")) {
+				outName = args[++i];
+				// System.out.println("outName: "+outName);
+			} else {
+				// OK, we suppose the remaing arg to be parsed.
+				schema[0] = args[i++];
+				// System.out.println("schema: "+schema[0]);
+			}
+		}
+		Start ast = parse(schema);
 
-	ast.setGrammar(grammarName);
+		ast.setGrammar(grammarName);
 
-	ast.registerProblematicNames();
+		ast.registerProblematicNames();
 
-	File siarasDir = new File(dir);
-	if (!siarasDir.isDirectory()) {
-	    siarasDir.mkdir();
-	}
+		File siarasDir = new File(dir);
+		if (!siarasDir.isDirectory()) {
+			siarasDir.mkdir();
+		}
 		
-	String fileName = null;
-	String common = dir+File.separator+outName;
-	try {
-	    // Generate JastAdd abstract grammar
-	    fileName = common+".ast";
-	    PrintStream pStream = new PrintStream(new File(fileName));
-	    ast.genAbsGrammar(pStream);
+		String fileName = null;
+		String common = dir+File.separator+outName;
+		try {
+			// Generate JastAdd abstract grammar
+			fileName = common+".ast";
+			PrintStream pStream = new PrintStream(new File(fileName));
+			ast.genAbsGrammar(pStream);
 
-	    // Generate JavaCC input
-	    fileName = common+".jjt";
-	    pStream = new PrintStream(new File(fileName));
-	    ast.genJavaCC(pStream);
+			// Generate JavaCC input
+			fileName = common+".jjt";
+			pStream = new PrintStream(new File(fileName));
+			ast.genJavaCC(pStream);
 
-	    // Generate Parser.java
-	    fileName = dir+"/Parser.java";
-	    pStream = new PrintStream(new File(fileName));
-	    ast.genParser(pStream);
+			// Generate Parser.java
+			fileName = dir+"/Parser.java";
+			pStream = new PrintStream(new File(fileName));
+			ast.genParser(pStream);
 
-	    // Generate PrettyPrint.java
-	    fileName = dir+"/PrettyPrint.java";
-	    pStream = new PrintStream(new File(fileName));
-	    ast.genPrettyPrint(pStream);
+			// Generate PrettyPrint.java
+			fileName = dir+"/PrettyPrint.java";
+			pStream = new PrintStream(new File(fileName));
+			ast.genPrettyPrint(pStream);
 
-	    // Generate aspects
-	    fileName = dir+"/GeneratedAspects.jrag";
-	    pStream = new PrintStream(new File(fileName));
-	    ast.genAspects(pStream);
+			// Generate aspects
+			fileName = dir+"/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();
-	}
+		} catch (java.io.FileNotFoundException e) {
+			System.out.println("Could not create file: "+fileName);
+			e.printStackTrace();
+		}
     }
 
 }
-- 
GitLab