blob: 3192558d7e4ae3c895d22d84a84fb2d06df25dba (
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
|
package bjc.rgens.parser.elements;
import bjc.utils.data.IPair;
import bjc.rgens.parser.GenerationState;
import bjc.rgens.parser.GrammarException;
import bjc.rgens.parser.RecurLimitException;
import bjc.rgens.parser.RGrammar;
import bjc.rgens.parser.Rule;
import bjc.rgens.parser.RuleCase;
public class RuleVarRefCaseElement extends StringCaseElement {
public RuleVarRefCaseElement(String vl) {
super(vl, false);
}
public void generate(GenerationState state) {
if(!state.rlVars.containsKey(val)) {
throw new GrammarException("No rule variable named " + val);
}
Rule rl = state.rlVars.get(val);
GenerationState newState = state.newBuf();
rl.generate(newState);
String res = newState.contents.toString();
state.contents.append(res);
}
}
|