more
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / specExtraction / ParserUtils.java
index 2cae9b5d8a55e52abd23b79e2ac2efc51183fffd..201bb8c5829bbc43d553cb414c886583d43a15b4 100644 (file)
@@ -7,9 +7,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 
 import edu.uci.eecs.specCompiler.codeGenerator.Environment;
-import edu.uci.eecs.specCompiler.codeGenerator.SemanticsChecker;
-import edu.uci.eecs.specCompiler.grammerParser.ParseException;
-import edu.uci.eecs.specCompiler.grammerParser.SpecParser;
+import edu.uci.eecs.specCompiler.grammerParser.utilParser.ParseException;
+import edu.uci.eecs.specCompiler.grammerParser.utilParser.UtilParser;
 
 public class ParserUtils {
        public static String trimSpace(String line) {
@@ -47,21 +46,25 @@ public class ParserUtils {
 
        public static String getTemplateStr(String templateLine) {
                String templateStr = null;
+               ArrayList<VariableDeclaration> templateArgs;
                try {
-                       ArrayList<String> args = SpecParser.getTemplateArg(templateLine);
-                       templateStr = "<" + args.get(1);
-                       for (int i = 1; i < args.size() / 2; i++) {
-                               templateStr = templateStr + ", " + args.get(i * 2 + 1);
+                       templateArgs = UtilParser.getTemplateArg(templateLine);
+                       templateStr = "<" + templateArgs.get(0).name;
+                       for (int i = 1; i < templateArgs.size(); i++) {
+                               templateStr = templateStr + ", " + templateArgs.get(i).name;
                        }
                        templateStr = templateStr + ">";
                } catch (ParseException e) {
                        e.printStackTrace();
                }
+
                return templateStr;
        }
-       
+
        public static void write2File(File file, ArrayList<String> content) {
-               String newFileName = Environment.GENERATED_FILE_DIR + "/" + file.getName();
+               String newFileName = Environment.GENERATED_FILE_DIR + "/"
+                               + file.getParentFile().getName() + "/" + file.getName();
+
                File newFile = new File(newFileName);
                newFile.getParentFile().mkdirs();
                if (!newFile.exists()) {