Package org.qdl_lang.expressions
Class ExpressionStemNode
- java.lang.Object
-
- org.qdl_lang.expressions.ExpressionStemNode
-
- All Implemented Interfaces:
Serializable
,ExpressionInterface
,HasResultInterface
,Statement
public class ExpressionStemNode extends Object implements ExpressionInterface
Models a stem.Created by Jeff Gaynor
on 3/5/21 at 5:58 AM- See Also:
- Serialized Form
-
-
Field Summary
-
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 ExpressionStemNode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
doLeftSVCase(ExpressionInterface leftArg, List<ExpressionInterface> indices, State state)
Case that the left hand argument is a stem variable.protected Object
doLeftSVCase(ExpressionInterface leftArg, ExpressionInterface rightArg, State state)
Object
evaluate(State state)
Since this is a dyadic operation in the parser, the result will be a tree of objects of the formString
getAlias()
ArrayList<ExpressionInterface>
getArguments()
ExpressionInterface
getLeftArg()
int
getNodeType()
QDL is not strongly typed but Java is, so each node type should have a unique integer and conditionals should use that, not the instanceof operator.protected Object
getOrSetValue(State state, boolean setValue, Object newValue)
Object
getResult()
int
getResultType()
ExpressionInterface
getRightArg()
List<String>
getSourceCode()
TokenPosition
getTokenPosition()
boolean
hasAlias()
boolean
hasTokenPosition()
boolean
isEvaluated()
ExpressionInterface
makeCopy()
void
setAlias(String alias)
void
setArguments(ArrayList<ExpressionInterface> arguments)
void
setEvaluated(boolean evaluated)
void
setLeftArg(ExpressionInterface swri)
void
setResult(Object object)
void
setResultType(int type)
void
setRightArg(ExpressionInterface swri)
void
setSourceCode(List<String> sourceCode)
void
setTokenPosition(TokenPosition tokenPosition)
Set the location of this token from the parser.Object
setValue(State state, Object newValue)
-
-
-
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
-
getArguments
public ArrayList<ExpressionInterface> getArguments()
-
setArguments
public void setArguments(ArrayList<ExpressionInterface> arguments)
-
getResult
public Object getResult()
- Specified by:
getResult
in interfaceHasResultInterface
-
setResult
public void setResult(Object object)
- Specified by:
setResult
in interfaceHasResultInterface
-
getResultType
public int getResultType()
- Specified by:
getResultType
in interfaceHasResultInterface
-
setResultType
public void setResultType(int type)
- Specified by:
setResultType
in interfaceHasResultInterface
-
isEvaluated
public boolean isEvaluated()
- Specified by:
isEvaluated
in interfaceHasResultInterface
-
setEvaluated
public void setEvaluated(boolean evaluated)
- Specified by:
setEvaluated
in interfaceHasResultInterface
-
getLeftArg
public ExpressionInterface getLeftArg()
-
setLeftArg
public void setLeftArg(ExpressionInterface swri)
-
setRightArg
public void setRightArg(ExpressionInterface swri)
-
getRightArg
public ExpressionInterface getRightArg()
-
evaluate
public Object evaluate(State state)
Since this is a dyadic operation in the parser, the result will be a tree of objects of the formx / \ ... scalar x / \ A B
-
doLeftSVCase
protected Object doLeftSVCase(ExpressionInterface leftArg, ExpressionInterface rightArg, State state)
-
doLeftSVCase
protected Object doLeftSVCase(ExpressionInterface leftArg, List<ExpressionInterface> indices, State state)
Case that the left hand argument is a stem variable. This does the lookup. In the variable case, aStemMultiIndex
is created and interacts with theState
to do the resolutions.- Parameters:
leftArg
-state
-- Returns:
-
getSourceCode
public List<String> getSourceCode()
- Specified by:
getSourceCode
in interfaceStatement
-
setSourceCode
public void setSourceCode(List<String> sourceCode)
- Specified by:
setSourceCode
in interfaceStatement
-
makeCopy
public ExpressionInterface makeCopy()
- Specified by:
makeCopy
in interfaceExpressionInterface
-
getNodeType
public int getNodeType()
Description copied from interface:ExpressionInterface
QDL is not strongly typed but Java is, so each node type should have a unique integer and conditionals should use that, not the instanceof operator. This allows for efficient programming with switch statements rather than a bevy of conditionals (potentially each of which gets done even if the correct case has been handled).- Specified by:
getNodeType
in interfaceExpressionInterface
- Returns:
-
-