T
- the type wrapped by this Varpublic class Var<T> extends Reference<T>
This class provides a "local variable"-like construct for action expressions in parser rule methods.
Var
Var
When rule method A() passes a Var defined in its scope to another rule method B() as a parameter and an action
in rule method B() writes to this Var all actions in rule method A() running after B() will "see" this newly written
value (since values in Var
Modifier and Type | Field and Description |
---|---|
private Factory<T> |
initialValueFactory |
private int |
level |
private java.lang.String |
name |
private java.util.LinkedList<T> |
stack |
Constructor and Description |
---|
Var()
Initializes a new Var with a null initial value.
|
Var(Factory<T> initialValueFactory)
Initializes a new Var.
|
Var(T value)
Initializes a new Var with the given initial value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
enterFrame()
Provides a new frame for the variable.
|
boolean |
exitFrame()
Exits a frame previously entered with
enterFrame() . |
int |
getLevel()
Returns the current frame level of this variable, the very first level corresponding to zero.
|
java.lang.String |
getName()
Gets the name of this Var.
|
void |
setName(java.lang.String name)
Sets the name of this Var.
|
java.lang.String |
toString() |
private java.util.LinkedList<T> stack
private int level
private java.lang.String name
public Var()
public Var(T value)
value
- the valuepublic java.lang.String getName()
public void setName(java.lang.String name)
name
- the namepublic int getLevel()
public boolean enterFrame()
public boolean exitFrame()
enterFrame()
.
Normally you do not have to call this method manually as parboiled provides for automatic Var frame management.public java.lang.String toString()
toString
in class java.lang.Object