Package org.qdl_lang.expressions
Class ExpressionImpl
- java.lang.Object
-
- org.qdl_lang.expressions.ExpressionImpl
-
- All Implemented Interfaces:
Serializable
,ExpressionNode
,ExpressionInterface
,HasResultInterface
,Statement
- Direct Known Subclasses:
AltIfExpressionNode
,ANode2
,ClosedSliceNode
,ConstantNode
,Dyad
,DyadicFunctionReferenceNode
,ESN2
,FunctionReferenceNode
,LambdaDefinitionNode
,ModuleExpression
,Monad
,Nilad
,OpenSliceNode
,Polyad
,SelectExpressionNode
,StemExtractionNode
,VariableNode
public abstract class ExpressionImpl extends Object implements ExpressionNode
Created by Jeff Gaynor
on 1/13/20 at 3:15 PM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<ExpressionInterface>
arguments
protected Object
result
protected int
valence
The valence is the number of arguments this expression allows.-
Fields inherited from interface org.qdl_lang.statements.ExpressionInterface
ALL_INDICES_NODE, ALT_IF_NODE, ASSIGNMENT_NODE, CLOSED_SLICE_NODE, COMPARISON_DYAD_NODE, CONSTANT_NODE, DYAD_NODE, DYADIC_FUNCTION_REFERENCE_NODE, EXPRESSION_STEM_NODE, EXPRESSION_STEM2_NODE, FUNCTION_REFERENCE_NODE, LAMBDA_DEFINITION_NODE, LIST_NODE, MODULE_NODE, MONAD_NODE, NILAD_NODE, OPEN_SLICE_NODE, PARENTHESIZED_NODE, PARSE_EXPRESSION_BLOCK_NODE, PARSE_STATEMENT_BLOCK_NODE, POLYAD_NODE, QDL_NULL_NODE, SELECT_NODE, SET_NODE, STEM_ENTRY_NODE, STEM_EXTRACTION_NODE, STEM_NODE, UNKNOWN_NODE, VARIABLE_NODE
-
-
Constructor Summary
Constructors Constructor Description ExpressionImpl()
ExpressionImpl(int operatorType)
ExpressionImpl(int operatorType, TokenPosition tokenPosition)
ExpressionImpl(TokenPosition tokenPosition)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
evalArg(int index, State state)
Object
evalLastArg(State state)
List<Object>
evaluatedArgs(State state)
Evaluate the arguments using the given state and set thesetEvaluatedArgs(List)
Calling this evaluates the args.String
getAlias()
ExpressionInterface
getArgAt(int index)
int
getArgCount()
ArrayList<ExpressionInterface>
getArguments()
List<Object>
getEvaluatedArgs()
The arguments to this polyad that have been evaluated vis a vis a specific state.ExpressionInterface
getLastArg()
int
getOperatorType()
This is the operator equiavalent of a function.Object
getResult()
int
getResultType()
List<String>
getSourceCode()
TokenPosition
getTokenPosition()
boolean
hasAlias()
boolean
hasEvaluatedArgs()
boolean
hasTokenPosition()
boolean
isEvaluated()
boolean
isSizeQuery()
Used when resolving function references to query the operator itself as to how many arguments it accepts.void
setAlias(String alias)
void
setArguments(ArrayList<ExpressionInterface> arguments)
void
setEvaluated(boolean evaluated)
void
setEvaluatedArgs(List<Object> evaluatedArgs)
void
setOperatorType(int operatorType)
void
setResult(Object result)
void
setResultType(int resultType)
void
setSizeQuery(boolean sizeQuery)
void
setSourceCode(List<String> sourceCode)
void
setTokenPosition(TokenPosition tokenPosition)
Set the location of this token from the parser.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.qdl_lang.statements.ExpressionInterface
getNodeType, makeCopy
-
-
-
-
Field Detail
-
valence
protected int valence
The valence is the number of arguments this expression allows.
0 = niladic 1 = monadic 2 = dyadic 3 = polyadic (more than 2)
-
arguments
protected ArrayList<ExpressionInterface> arguments
-
result
protected Object result
-
-
Constructor Detail
-
ExpressionImpl
public ExpressionImpl()
-
ExpressionImpl
public ExpressionImpl(TokenPosition tokenPosition)
-
ExpressionImpl
public ExpressionImpl(int operatorType, TokenPosition tokenPosition)
-
ExpressionImpl
public ExpressionImpl(int operatorType)
-
-
Method Detail
-
setTokenPosition
public void setTokenPosition(TokenPosition tokenPosition)
Description copied from interface:Statement
Set the location of this token from the parser. This is used for error notifications later.- Specified by:
setTokenPosition
in interfaceStatement
-
getTokenPosition
public TokenPosition getTokenPosition()
- Specified by:
getTokenPosition
in interfaceStatement
-
hasTokenPosition
public boolean hasTokenPosition()
- Specified by:
hasTokenPosition
in interfaceStatement
-
hasAlias
public boolean hasAlias()
- Specified by:
hasAlias
in interfaceExpressionInterface
-
getAlias
public String getAlias()
- Specified by:
getAlias
in interfaceExpressionInterface
-
setAlias
public void setAlias(String alias)
- Specified by:
setAlias
in interfaceExpressionInterface
-
getArgCount
public int getArgCount()
- Specified by:
getArgCount
in interfaceExpressionNode
-
getLastArg
public ExpressionInterface getLastArg()
-
getArguments
public ArrayList<ExpressionInterface> getArguments()
- Specified by:
getArguments
in interfaceExpressionNode
-
getArgAt
public ExpressionInterface getArgAt(int index)
- Specified by:
getArgAt
in interfaceExpressionNode
-
setArguments
public void setArguments(ArrayList<ExpressionInterface> arguments)
- Specified by:
setArguments
in interfaceExpressionNode
-
isEvaluated
public boolean isEvaluated()
- Specified by:
isEvaluated
in interfaceHasResultInterface
-
setEvaluated
public void setEvaluated(boolean evaluated)
- Specified by:
setEvaluated
in interfaceHasResultInterface
-
getResult
public Object getResult()
- Specified by:
getResult
in interfaceHasResultInterface
-
isSizeQuery
public boolean isSizeQuery()
Used when resolving function references to query the operator itself as to how many arguments it accepts.- Returns:
-
setSizeQuery
public void setSizeQuery(boolean sizeQuery)
-
getResultType
public int getResultType()
- Specified by:
getResultType
in interfaceHasResultInterface
-
setResult
public void setResult(Object result)
- Specified by:
setResult
in interfaceHasResultInterface
-
setResultType
public void setResultType(int resultType)
- Specified by:
setResultType
in interfaceHasResultInterface
-
setOperatorType
public void setOperatorType(int operatorType)
- Specified by:
setOperatorType
in interfaceExpressionNode
-
getOperatorType
public int getOperatorType()
This is the operator equiavalent of a function.EvaluatorInterface.UNKNOWN_VALUE
is the default.- Specified by:
getOperatorType
in interfaceExpressionNode
- Returns:
-
getSourceCode
public List<String> getSourceCode()
- Specified by:
getSourceCode
in interfaceStatement
-
setSourceCode
public void setSourceCode(List<String> sourceCode)
- Specified by:
setSourceCode
in interfaceStatement
-
getEvaluatedArgs
public List<Object> getEvaluatedArgs()
The arguments to this polyad that have been evaluated vis a vis a specific state. The intent is that this is used in evaluating functions sent via a module, where the arguments are evaluated in the ambient state and forwarded to the module for later evaluation. This has to be done since there is no way to figure out the state in general where these evaluate except at exactly the point where they are called.- Returns:
-
evaluatedArgs
public List<Object> evaluatedArgs(State state)
Evaluate the arguments using the given state and set thesetEvaluatedArgs(List)
Calling this evaluates the args.- Parameters:
state
-- Returns:
-
hasEvaluatedArgs
public boolean hasEvaluatedArgs()
-
-