blob: cdead802a73638ad4396a339eba045628d4f0971 (
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
|
package bjc.rgens.parser.elements.vars;
import bjc.rgens.parser.GenerationState;
import bjc.rgens.parser.GrammarException;
/**
* Variable reference variable element.
*
* @author Ben Culkin
*
*/
public class VRefVariableElement extends VariableElement {
/**
* The name of the variable to element.
*/
public final String nam;
/**
* Create a new variable referencing variable element.
* @param forbidSpaces Whether or not to forbid spaces in the element.
* @param nam The name of the variable.
*/
public VRefVariableElement(boolean forbidSpaces, String nam) {
super(forbidSpaces);
this.nam = nam;
}
@Override
public void generate(GenerationState state) {
String strang = state.findVar(nam);
if(forbidSpaces && strang.contains(" ")) {
throw new GrammarException(String.format("Cannot include variable %s w/ spaces in body in rule name", nam));
}
state.appendContents(strang);
}
}
|