blob: e919cb8b3724073e90df9c357eff55c1b9ac93e4 (
plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
package bjc.rgens.newparser;
import bjc.utils.funcdata.IList;
/**
* A case in a rule in a randomized grammar.
*
* @author EVE
*/
public class RuleCase {
/**
* The possible types of a case.
*
* @author EVE
*
*/
public static enum CaseType {
/**
* A normal case, composed from a list of elementList.
*/
NORMAL;
}
/**
* The type of this case.
*/
public final CaseType type;
/**
* The list of element values for this case.
*
* <h2>Used For</h2>
* <dl>
* <dt>NORMAL</dt>
* <dd>Used as the list of elementList the rule is composed of.</dd>
* </dl>
*/
private IList<CaseElement> elementList;
/**
* Create a new case of the specified type.
*
* @param typ
* The type of case to create.
*
* @throws IllegalArgumentException
* If the type requires parameters.
*/
public RuleCase(CaseType typ) {
switch(typ) {
case NORMAL:
throw new IllegalArgumentException("This type requires an element list parameter");
default:
break;
}
type = typ;
}
/**
* Create a new case of the specified type that takes a element list
* parameter.
*
* @param typ
* The type of case to create.
*
* @param elements
* The element list parameter of the case.
*
* @throws IllegalArgumentException
* If this type doesn't take a element list parameter.
*/
public RuleCase(CaseType typ, IList<CaseElement> elements) {
switch(typ) {
case NORMAL:
break;
default:
throw new IllegalArgumentException("This type doesn't have a element list parameter");
}
type = typ;
elementList = elements;
}
/**
* Get the element list value of this type.
*
* @return The element list value of this case, or null if this type
* doesn't have one.
*/
public IList<CaseElement> getElements() {
return elementList;
}
}
|