import java.io.IOException;
import java.io.LineNumberReader;
import java.util.ArrayList;
+import java.util.HashMap;
import edu.uci.eecs.specCompiler.grammerParser.ParseException;
import edu.uci.eecs.specCompiler.grammerParser.SpecParser;
*
*/
public class SpecExtractor {
- private ArrayList<Construct> _constructs;
- private int _beginLineNum, _endLineNum;
- private String _beginLine;
+ public final ArrayList<Construct> constructs;
+
+ public final HashMap<File, ArrayList<String>> contents;
+
public SpecExtractor() {
- _constructs = new ArrayList<Construct>();
+ constructs = new ArrayList<Construct>();
+ contents = new HashMap<File, ArrayList<String>>();
}
- ArrayList<Construct> getConstructs() {
- return this._constructs;
- }
-
/**
* <p>
* Given a list of files, it scans each file and add found SpecConstrcut to
}
public void extract(File file) {
- StringBuilder specText = new StringBuilder();
-
- }
-
- public static String trimSpace(String line) {
- int i, j;
- char ch;
- for (i = 0; i < line.length(); i++) {
- ch = line.charAt(i);
- if (ch != ' ' && ch != '\t')
- break;
- }
- for (j = line.length() - 1; j >= 0; j--) {
- ch = line.charAt(j);
- if (ch != ' ' && ch != '\t')
- break;
+ if (contents.containsKey(file))
+ return;
+ ArrayList<String> content = new ArrayList<String>();
+ ArrayList<Construct> localConstructs = new ArrayList<Construct>();
+ try {
+ SpecParser.ParseFile(file, content, localConstructs);
+ contents.put(file, content);
+ constructs.addAll(localConstructs);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ } catch (TokenMgrError e) {
+ e.printStackTrace();
}
- if (i > j)
- return "";
- else
- return line.substring(i, j + 1);
}
+
+
}