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,AxisExpression,ClosedSliceNode,ConstantNode,Dyad,DyadicFunctionReferenceNode,ESN2,FunctionReferenceNode,LambdaDefinitionNode,ModuleExpression,Monad,Nilad,OpenSliceNode,Polyad,SelectExpressionNode,StemExtractionNode,VariableNode
public abstract class ExpressionImpl extends Object implements ExpressionNode
Main workhorse class. Expressions from the parser are some subclass of this.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>argumentsprotected QDLValueresultprotected intvalenceThe 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, AXIS_RESTRICTION_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 voidaddArgument(ExpressionInterface expr)QDLValueevalArg(int index, State state)QDLValueevalLastArg(State state)List<QDLValue>evaluatedArgs(State state)Evaluate the arguments using the given state and set thesetEvaluatedArgs(List)Calling this evaluates the args.StringgetAlias()ExpressionInterfacegetArgAt(int index)intgetArgCount()ArrayList<ExpressionInterface>getArguments()List<QDLValue>getEvaluatedArgs()The arguments to this polyad that have been evaluated vis a vis a specific state.ExpressionInterfacegetLastArg()intgetOperatorType()This is the operator equiavalent of a function.QDLValuegetResult()intgetResultType()List<String>getSourceCode()TokenPositiongetTokenPosition()booleanhasAlias()booleanhasEvaluatedArgs()booleanhasTokenPosition()booleanisEvaluated()booleanisSizeQuery()Used when resolving function references to query the operator itself as to how many arguments it accepts.voidsetAlias(String alias)voidsetArguments(ArrayList<ExpressionInterface> arguments)voidsetEvaluated(boolean evaluated)voidsetEvaluatedArgs(List<QDLValue> evaluatedArgs)voidsetOperatorType(int operatorType)voidsetResult(Object result)Convenience method.This should turn the object into a properQDLValueas needed.voidsetResult(QDLValue result)voidsetSizeQuery(boolean sizeQuery)voidsetSourceCode(List<String> sourceCode)voidsetTokenPosition(TokenPosition tokenPosition)Set the location of this token from the parser.StringtoString()- 
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 QDLValue 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:StatementSet the location of this token from the parser. This is used for error notifications later.- Specified by:
 setTokenPositionin interfaceStatement
 
- 
getTokenPosition
public TokenPosition getTokenPosition()
- Specified by:
 getTokenPositionin interfaceStatement
 
- 
hasTokenPosition
public boolean hasTokenPosition()
- Specified by:
 hasTokenPositionin interfaceStatement
 
- 
hasAlias
public boolean hasAlias()
- Specified by:
 hasAliasin interfaceExpressionInterface
 
- 
getAlias
public String getAlias()
- Specified by:
 getAliasin interfaceExpressionInterface
 
- 
setAlias
public void setAlias(String alias)
- Specified by:
 setAliasin interfaceExpressionInterface
 
- 
getArgCount
public int getArgCount()
- Specified by:
 getArgCountin interfaceExpressionNode
 
- 
getLastArg
public ExpressionInterface getLastArg()
 
- 
getArguments
public ArrayList<ExpressionInterface> getArguments()
- Specified by:
 getArgumentsin interfaceExpressionNode
 
- 
getArgAt
public ExpressionInterface getArgAt(int index)
- Specified by:
 getArgAtin interfaceExpressionNode
 
- 
setArguments
public void setArguments(ArrayList<ExpressionInterface> arguments)
- Specified by:
 setArgumentsin interfaceExpressionNode
 
- 
isEvaluated
public boolean isEvaluated()
- Specified by:
 isEvaluatedin interfaceHasResultInterface
 
- 
setEvaluated
public void setEvaluated(boolean evaluated)
- Specified by:
 setEvaluatedin interfaceHasResultInterface
 
- 
getResult
public QDLValue getResult()
- Specified by:
 getResultin 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:
 getResultTypein interfaceHasResultInterface
 
- 
setResult
public void setResult(QDLValue result)
- Specified by:
 setResultin interfaceHasResultInterface
 
- 
setResult
public void setResult(Object result)
Description copied from interface:HasResultInterfaceConvenience method.This should turn the object into a properQDLValueas needed.- Specified by:
 setResultin interfaceHasResultInterface
 
- 
setOperatorType
public void setOperatorType(int operatorType)
- Specified by:
 setOperatorTypein interfaceExpressionNode
 
- 
getOperatorType
public int getOperatorType()
This is the operator equiavalent of a function.EvaluatorInterface.UNKNOWN_VALUEis the default.- Specified by:
 getOperatorTypein interfaceExpressionNode- Returns:
 
 
- 
getSourceCode
public List<String> getSourceCode()
- Specified by:
 getSourceCodein interfaceStatement
 
- 
setSourceCode
public void setSourceCode(List<String> sourceCode)
- Specified by:
 setSourceCodein interfaceStatement
 
- 
getEvaluatedArgs
public List<QDLValue> 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<QDLValue> 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()
 
- 
addArgument
public void addArgument(ExpressionInterface expr)
 
 - 
 
 -