1 package edu.uci.eecs.specCompiler.specExtraction;
3 import java.util.HashMap;
5 import java.io.FileNotFoundException;
6 import java.io.FileReader;
7 import java.io.IOException;
8 import java.io.LineNumberReader;
10 import java.util.regex.Pattern;
11 import java.util.regex.Matcher;
15 * This class will scan all the input files, extract all the "special comments"
16 * (specifications). It should include information: 1. Beginning and end line of
17 * the specs; 2. The next two lines of code if it is interface constrcut.
23 public class SpecInfoScanner {
24 public final HashMap<File, Construct> constructs;
26 public SpecInfoScanner() {
27 constructs = new HashMap<File, Construct>();
37 private void scanFile(File file) {
39 FileReader fr = new FileReader(file);
40 LineNumberReader lnr = new LineNumberReader(fr);
42 // Info to keep when parsing the Spec
43 // 0 for default, 1 for potential sepc, 2 for in spec
45 Pattern pBegin = Pattern.compile("^[\\s|\\t]*/**"), pEnd = Pattern
47 while ((line = lnr.readLine()) != null) {
48 Matcher m1 = pBegin.matcher(line);
50 state = 1; // Go to 'potential spec' state
55 } catch (FileNotFoundException e) {
57 } catch (IOException e) {
62 public void scanFiles(File[] files) {
63 for (int i = 0; i < files.length; i++) {