Package org.qdl_lang.expressions
Class Monad
- java.lang.Object
-
- org.qdl_lang.expressions.ExpressionImpl
-
- org.qdl_lang.expressions.Monad
-
- All Implemented Interfaces:
Serializable
,ExpressionNode
,ExpressionInterface
,HasResultInterface
,Statement
public class Monad extends ExpressionImpl
A post or prefix operator, such a logical not or ++. The default is that this is postfix.Created by Jeff Gaynor
on 1/13/20 at 3:43 PM- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.qdl_lang.expressions.ExpressionImpl
arguments, result, valence
-
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 Monad(boolean postFix)
Monad(boolean postFix, TokenPosition tokenPosition)
Monad(int operatorType, boolean isPostFix)
Monad(int operatorType, boolean isPostFix, TokenPosition tokenPosition)
Monad(int operatorType, ExpressionNode argument)
Constructor for making a post fix monad.Monad(int operatorType, ExpressionNode argument, boolean isPostFix)
Constructor for specifying the type of operator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
evaluate(State state)
ExpressionInterface
getArgument()
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.BigDecimal
getSignedDecimalValue()
Long
getSignedLongValue()
boolean
isPostFix()
boolean
isSigned()
ExpressionNode
makeCopy()
void
setArgument(ExpressionInterface node)
void
setPostFix(boolean postFix)
-
Methods inherited from class org.qdl_lang.expressions.ExpressionImpl
evalArg, evalLastArg, evaluatedArgs, getAlias, getArgAt, getArgCount, getArguments, getEvaluatedArgs, getLastArg, getOperatorType, getResult, getResultType, getSourceCode, getTokenPosition, hasAlias, hasEvaluatedArgs, hasTokenPosition, isEvaluated, isSizeQuery, setAlias, setArguments, setEvaluated, setEvaluatedArgs, setOperatorType, setResult, setResultType, setSizeQuery, setSourceCode, setTokenPosition, toString
-
-
-
-
Constructor Detail
-
Monad
public Monad(boolean postFix)
-
Monad
public Monad(boolean postFix, TokenPosition tokenPosition)
-
Monad
public Monad(int operatorType, boolean isPostFix)
-
Monad
public Monad(int operatorType, boolean isPostFix, TokenPosition tokenPosition)
-
Monad
public Monad(int operatorType, ExpressionNode argument)
Constructor for making a post fix monad.- Parameters:
operatorType
-argument
-
-
Monad
public Monad(int operatorType, ExpressionNode argument, boolean isPostFix)
Constructor for specifying the type of operator.- Parameters:
operatorType
-argument
-isPostFix
-
-
-
Method Detail
-
isPostFix
public boolean isPostFix()
-
setPostFix
public void setPostFix(boolean postFix)
-
getArgument
public ExpressionInterface getArgument()
-
setArgument
public void setArgument(ExpressionInterface node)
-
makeCopy
public ExpressionNode makeCopy()
-
isSigned
public boolean isSigned()
-
getSignedLongValue
public Long getSignedLongValue()
-
getSignedDecimalValue
public BigDecimal getSignedDecimalValue()
-
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).- Returns:
-
-