Inherits org.qscript.Token.
Inherited by org.qscript.operator.AbsFunction, org.qscript.operator.AcosFunction, org.qscript.operator.AdditionSymbol, org.qscript.operator.AndSymbol, org.qscript.operator.AngleBetweenFunction, org.qscript.operator.AsinFunction, org.qscript.operator.AssignmentSymbol, org.qscript.operator.Atan2Function, org.qscript.operator.AtanFunction, org.qscript.operator.CeilFunction, org.qscript.operator.CommaSymbol, org.qscript.operator.ComplexFunction, org.qscript.operator.ConjugateFunction, org.qscript.operator.CosFunction, org.qscript.operator.CoshFunction, org.qscript.operator.CrossFunction, org.qscript.operator.DegreesToRadians, org.qscript.operator.DivisionSymbol, org.qscript.operator.DotFunction, org.qscript.operator.E_constant, org.qscript.operator.EOL_constant, org.qscript.operator.EqualSymbol, org.qscript.operator.ExpFunction, org.qscript.operator.ExpressionSeperatorSymbol, org.qscript.operator.False_constant, org.qscript.operator.FloorFuction, org.qscript.operator.FlowOperator, org.qscript.operator.GreaterThanOrEqualSymbol, org.qscript.operator.GreaterThanSymbol, org.qscript.operator.ImagFunction, org.qscript.operator.IntFunction, org.qscript.operator.LeftParenSymbol, org.qscript.operator.LerpFunction, org.qscript.operator.LessThanOrEqualSymbol, org.qscript.operator.LessThanSymbol, org.qscript.operator.Log10_Function, org.qscript.operator.Log_Function, org.qscript.operator.LogE_Function, org.qscript.operator.MagFunction, org.qscript.operator.MaxFunction, org.qscript.operator.MinFunction, org.qscript.operator.ModuloSymbol, org.qscript.operator.MultiplicationSymbol, org.qscript.operator.NegFunction, org.qscript.operator.NormalizeFunction, org.qscript.operator.NotEqualSymbol, org.qscript.operator.NotFuntion, org.qscript.operator.OrSymbol, org.qscript.operator.PI_constant, org.qscript.operator.PowerFunction, org.qscript.operator.PrintFunction, org.qscript.operator.PrintlnFunction, org.qscript.operator.RadiansToDegrees, org.qscript.operator.RandomComplexFunction, org.qscript.operator.RandomFunction, org.qscript.operator.RandomVectorFunction, org.qscript.operator.RealFunction, org.qscript.operator.RightParenSymbol, org.qscript.operator.RoundFunction, org.qscript.operator.RuntimeFunction, org.qscript.operator.SignumFunction, org.qscript.operator.SinFunction, org.qscript.operator.SinhFunction, org.qscript.operator.SqrtFunction, org.qscript.operator.SqrtzFunction, org.qscript.operator.SubtractionSymbol, org.qscript.operator.TanFunction, org.qscript.operator.TanhFunction, org.qscript.operator.True_constant, org.qscript.operator.V000_constant, org.qscript.operator.V001_constant, org.qscript.operator.V010_constant, org.qscript.operator.V100_constant, org.qscript.operator.VectorFunction, org.qscript.operator.VectorXFunction, org.qscript.operator.VectorYFunction, org.qscript.operator.VectorZFunction, org.qscript.operator.WAIT_operator, and org.qscript.operator.XorSymbol.
|
static final int | MARKER = 0 |
|
static final int | CONSTANT = 1 |
|
static final int | INFIX_SYMBOL = 2 |
|
static final int | FUNCTION = 3 |
|
static final Token | DUMMY = new Argument(null) |
|
|
int | line |
|
int | charStart |
|
int | charWidth |
|
This is the base class for all operators to be recognized by the expression parser.
There are four operator types -
MARKER
These do not perform any evaluation themselves so they do not require any arguments. Examples include WEND, ELSE, comma, parenthesis.
CONSTANT
These are simply named values (e.g. PI, E, EOL) so they have no arguments to process but must have a high priority (40) so that its value is retrieved before further evaluation.
INFIX_SYMBOL
An infix symbols is any symbol that sits between the two operands it has to process. These include the
-
normal mathematical operators such as + = / *
-
assignment operator =
-
the logical operators && AND || OR
-
comparison operators such as == > <= !=
It does mean that infix symbols always require exactly two arguments.
FUNCTION
A function is any symbol that takes one or more arguments and evaluates them. All functions have the format
symbol(comma separated list of arguments)
These include all the common mathematical functions such as sqrt, cos, sin; but the library also has some extras such as rnd, pow
All functions have the same priority (30)
It is possible to create user defined operators and add them to the standard set.
- Author
- Peter Lager
org.qscript.operator.Operator.Operator |
( |
String |
symbol, |
|
|
int |
nbrArgs, |
|
|
int |
priority, |
|
|
int |
type |
|
) |
| |
This is the constructor used to create an operator object.
- Parameters
-
symbol | the symbol/name that identifies this operator. |
nbrArgs | the number of arguments needed by this operator |
priority | the value used to determine the order of precedence |
type | the operator type |
String org.qscript.operator.Operator.forListing |
( |
| ) |
|
Used in Script and Parser classes when listings
int org.qscript.operator.Operator.getNbrArgs |
( |
| ) |
|
Get the number of arguments needed by this operator
int org.qscript.operator.Operator.getOpType |
( |
| ) |
|
int org.qscript.operator.Operator.getPriority |
( |
| ) |
|
Get the operator priority value. This is used to determine the order that operators are evaluated.
String org.qscript.operator.Operator.getSymbol |
( |
| ) |
|
Get the operator identifying symbol
Call this method if the arguments are the incorrect types for the operator
- Parameters
-
script | the Script object responsible for evaluation |
charNo | |
charWidth | |
- Exceptions
-
boolean org.qscript.operator.Operator.isOperator |
( |
| ) |
|
- Parameters
-
script | the Script object responsible for evaluation |
token | the current token being evaluated |
args | the arguments for this operator |
objects | ignore it has been included for possible future use |
- Returns
- the result of this operation or null if there is no need to store the result
- Exceptions
-
SyntaxException | |
EvaluationException | |
Implemented in org.qscript.operator.END_operator, org.qscript.operator.SqrtFunction, org.qscript.operator.SqrtzFunction, org.qscript.operator.AssignmentSymbol, org.qscript.operator.PowerFunction, org.qscript.operator.WAIT_operator, org.qscript.operator.AsinFunction, org.qscript.operator.DivisionSymbol, org.qscript.operator.ELSE_operator, org.qscript.operator.ImagFunction, org.qscript.operator.MultiplicationSymbol, org.qscript.operator.NegFunction, org.qscript.operator.SubtractionSymbol, org.qscript.operator.WEND_operator, org.qscript.operator.AcosFunction, org.qscript.operator.AtanFunction, org.qscript.operator.CosFunction, org.qscript.operator.CoshFunction, org.qscript.operator.ENDIF_operator, org.qscript.operator.ExpFunction, org.qscript.operator.IF_operator, org.qscript.operator.LogE_Function, org.qscript.operator.PrintFunction, org.qscript.operator.PrintlnFunction, org.qscript.operator.RandomComplexFunction, org.qscript.operator.RandomVectorFunction, org.qscript.operator.RealFunction, org.qscript.operator.REPEAT_operator, org.qscript.operator.SinFunction, org.qscript.operator.SinhFunction, org.qscript.operator.TanFunction, org.qscript.operator.TanhFunction, org.qscript.operator.UNTIL_operator, org.qscript.operator.V000_constant, org.qscript.operator.V001_constant, org.qscript.operator.V010_constant, org.qscript.operator.V100_constant, org.qscript.operator.VectorXFunction, org.qscript.operator.VectorYFunction, org.qscript.operator.VectorZFunction, org.qscript.operator.WHILE_operator, org.qscript.operator.AbsFunction, org.qscript.operator.AndSymbol, org.qscript.operator.Atan2Function, org.qscript.operator.CeilFunction, org.qscript.operator.CommaSymbol, org.qscript.operator.ConjugateFunction, org.qscript.operator.DegreesToRadians, org.qscript.operator.E_constant, org.qscript.operator.EOL_constant, org.qscript.operator.EqualSymbol, org.qscript.operator.False_constant, org.qscript.operator.GreaterThanOrEqualSymbol, org.qscript.operator.GreaterThanSymbol, org.qscript.operator.IntFunction, org.qscript.operator.LeftParenSymbol, org.qscript.operator.LessThanOrEqualSymbol, org.qscript.operator.LessThanSymbol, org.qscript.operator.Log10_Function, org.qscript.operator.MaxFunction, org.qscript.operator.MinFunction, org.qscript.operator.ModuloSymbol, org.qscript.operator.NotEqualSymbol, org.qscript.operator.NotFuntion, org.qscript.operator.OrSymbol, org.qscript.operator.PI_constant, org.qscript.operator.RadiansToDegrees, org.qscript.operator.RandomFunction, org.qscript.operator.RightParenSymbol, org.qscript.operator.RoundFunction, org.qscript.operator.RuntimeFunction, org.qscript.operator.SignumFunction, org.qscript.operator.True_constant, org.qscript.operator.XorSymbol, org.qscript.operator.ExpressionSeperatorSymbol, org.qscript.operator.AdditionSymbol, org.qscript.operator.AngleBetweenFunction, org.qscript.operator.LerpFunction, org.qscript.operator.CrossFunction, org.qscript.operator.MagFunction, org.qscript.operator.NormalizeFunction, org.qscript.operator.DotFunction, org.qscript.operator.VectorFunction, org.qscript.operator.Log_Function, org.qscript.operator.FloorFuction, and org.qscript.operator.ComplexFunction.
This method checks to see if a variable has been initialized.
- Parameters
-
script | the Script object responsible for evaluation |
args | list of Arguments to check |
- Returns
- true if the variable has been initialized
- Exceptions
-
SyntaxException | |
EvaluationException | |
This method checks for uninitialized variables and should be called by the first statement in the method resolve().
The only exception is the Assignment class where the left hand operand may be an uninitialized variable.
- Parameters
-
script | the Script object responsible for evaluation |
args | list of Arguments to check |
- Exceptions
-
SyntaxException | |
EvaluationException | |
The documentation for this class was generated from the following file:
- /Users/peter/git/qscript-repos/Q-script/src/org/qscript/operator/Operator.java