summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/rgens/parser/elements/vars/ARefVariableElement.java
blob: 8f12f584fdce2e20c4c1a47a6b7eff5fde65dc2a (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.Rule;
/**
 * Reference to an array variable.
 * @author bjculkin
 *
 */
public class ARefVariableElement extends VariableElement {
	/**
	 * The name of the value we are referring to.
	 */
	public String value;

	/**
	 * Create a new array reference.
	 * 
	 * @param val The value of the array reference.
	 */
	public ARefVariableElement(String val) {
		super(false);

		value = val;
	}
	
	@Override
	public void generate(GenerationState state) {
		Rule rl = state.findRuleVar(value);

		GenerationState newState = state.newBuf();

		rl.generate(newState);

		String res = newState.getContents();

		state.appendContents(res);
	}
}