-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExpected.java
55 lines (47 loc) · 1.03 KB
/
Expected.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package edu.lsu.cct.piraha;
import java.util.HashSet;
import java.util.Set;
public class Expected {
Seq seq;
int n;
Pattern pat;
int pos;
Set<String> possibilities = new HashSet<String>();
int epos;
Or or;
void build(int maxTextPos) {
pos = maxTextPos;
if(pat != null) {
possibilities.add(pat.decompile());
} else if(seq != null) {
StringBuffer sb = new StringBuffer();
for(int j=n;j<seq.patternList.size();j++) {
Pattern x = seq.patternList.get(j);
if(x instanceof Literal)
sb.append(x.decompile());
else if(x instanceof ILiteral)
sb.append(x.decompile());
else if(x instanceof Bracket)
sb.append(x.decompile());
else
break;
}
if(sb.length()>0)
possibilities.add(sb.toString());
}
}
public Expected() {
}
public Expected(Pattern pat) {
this.pat = pat;
}
public Expected(Seq seq,int n) {
this.seq = seq;
this.n = n;
}
public Expected(Or or,int pos) {
this.or = or;
this.epos = pos;
}
public String toString() { return possibilities.toString(); }
}