public abstract class Expr
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Expr.internalFunction
list of all supported internal functions
|
static class |
Expr.operatorType
list of all supported internal operators
|
Constructor and Description |
---|
Expr() |
Modifier and Type | Method and Description |
---|---|
Expr |
append(Expr expr)
Allows appending a new expression to this expression,
thus getting a Expr_LIST if it was not already.
|
static Expr |
booleanExpr(boolean b)
constructor method - returns a boolean expression that holds the specified logical value
|
boolean |
equals(Expr other,
Context context)
compares if the values of this expression and the other expression are the same
|
abstract Expr |
eval(Context context)
evaluates this expression and returns the resulting value
|
int |
getInt()
stub to be overriden by expressions that are of numeric type, otherwise throws exception
|
static Expr.internalFunction |
getInternalFunction(java.lang.String fn) |
static Expr.operatorType |
getOperatorType(java.lang.String op)
convert an operator lexeme to the respective operator
|
java.lang.String |
getStr()
stub to be overriden by expressions that are of string type, otherwise throws exception
|
boolean |
isFalse()
stub to be overriden by expressions that are of boolean type, otherwise returns false
note: here we do not use closed-world assumption: anything else than false is not false!
|
boolean |
isTrue()
stub to be overriden by expressions that are of boolean type, otherwise returns false
|
boolean |
matches(IndexedName name,
Context context)
stub to be overriden by expressions that are of string type - it should
set the variables in the context, if the expression contains variable references
|
boolean |
matches(int i,
Context context)
stub to be overriden by expressions that are of numeric type - it should
set the variables in the context, if the expression is a variable
|
boolean |
matches(java.lang.String s,
Context context)
stub to be overriden by expressions that are of string type - it should
set the variables in the context, if the expression contains variable references
|
static Expr |
numExpr(int num)
constructor method - returns a numerical expression that holds the specified number
|
static Expr |
parseExpr(java.lang.String ln)
Parse the expression from a string representation as appears in the
game specification file.
|
static Expr |
strExpr(java.lang.String str)
constructor method - returns a string expression that holds the specified string
|
public Expr append(Expr expr)
public static Expr parseExpr(java.lang.String ln) throws java.lang.Exception
java.lang.Exception
public static Expr.operatorType getOperatorType(java.lang.String op)
public static Expr.internalFunction getInternalFunction(java.lang.String fn)
public static Expr numExpr(int num)
public static Expr strExpr(java.lang.String str)
public static Expr booleanExpr(boolean b)
public int getInt() throws java.lang.Exception
java.lang.Exception
public java.lang.String getStr() throws java.lang.Exception
java.lang.Exception
public boolean isTrue()
public boolean isFalse()
public boolean matches(java.lang.String s, Context context)
public boolean matches(int i, Context context)
public boolean matches(IndexedName name, Context context)
public abstract Expr eval(Context context) throws java.lang.Exception
java.lang.Exception