public class Expression
extends java.lang.Object
add(java.lang.String, xyz.avarel.aje.runtime.Obj), compile and compute an AJE expression. All values are stored
in the scope. The expression not compiled until the invocation of either compile() or
compute() explicitly; AJEException and its derivatives would not be thrown until then.| Constructor and Description |
|---|
Expression(AJELexer lexer,
Scope scope)
Creates an expression based on a stream of tokens from a lexer.
|
Expression(java.io.Reader reader)
Creates an expression based on the character stream from a reader.
|
Expression(java.io.Reader reader,
Scope scope)
Creates an expression based on the character stream from a reader.
|
Expression(java.lang.String script)
Creates an expression based on a string.
|
Expression(java.lang.String script,
Scope scope)
Creates an expression based on a string.
|
| Modifier and Type | Method and Description |
|---|---|
Expression |
add(java.lang.String name,
Expression object)
Declare a variable with the name and the
Obj value from the evaluated Expression. |
Expression |
add(java.lang.String name,
Obj object)
Declare a variable with the name and the
Obj parameter. |
Expr |
compile()
Parse the expression into an AST structure of
Expr nodes. |
Obj |
compute()
Compile if this expression has not been already compiled and compute its value.
|
public Expression(java.lang.String script)
default scope
and its values. This constructor is a shortcut for
Expression(String, DefaultScope.INSTANCE.copy())script - The string of AJE expression.public Expression(java.io.Reader reader)
default scope and its values. This constructor is a shortcut for
Expression(Reader, DefaultScope.INSTANCE.copy())reader - The reader instance that reads AJE expressions.\public Expression(java.lang.String script,
Scope scope)
script - The string of AJE expression.scope - The scope to evaluate the expression from.public Expression(java.io.Reader reader,
Scope scope)
reader - The reader instance that reads AJE expressions.scope - The scope to evaluate the expression from.public Expression add(java.lang.String name, Obj object)
Obj parameter.name - The name of the variable to assign the value to.object - The Obj value.Expression builder instance. Useful for chaining.public Expression add(java.lang.String name, Expression object)
Obj value from the evaluated Expression. Note that
the Expression parameter has its own Scope and can not access any values of the current
expression.name - The name of the variable to assign the value to.object - The Expression value which is then computed as an Obj.Expression builder instance. Useful for chaining.public Expr compile()
Expr nodes.Expr.SyntaxException - Error during the lexing or parsing process of the expression.public Obj compute()
SyntaxException - Error during the lexing or parsing process of the expression. Thrown by the invocation of
compile().ComputeException - Error during the execution of the expression.