import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import edu.uci.eecs.specCompiler.grammerParser.ParseException;
import edu.uci.eecs.specCompiler.grammerParser.SpecParser;
*
*/
public class SpecExtractor {
- public final ArrayList<Construct> constructs;
-
- public final HashMap<File, ArrayList<String>> contents;
-
+ public final HashMap<File, SourceFileInfo> srcFilesInfo;
public SpecExtractor() {
- constructs = new ArrayList<Construct>();
- contents = new HashMap<File, ArrayList<String>>();
+ srcFilesInfo = new HashMap<File, SourceFileInfo>();
+ }
+
+ public ArrayList<Construct> getConstructs() {
+ ArrayList<Construct> constructs = new ArrayList<Construct>();
+ for (File f : srcFilesInfo.keySet()) {
+ constructs.addAll(srcFilesInfo.get(f).constructs);
+ }
+ return constructs;
}
/**
}
public void extract(File file) {
- if (contents.containsKey(file))
+ if (srcFilesInfo.containsKey(file))
return;
- ArrayList<String> content = new ArrayList<String>();
- ArrayList<Construct> localConstructs = new ArrayList<Construct>();
+ SourceFileInfo srcFileInfo;
try {
- SpecParser.ParseFile(file, content, localConstructs);
- contents.put(file, content);
- constructs.addAll(localConstructs);
+ srcFileInfo = SpecParser.ParseFile(file);
+ srcFilesInfo.put(file, srcFileInfo);
} catch (ParseException e) {
e.printStackTrace();
} catch (TokenMgrError e) {