public abstract class Expression extends Object implements ParseInfo
Modifier and Type | Class and Description |
---|---|
static class |
Expression.BinaryOp
Binary operators.
|
static class |
Expression.BooleanOp
Boolean operators.
|
static class |
Expression.DataOp
Data operators.
|
static class |
Expression.FunctCallOp
Function call operators.
|
static class |
Expression.RelationalOp
Relational operators.
|
Constructor and Description |
---|
Expression() |
Modifier and Type | Method and Description |
---|---|
static Types.DataType |
computeDataType(Expression expression1,
Expression expression2,
boolean cast)
Compute data type based on expressions.
|
static Types.DataType |
computeDataType(Identifier identifier1,
Identifier identifier2,
boolean cast)
Compute data type based on identifiers.
|
static Types.ValueType |
computeValueType(Expression expression1,
Expression expression2,
boolean cast)
Compute value type based on expressions.
|
static Types.ValueType |
computeValueType(Expression expr1,
Types.ValueType v1,
Types.ValueType v2,
boolean cast) |
static Types.ValueType |
computeValueType(Identifier identifier1,
Identifier identifier2,
boolean cast)
Compute value type based on identifiers.
|
static Types.FileFormat |
convertFormatType(String format)
Convert string format type to
Hop.FileFormatTypes . |
boolean |
equals(Object that) |
int |
getBeginColumn() |
int |
getBeginLine() |
static MatrixCharacteristics |
getBinaryMatrixCharacteristics(Expression expression1,
Expression expression2)
Returns the matrix characteristics for scalar-scalar, scalar-matrix, matrix-scalar, matrix-matrix
operations.
|
static Expression.BinaryOp |
getBinaryOp(String val)
Convert string value to binary operator.
|
static Expression.BooleanOp |
getBooleanOp(String val)
Convert string value to boolean operator.
|
int |
getEndColumn() |
int |
getEndLine() |
String |
getFilename() |
Identifier |
getOutput()
Obtain identifier.
|
Identifier[] |
getOutputs()
Obtain identifiers.
|
ArrayList<String> |
getParseExceptionList() |
static Expression.RelationalOp |
getRelationalOp(String val)
Convert string value to relational operator.
|
static String |
getTempName()
Obtain temporary name ("parsertemp" + _tempId) for expression.
|
String |
getText() |
int |
hashCode() |
String |
printErrorLocation() |
String |
printInfoLocation()
Return info message containing the filename, the beginning line position, and the beginning column position.
|
String |
printWarningLocation() |
void |
raiseValidateError(String message)
Throw a LanguageException with the message.
|
void |
raiseValidateError(String message,
boolean conditional)
Throw a LanguageException with the message if conditional is
false ;
otherwise log the message as a warning. |
void |
raiseValidateError(String msg,
boolean conditional,
String errorCode)
Throw a LanguageException with the message (and optional error code) if conditional is
false ;
otherwise log the message as a warning. |
abstract Expression |
rewriteExpression(String prefix) |
void |
setBeginColumn(int passed) |
void |
setBeginLine(int passed) |
void |
setCtxValues(org.antlr.v4.runtime.ParserRuleContext ctx)
Set ParserRuleContext values (begin line, begin column, end line, end
column, and text).
|
void |
setCtxValuesAndFilename(org.antlr.v4.runtime.ParserRuleContext ctx,
String filename)
Set ParserRuleContext values (begin line, begin column, end line, end
column, and text) and file name.
|
void |
setEndColumn(int passed) |
void |
setEndLine(int passed) |
void |
setFilename(String passed) |
void |
setOutput(Identifier output) |
void |
setParseExceptionList(ArrayList<String> passed) |
void |
setParseInfo(ParseInfo parseInfo)
Set parse information.
|
void |
setText(String text) |
void |
validateExpression(HashMap<String,DataIdentifier> ids,
HashMap<String,ConstIdentifier> currConstVars,
boolean conditional) |
void |
validateExpression(MultiAssignmentStatement mas,
HashMap<String,DataIdentifier> ids,
HashMap<String,ConstIdentifier> currConstVars,
boolean conditional) |
abstract VariableSet |
variablesRead() |
abstract VariableSet |
variablesUpdated() |
getClass, notify, notifyAll, toString, wait, wait, wait
ctxAndFilenameToParseInfo
public abstract Expression rewriteExpression(String prefix)
public void setOutput(Identifier output)
public Identifier getOutput()
public Identifier[] getOutputs()
public void validateExpression(HashMap<String,DataIdentifier> ids, HashMap<String,ConstIdentifier> currConstVars, boolean conditional)
public void validateExpression(MultiAssignmentStatement mas, HashMap<String,DataIdentifier> ids, HashMap<String,ConstIdentifier> currConstVars, boolean conditional)
public static Expression.BinaryOp getBinaryOp(String val)
val
- String value ('+', '-', '*', '/', '%%', '%/%', '^', %*%')BinaryOp.PLUS
, BinaryOp.MINUS
,
BinaryOp.MULT
, BinaryOp.DIV
, BinaryOp.MODULUS
,
BinaryOp.INTDIV
, BinaryOp.POW
, BinaryOp.MATMULT
).
Returns BinaryOp.INVALID
if string value not recognized.public static Expression.RelationalOp getRelationalOp(String val)
val
- String value ('<', '<=', '>', '>=', '==', '!=')RelationalOp.LESS
, RelationalOp.LESSEQUAL
,
RelationalOp.GREATER
, RelationalOp.GREATEREQUAL
, RelationalOp.EQUAL
,
RelationalOp.NOTEQUAL
).
Returns RelationalOp.INVALID
if string value not recognized.public static Expression.BooleanOp getBooleanOp(String val)
val
- String value ('&&', '&', '||', '|', '!')BooleanOp.CONDITIONALAND
, BooleanOp.LOGICALAND
,
BooleanOp.CONDITIONALOR
, BooleanOp.LOGICALOR
, BooleanOp.NOT
).
Returns BooleanOp.INVALID
if string value not recognized.public static Types.FileFormat convertFormatType(String format)
Hop.FileFormatTypes
.format
- String format type ("text", "binary", "mm", "csv")Hop.FileFormatTypes
. Can be
FileFormatTypes.TEXT
, FileFormatTypes.BINARY
,
FileFormatTypes.MM
, or FileFormatTypes.CSV
. Unrecognized
type is set to FileFormatTypes.TEXT
.public static String getTempName()
public abstract VariableSet variablesRead()
public abstract VariableSet variablesUpdated()
public static Types.DataType computeDataType(Expression expression1, Expression expression2, boolean cast)
computeDataType(Identifier, Identifier, boolean)
. If the identifiers have the same data type, the shared data type is
returned. Otherwise, if cast
is true
and one of the identifiers is a matrix and the other
identifier is a scalar, return DataType.MATRIX
. Otherwise, throw a LanguageException.expression1
- First expressionexpression2
- Second expressioncast
- Whether a cast should potentially be performedTypes.DataType
)public static Types.DataType computeDataType(Identifier identifier1, Identifier identifier2, boolean cast)
cast
is true
and one of the identifiers is a matrix and the other
identifier is a scalar, return DataType.MATRIX
. Otherwise, throw a LanguageException.identifier1
- First identifieridentifier2
- Second identifiercast
- Whether a cast should potentially be performedTypes.DataType
)public static Types.ValueType computeValueType(Expression expression1, Expression expression2, boolean cast)
computeValueType(Identifier, Identifier, boolean)
. If the identifiers have the same value type, the shared value type is
returned. Otherwise, if cast
is true
and one value type is a double and the other is an int,
return ValueType.DOUBLE
. If cast
is true
and one value type is a string or the other value type is a string, return
ValueType.STRING
. Otherwise, throw a LanguageException.expression1
- First expressionexpression2
- Second expressioncast
- Whether a cast should potentially be performedTypes.ValueType
)public static Types.ValueType computeValueType(Identifier identifier1, Identifier identifier2, boolean cast)
cast
is true
and one value type is a double and the other is an int,
return ValueType.DOUBLE
. If cast
is true
and one value type is a string or the other value type is a string, return
ValueType.STRING
. Otherwise, throw a LanguageException.identifier1
- First identifieridentifier2
- Second identifiercast
- Whether a cast should potentially be performedTypes.ValueType
)public static Types.ValueType computeValueType(Expression expr1, Types.ValueType v1, Types.ValueType v2, boolean cast)
public void raiseValidateError(String message)
message
- the error messagepublic void raiseValidateError(String message, boolean conditional)
false
;
otherwise log the message as a warning.message
- the error (or warning) messageconditional
- if true
, display log warning message. Otherwise, the message
will be thrown as a LanguageExceptionpublic void raiseValidateError(String msg, boolean conditional, String errorCode)
false
;
otherwise log the message as a warning.msg
- the error (or warning) messageconditional
- if true
, display log warning message. Otherwise, the message (and optional
error code) will be thrown as a LanguageExceptionerrorCode
- optional error codepublic static MatrixCharacteristics getBinaryMatrixCharacteristics(Expression expression1, Expression expression2)
expression1
- The first expressionexpression2
- The second expressionpublic void setFilename(String passed)
setFilename
in interface ParseInfo
public void setBeginLine(int passed)
setBeginLine
in interface ParseInfo
public void setBeginColumn(int passed)
setBeginColumn
in interface ParseInfo
public void setEndLine(int passed)
setEndLine
in interface ParseInfo
public void setEndColumn(int passed)
setEndColumn
in interface ParseInfo
public void setParseInfo(ParseInfo parseInfo)
parseInfo
- parse information, such as beginning line position, beginning
column position, ending line position, ending column position,
text, and filenamepublic void setCtxValues(org.antlr.v4.runtime.ParserRuleContext ctx)
ctx
- the antlr ParserRuleContextpublic void setCtxValuesAndFilename(org.antlr.v4.runtime.ParserRuleContext ctx, String filename)
ctx
- the antlr ParserRuleContextfilename
- the filename (if it exists)public String getFilename()
getFilename
in interface ParseInfo
public int getBeginLine()
getBeginLine
in interface ParseInfo
public int getBeginColumn()
getBeginColumn
in interface ParseInfo
public int getEndLine()
getEndLine
in interface ParseInfo
public int getEndColumn()
getEndColumn
in interface ParseInfo
public String printErrorLocation()
public String printWarningLocation()
public String printInfoLocation()
Copyright © 2020 The Apache Software Foundation. All rights reserved.