add lots of stuff
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / specExtraction / ParserUtils.java
index 0ce533288dd6af681b8f55d8b1a3af1aab24b827..61d0da71167d1403abbbfb588c725deaa8cce235 100644 (file)
@@ -2,6 +2,7 @@ package edu.uci.eecs.specCompiler.specExtraction;
 
 import java.util.ArrayList;
 
+import edu.uci.eecs.specCompiler.codeGenerator.SemanticsChecker;
 import edu.uci.eecs.specCompiler.grammerParser.ParseException;
 import edu.uci.eecs.specCompiler.grammerParser.SpecParser;
 
@@ -24,7 +25,7 @@ public class ParserUtils {
                else
                        return line.substring(i, j + 1);
        }
-       
+
        public static String array2Str(ArrayList code) {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < code.size(); i++) {
@@ -32,4 +33,25 @@ public class ParserUtils {
                }
                return sb.toString();
        }
+
+       public static String getClassName(String classDefineLine) {
+               IDExtractor extractor = new IDExtractor(classDefineLine,
+                               classDefineLine.length() - 1);
+               return extractor.getPrevID();
+       }
+
+       public static String getTemplateStr(String templateLine) {
+               String templateStr = null;
+               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);
+                       }
+                       templateStr = templateStr + ">";
+               } catch (ParseException e) {
+                       e.printStackTrace();
+               }
+               return templateStr;
+       }
 }