|
http://www.eteks.com | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Syntax used by parsers. This interface specifies all the keys and
various methods used by a parser to check the syntax of parsed strings.
getConstantKey ()
, getUnaryOperatorKey ()
,
getBinaryOperatorKey ()
, getConditionPartKey ()
,
getCommonFunctionKey ()
methods are called by the parser to check
if a string extracted from a parsed expression is a valid lexical element or
not for the syntax.
These methods returns one of the Integer
constants matching keys
described in this interface if the extracted string is respectively a constant,
an unary opertor, a binary operator, a condition part or a common function of the syntax.
Examples :
getBinaryOperatorKey ()
method returns OPERATOR_MULTIPLY
.getCommonFunctionKey ()
method returns FUNCTION_SIN
.getBinaryOperatorPriority ()
method returns a positive number telling
the priority of each binary operator keys supported by the syntax. All the binary operators
with the same priority are left-to-right associative. All the unary operators and function
calls have the highest priority and are right-to-left associative.
The condition operator has the lowest priority.getLiteral ()
method extracts the string of a literal from parsed strings
and returns the value of the literal valid for the syntax.get... ()
following methods are called by the parser to get
the other elements that describes a syntax :
getWhiteSpaceCharacters ()
: returns a string that contains all the allowed white space
delimiters (tab, spaces,...).getOpeningBracket ()
: returns the char used as an opening bracket.getClosingBracket ()
: returns the char used as a closing bracket.getParameterSeparator ()
: returns the char used to separate parameters in a function call.getDelimiters ()
: returns all the chars of the syntax
(operators and above characters) that may be used as delimiters between literals, constants and identifiers.getAssignmentOperator ()
: returns a string used as the assignment
operator by the parsers FunctionParser
and ExpressionParser
.isCaseSensitive ()
: returns true
if identifiers, operators and functions
of the syntax are case sensitive.isShortSyntax ()
: returns true
if the syntax supports short cuts in expressions
(no need to put between brackets common functions parameters between brackets).isValidIdentifier ()
: returns true
if the string parameter
can be considered as a user function paramater or an expression parameter.getFunction ()
method is called by the parser to check if an extracted string
is a user function, that may be a previous parsed function or a Java written function implementing the Function
interface. This enables to chain calls with other functions.AbstractSyntax
class to help you implement
this interface. The classes PascalSyntax
or JavaSyntax
classes
can be used to parse PASCAL or Java expressions and functions.Interpreter
interface implements how to compute
all the litterals, operators or functions of the syntax.Integer
or any other type as long as its unique in its category
(constant, unary operator, binary operator or common function).
If you create an Integer
key, use a number greater or equal to
USER_STARTING_KEY
to avoid any problem.get...Key ()
method
of Syntax
that accepts it as an lexical element of the syntax.
If your syntax is a subclass of AbstractSyntax
, you may also use the
set...Key ()
method to add directly the new key and its matching string
to the syntax.get...Value ()
method of Interpreter
for the new key.FUNCTION_INVERSE
equal to
new Integer (USER_STARTING_KEY)
.FUNCTION_INVERSE
in your implementation of the
getCommonFunctionKey ()
method if its string parameter is equal to "INV".
If your syntax is a subclass of AbstractSyntax
, you can also call
setCommonFunctionKey ("INV", FUNCTION_INVERSE)
on the instance
of Syntax
.FUNCTION_INVERSE
in the
getCommonFunctionValue ()
method of Interpreter
.Interpreter
.com.eteks.tools.calculator.JeksCalculator
class implements the
Syntax
and Interpreter
interfaces in a way it uses uppercase strings for all its keys.Interpreter
interface.Function
interface and if it's returned by
the getFunction ()
method.
AbstractSyntax
,
Interpreter
,
Function
,
com.eteks.tools.calculator.JeksCalculator
Field Summary | |
static java.lang.Integer |
CONDITION_ELSE
Key returned by getConditionPartKey () for the else part of a condition. |
static java.lang.Integer |
CONDITION_IF
Key returned by getConditionPartKey () for the if part of a condition. |
static java.lang.Integer |
CONDITION_THEN
Key returned by getConditionPartKey () for the then part of a condition. |
static java.lang.Integer |
CONSTANT_E
Key returned by getConstantKey () for the constant number E (exp (1)). |
static java.lang.Integer |
CONSTANT_FALSE
Key returned by getConstantKey () for the constant false. |
static java.lang.Integer |
CONSTANT_PI
Key returned by getConstantKey () for the constant PI. |
static java.lang.Integer |
CONSTANT_TRUE
Key returned by getConstantKey () for the constant true. |
static java.lang.Integer |
FUNCTION_ABS
Key returned by getCommonFunctionKey () for the absolute value function. |
static java.lang.Integer |
FUNCTION_ACOS
Key returned by getCommonFunctionKey () for the arc cosine function. |
static java.lang.Integer |
FUNCTION_ASIN
Key returned by getCommonFunctionKey () for the arc sine function. |
static java.lang.Integer |
FUNCTION_ATAN
Key returned by getCommonFunctionKey () for the arc tangent function. |
static java.lang.Integer |
FUNCTION_CEIL
Key returned by getCommonFunctionKey () for the ceil value function. |
static java.lang.Integer |
FUNCTION_COS
Key returned by getCommonFunctionKey () for the cosine function. |
static java.lang.Integer |
FUNCTION_COSH
Key returned by getCommonFunctionKey () for the hyperbolic sine function. |
static java.lang.Integer |
FUNCTION_EXP
Key returned by getCommonFunctionKey () for the exponential function. |
static java.lang.Integer |
FUNCTION_FLOOR
Key returned by getCommonFunctionKey () for the floor value function. |
static java.lang.Integer |
FUNCTION_INTEGER
Key returned by getCommonFunctionKey () for the integer part function. |
static java.lang.Integer |
FUNCTION_LN
Key returned by getCommonFunctionKey () for the nepierian logarithm function. |
static java.lang.Integer |
FUNCTION_LOG
Key returned by getCommonFunctionKey () for the decimal logarithm function. |
static java.lang.Integer |
FUNCTION_NOT
Key returned by getCommonFunctionKey () for the not function. |
static java.lang.Integer |
FUNCTION_OPPOSITE
Key returned by getCommonFunctionKey () for the opposite function. |
static java.lang.Integer |
FUNCTION_ROUND
Key returned by getCommonFunctionKey () for the round value function. |
static java.lang.Integer |
FUNCTION_SIN
Key returned by getCommonFunctionKey () for the sine function. |
static java.lang.Integer |
FUNCTION_SINH
Key returned by getCommonFunctionKey () for the hyperbolic sine function. |
static java.lang.Integer |
FUNCTION_SQR
Key returned by getCommonFunctionKey () for the square function. |
static java.lang.Integer |
FUNCTION_SQRT
Key returned by getCommonFunctionKey () for the square root function. |
static java.lang.Integer |
FUNCTION_TAN
Key returned by getCommonFunctionKey () for the tangent function. |
static java.lang.Integer |
FUNCTION_TANH
Key returned by getCommonFunctionKey () for the hyperbolic tangent function. |
static java.lang.Integer |
OPERATOR_ADD
Key returned by getBinaryOperatorKey () for the add operator. |
static java.lang.Integer |
OPERATOR_BITWISE_AND
Key returned by getBinaryOperatorKey () for the bitwise and operator. |
static java.lang.Integer |
OPERATOR_BITWISE_NOT
Key returned by getUnaryOperatorKey () for the bitwise not operator. |
static java.lang.Integer |
OPERATOR_BITWISE_OR
Key returned by getBinaryOperatorKey () for the bitwise or operator. |
static java.lang.Integer |
OPERATOR_BITWISE_XOR
Key returned by getBinaryOperatorKey () for the bitwise xor operator. |
static java.lang.Integer |
OPERATOR_DIFFERENT
Key returned by getBinaryOperatorKey () for the different operator. |
static java.lang.Integer |
OPERATOR_DIVIDE
Key returned by getBinaryOperatorKey () for the divide operator. |
static java.lang.Integer |
OPERATOR_EQUAL
Key returned by getBinaryOperatorKey () for the equal operator. |
static java.lang.Integer |
OPERATOR_GREATER
Key returned by getBinaryOperatorKey () for the greater operator. |
static java.lang.Integer |
OPERATOR_GREATER_OR_EQUAL
Key returned by getBinaryOperatorKey () for the greater or equal operator. |
static java.lang.Integer |
OPERATOR_LESS
Key returned by getBinaryOperatorKey () for the less operator. |
static java.lang.Integer |
OPERATOR_LESS_OR_EQUAL
Key returned by getBinaryOperatorKey () for the less or equal operator. |
static java.lang.Integer |
OPERATOR_LOGICAL_AND
Key returned by getBinaryOperatorKey () for the logical and operator. |
static java.lang.Integer |
OPERATOR_LOGICAL_NOT
Key returned by getUnaryOperatorKey () for the logical not operator. |
static java.lang.Integer |
OPERATOR_LOGICAL_OR
Key returned by getBinaryOperatorKey () for the logical or operator. |
static java.lang.Integer |
OPERATOR_LOGICAL_XOR
Key returned by getBinaryOperatorKey () for the logical xor operator. |
static java.lang.Integer |
OPERATOR_MODULO
Key returned by getBinaryOperatorKey () for the modulo operator. |
static java.lang.Integer |
OPERATOR_MULTIPLY
Key returned by getBinaryOperatorKey () for the multiply operator. |
static java.lang.Integer |
OPERATOR_OPPOSITE
Key returned by getUnaryOperatorKey () for the opposite operator. |
static java.lang.Integer |
OPERATOR_POSITIVE
Key returned by getUnaryOperatorKey () for the positive operator. |
static java.lang.Integer |
OPERATOR_POWER
Key returned by getBinaryOperatorKey () for the power operator. |
static java.lang.Integer |
OPERATOR_REMAINDER
Key returned by getBinaryOperatorKey () for the remainder operator. |
static java.lang.Integer |
OPERATOR_SHIFT_LEFT
Key returned by getBinaryOperatorKey () for the shift left operator. |
static java.lang.Integer |
OPERATOR_SHIFT_RIGHT
Key returned by getBinaryOperatorKey () for the shift right operator. |
static java.lang.Integer |
OPERATOR_SHIFT_RIGHT_0
Key returned by getBinaryOperatorKey () for the shift right operator (Java operator >>>). |
static java.lang.Integer |
OPERATOR_SUBSTRACT
Key returned by getBinaryOperatorKey () for the substract operator. |
static int |
USER_STARTING_KEY
Key starting value for user keys. |
Method Summary | |
java.lang.String |
getAssignmentOperator()
Returns the string used as the operator of assignment by the parsers FunctionParser and ExpressionParser .
|
java.lang.Object |
getBinaryOperatorKey(java.lang.String binaryOperator)
Returns the key matching binaryOperator (one of OPERATOR_ADD ,
OPERATOR_SUBSTRACT , OPERATOR_MULTIPLY , OPERATOR_DIVIDE ,... or
an other user defined key). |
int |
getBinaryOperatorPriority(java.lang.Object binaryOperatorKey)
Returns the priority of the binary operator matching the key binaryOperatorKey . |
char |
getClosingBracket()
Returns the char used as the closing bracket of the syntax. |
java.lang.Object |
getCommonFunctionKey(java.lang.String commonFunction)
Returns the key matching commonFunction (one of FUNCTION_LN ,
FUNCTION_LOG , FUNCTION_EXP , FUNCTION_SQR ,... or
an other user defined key). |
int |
getConditionPartCount()
Returns 2 or 3 depending on whether the syntax using a condition with two or three parts (then else parts or if then else parts. |
java.lang.Object |
getConditionPartKey(java.lang.String conditionPart)
Returns the key matching conditionPart (one of CONDITION_IF ,
CONDITION_THEN , CONDITION_ELSE ). |
java.lang.Object |
getConstantKey(java.lang.String constant)
Returns the key matching constant (one of CONSTANT_PI ,
CONSTANT_E , CONSTANT_FALSE , CONSTANT_TRUE or
an other user defined key). |
java.lang.String |
getDelimiters()
Returns all the chars of the syntax that may be used as delimiters between literals, constants and other identifiers. |
Function |
getFunction(java.lang.String functionName)
Returns a reference to the instance of Function whose name is functionName .
|
java.lang.Object |
getLiteral(java.lang.String expression,
java.lang.StringBuffer extractedLiteral)
Returns the value of the literal parsed from the string expression
or null if expression doesn't start with a literal. |
char |
getOpeningBracket()
Returns the char used as the opening bracket of the syntax. |
char |
getParameterSeparator()
Returns the char used to separate parameters in a function call. |
java.lang.Object |
getUnaryOperatorKey(java.lang.String unaryOperator)
Returns the key matching unaryOperator (one of OPERATOR_POSITIVE ,
OPERATOR_OPPOSITE , OPERATOR_LOGICAL_NOT , OPERATOR_BITWISE_NOT or
an other user defined key). |
java.lang.String |
getWhiteSpaceCharacters()
Returns a string that contains all the delimiters allowed by the syntax as white spaces (tab, spaces,...). |
boolean |
isCaseSensitive()
Returns true if identifiers, constants, operators and function of the syntax
are case sensitive. |
boolean |
isShortSyntax()
Returns true if expressions parsed with this syntax supports short cuts.
|
boolean |
isValidIdentifier(java.lang.String identifier)
Returns true if the string identifier is a correctly written identifier
to be used as a user function name, a user function paramater name or an expression parameter.
|
Field Detail |
public static final java.lang.Integer CONSTANT_PI
getConstantKey ()
for the constant PI.public static final java.lang.Integer CONSTANT_E
getConstantKey ()
for the constant number E (exp (1)).public static final java.lang.Integer CONSTANT_FALSE
getConstantKey ()
for the constant false.public static final java.lang.Integer CONSTANT_TRUE
getConstantKey ()
for the constant true.public static final java.lang.Integer OPERATOR_POSITIVE
getUnaryOperatorKey ()
for the positive operator.public static final java.lang.Integer OPERATOR_OPPOSITE
getUnaryOperatorKey ()
for the opposite operator.public static final java.lang.Integer OPERATOR_LOGICAL_NOT
getUnaryOperatorKey ()
for the logical not operator.public static final java.lang.Integer OPERATOR_BITWISE_NOT
getUnaryOperatorKey ()
for the bitwise not operator.public static final java.lang.Integer OPERATOR_ADD
getBinaryOperatorKey ()
for the add operator.public static final java.lang.Integer OPERATOR_SUBSTRACT
getBinaryOperatorKey ()
for the substract operator.public static final java.lang.Integer OPERATOR_MULTIPLY
getBinaryOperatorKey ()
for the multiply operator.public static final java.lang.Integer OPERATOR_DIVIDE
getBinaryOperatorKey ()
for the divide operator.public static final java.lang.Integer OPERATOR_POWER
getBinaryOperatorKey ()
for the power operator.public static final java.lang.Integer OPERATOR_MODULO
getBinaryOperatorKey ()
for the modulo operator.public static final java.lang.Integer OPERATOR_REMAINDER
getBinaryOperatorKey ()
for the remainder operator.public static final java.lang.Integer OPERATOR_EQUAL
getBinaryOperatorKey ()
for the equal operator.public static final java.lang.Integer OPERATOR_DIFFERENT
getBinaryOperatorKey ()
for the different operator.public static final java.lang.Integer OPERATOR_GREATER_OR_EQUAL
getBinaryOperatorKey ()
for the greater or equal operator.public static final java.lang.Integer OPERATOR_LESS_OR_EQUAL
getBinaryOperatorKey ()
for the less or equal operator.public static final java.lang.Integer OPERATOR_GREATER
getBinaryOperatorKey ()
for the greater operator.public static final java.lang.Integer OPERATOR_LESS
getBinaryOperatorKey ()
for the less operator.public static final java.lang.Integer OPERATOR_LOGICAL_OR
getBinaryOperatorKey ()
for the logical or operator.public static final java.lang.Integer OPERATOR_LOGICAL_AND
getBinaryOperatorKey ()
for the logical and operator.public static final java.lang.Integer OPERATOR_LOGICAL_XOR
getBinaryOperatorKey ()
for the logical xor operator.public static final java.lang.Integer OPERATOR_BITWISE_OR
getBinaryOperatorKey ()
for the bitwise or operator.public static final java.lang.Integer OPERATOR_BITWISE_XOR
getBinaryOperatorKey ()
for the bitwise xor operator.public static final java.lang.Integer OPERATOR_BITWISE_AND
getBinaryOperatorKey ()
for the bitwise and operator.public static final java.lang.Integer OPERATOR_SHIFT_LEFT
getBinaryOperatorKey ()
for the shift left operator.public static final java.lang.Integer OPERATOR_SHIFT_RIGHT
getBinaryOperatorKey ()
for the shift right operator.public static final java.lang.Integer OPERATOR_SHIFT_RIGHT_0
getBinaryOperatorKey ()
for the shift right operator (Java operator >>>).public static final java.lang.Integer CONDITION_IF
getConditionPartKey ()
for the if part of a condition. If the
syntax uses a condition with only two parts for the then and
else parts of the condition (like the operator ? : in Java), the getConditionPartCount ()
method returns 2.public static final java.lang.Integer CONDITION_THEN
getConditionPartKey ()
for the then part of a condition.public static final java.lang.Integer CONDITION_ELSE
getConditionPartKey ()
for the else part of a condition.public static final java.lang.Integer FUNCTION_LN
getCommonFunctionKey ()
for the nepierian logarithm function.public static final java.lang.Integer FUNCTION_LOG
getCommonFunctionKey ()
for the decimal logarithm function.public static final java.lang.Integer FUNCTION_EXP
getCommonFunctionKey ()
for the exponential function.public static final java.lang.Integer FUNCTION_SQR
getCommonFunctionKey ()
for the square function.public static final java.lang.Integer FUNCTION_SQRT
getCommonFunctionKey ()
for the square root function.public static final java.lang.Integer FUNCTION_COS
getCommonFunctionKey ()
for the cosine function.public static final java.lang.Integer FUNCTION_SIN
getCommonFunctionKey ()
for the sine function.public static final java.lang.Integer FUNCTION_TAN
getCommonFunctionKey ()
for the tangent function.public static final java.lang.Integer FUNCTION_ACOS
getCommonFunctionKey ()
for the arc cosine function.public static final java.lang.Integer FUNCTION_ASIN
getCommonFunctionKey ()
for the arc sine function.public static final java.lang.Integer FUNCTION_ATAN
getCommonFunctionKey ()
for the arc tangent function.public static final java.lang.Integer FUNCTION_COSH
getCommonFunctionKey ()
for the hyperbolic sine function.public static final java.lang.Integer FUNCTION_SINH
getCommonFunctionKey ()
for the hyperbolic sine function.public static final java.lang.Integer FUNCTION_TANH
getCommonFunctionKey ()
for the hyperbolic tangent function.public static final java.lang.Integer FUNCTION_INTEGER
getCommonFunctionKey ()
for the integer part function.public static final java.lang.Integer FUNCTION_FLOOR
getCommonFunctionKey ()
for the floor value function.public static final java.lang.Integer FUNCTION_CEIL
getCommonFunctionKey ()
for the ceil value function.public static final java.lang.Integer FUNCTION_ROUND
getCommonFunctionKey ()
for the round value function.public static final java.lang.Integer FUNCTION_ABS
getCommonFunctionKey ()
for the absolute value function.public static final java.lang.Integer FUNCTION_OPPOSITE
getCommonFunctionKey ()
for the opposite function.public static final java.lang.Integer FUNCTION_NOT
getCommonFunctionKey ()
for the not function.public static final int USER_STARTING_KEY
Method Detail |
public java.lang.Object getLiteral(java.lang.String expression, java.lang.StringBuffer extractedLiteral)
expression
or null
if expression
doesn't start with a literal. If a
literal is found at the beginning of expression
, this method extracts
the parsed literal in the string buffer extractedLiteral
.
The extracted literal is any literal valid for the syntax, a number, a string or other kind
of literal value. The getLiteralValue ()
method of Interpreter
must be implemented to return the value matching the value returned by this method that
the interpreter accepts to use.expression
- the string to parse.extractedLiteral
- the literal extracted from expression
identified
as a valid literal with the syntax of the parser. This string buffer
is emptied before the call of this method by the parser.null
if expression
doesn't start with a literal valid for the syntax. If the literal is a number,
an instance of Number
should be returned, if the literal is a string
an instance of String
should be returned. Otherwise the returned value
may be of any class, as long as the methods of the used interpreter at runtime is able
to use them.public java.lang.Object getConstantKey(java.lang.String constant)
constant
(one of CONSTANT_PI
,
CONSTANT_E
, CONSTANT_FALSE
, CONSTANT_TRUE
or
an other user defined key). The getLiteralValue ()
method of Interpreter
must be implemented to return a value for this key (for example getLiteralValue ()
can return the object new Double (Math.PI)
for a key equal to CONSTANT_PI
).CalculatorParser
parser.constant
- the string to test. Numeric and string literals are not checked by this method.null
if constant
isn't a constant of the syntax.Interpreter
,
AbstractSyntax.setConstantKey(java.lang.String, java.lang.Object)
public java.lang.Object getUnaryOperatorKey(java.lang.String unaryOperator)
unaryOperator
(one of OPERATOR_POSITIVE
,
OPERATOR_OPPOSITE
, OPERATOR_LOGICAL_NOT
, OPERATOR_BITWISE_NOT
or
an other user defined key). The getUnaryOperatorValue ()
method of Interpreter
must be implemented to compute the operator of this key (for example getUnaryOperatorValue ()
can compute the opposite operation of its parameter for a key equal to OPERATOR_OPPOSITE
).getUnaryOperatorKey ()
and getBinaryOperatorKey ()
may support
some synonymous operators (as the operators - or +). The parser manages to guess
whether a synonymous operator is an unary or a binary operator according to the context.unaryOperator
- the string to test.null
if unaryOperator
isn't a unary operator the syntax.Interpreter
,
AbstractSyntax.setUnaryOperatorKey(java.lang.String, java.lang.Object)
public java.lang.Object getBinaryOperatorKey(java.lang.String binaryOperator)
binaryOperator
(one of OPERATOR_ADD
,
OPERATOR_SUBSTRACT
, OPERATOR_MULTIPLY
, OPERATOR_DIVIDE
,... or
an other user defined key). The getBinaryOperatorValue ()
method of Interpreter
must be implemented to compute the operator of this key (for example getBinaryOperatorValue ()
can compute the addition of its parameters for a key equal to OPERATOR_ADD
).getUnaryOperatorKey ()
and getBinaryOperatorKey ()
may support
some synonymous operators (as the operators - or +). The parser manages to guess
whether a synonymous operator is an unary or a binary operator according to the context.binaryOperator
- the string to test.null
if binaryOperator
isn't a binary operator of the syntax.Interpreter
,
AbstractSyntax.setBinaryOperatorKey(java.lang.String, java.lang.Object)
public java.lang.Object getConditionPartKey(java.lang.String conditionPart)
conditionPart
(one of CONDITION_IF
,
CONDITION_THEN
, CONDITION_ELSE
). The getConditionValue ()
method
of Interpreter
must be implemented to return the good value if a condition is true
or false.CalculatorParser
parser.conditionPart
- the string to test.null
if conditionPart
isn't a conditional part of the syntax or if no condition is supported by the syntax.Interpreter
,
AbstractSyntax.setConditionPartKey(java.lang.String, java.lang.Object)
public int getConditionPartCount()
CalculatorParser
parser.public java.lang.Object getCommonFunctionKey(java.lang.String commonFunction)
commonFunction
(one of FUNCTION_LN
,
FUNCTION_LOG
, FUNCTION_EXP
, FUNCTION_SQR
,... or
an other user defined key). The getCommonFunctionValue ()
method of Interpreter
must be implemented to compute the function of this key (for example getCommonFunctionValue ()
can compute the nepierian logarithm of its parameter for a key equal to FUNCTION_LN
).
Common functions have only one parameter and may be called with no brackets
around their parameter if isShortSyntax ()
returns true
.commonFunction
- the string to test.null
if commonFunction
isn't a common function of the syntax.Interpreter
,
AbstractSyntax.setCommonFunctionKey(java.lang.String, java.lang.Object)
public Function getFunction(java.lang.String functionName)
Function
whose name is functionName
.
This enables to call in an other function a previously parsed function or a function
implementing the Function
interface.
The getFunctionValue ()
method of Interpreter
must be implemented to compute the returned function.CalculatorParser
parser.functionName
- the string to test.Function
reference or null
if functionName
isn't a function of the syntax.Function
,
Interpreter
,
AbstractSyntax.addFunction(com.eteks.parser.Function)
public int getBinaryOperatorPriority(java.lang.Object binaryOperatorKey)
binaryOperatorKey
. Two
operators may have the same priority. A greater value is returned for an operator with higher priority.binaryOperatorKey
- a binary operator key (one of OPERATOR_ADD
,
OPERATOR_SUBSTRACT
, OPERATOR_MULTIPLY
,
OPERATOR_DIVIDE
,... or an other user defined key).binaryOperatorKey
.AbstractSyntax.setBinaryOperatorPriority(java.lang.Object, int)
public java.lang.String getWhiteSpaceCharacters()
null
.AbstractSyntax.setWhiteSpaceCharacters(java.lang.String)
public char getOpeningBracket()
AbstractSyntax.setOpeningBracket(char)
public char getClosingBracket()
AbstractSyntax.setClosingBracket(char)
public char getParameterSeparator()
CalculatorParser
parser.AbstractSyntax.setParameterSeparator(char)
public java.lang.String getDelimiters()
getWhiteSpaceCharacters ()
and
generally contains the opening and closing brackets, the separator of parameters and the
characters of operators, that are not part of literals, constants and identifiers.
The AbstractSyntax
class computes automatically this string.AbstractSyntax.getDelimiters()
public java.lang.String getAssignmentOperator()
FunctionParser
and ExpressionParser
.
=
in the string
f(x) = x + 1
; FunctionParser
requires a valid
assignment operator to parse a function.ExpressionParser
, it's the string
at the beginning of the expression like the char =
in the string
= A1 + 1
, if this string isn't null
.CalculatorParser
parser.FunctionParser
,
AbstractSyntax.setAssignmentOperator(java.lang.String)
public boolean isCaseSensitive()
true
if identifiers, constants, operators and function of the syntax
are case sensitive. Note that this method is used by the parser only for tests comparing
the name of functions and parameters. getConstantKey ()
,
getUnaryOperatorKey ()
, getBinaryOperatorKey ()
,
getConditionPartKey ()
and getCommonFunctionKey ()
methods must perform
the good test of comparison depending on whether the syntax being case sensitive or not.CalculatorParser
parser.true
if the syntax is case sensitive.AbstractSyntax.AbstractSyntax()
public boolean isShortSyntax()
true
if expressions parsed with this syntax supports short cuts.
false
, the syntax is the one generally used in
data processing, i.e. every multiply operator is written and
the parameters of common functions are always between brackets
(for example f(x) = 2*sin(x) + 3*x
).true
, the syntax supports also the mathematical
syntax, i.e. multiply operator and brackets around the parameters of common
functions may be omitted. If a literal number is directly followed by an
identifier, a function or an expression between brackets without
any white space character, an implicit multiplication will be performed (for example :
f(x) = 2x
or f(x) = 5.2E-2(ln x + 3)
).
More generally, a multiplication is applied to two operands if they are separated
by one or more white space characters (for example : f(x,y) = x y ou f(x) = x ln x
).f(x) = log(2x)
is different of f(x) = log 2x
.f(x) = sqr log -x
which is the same as f(x) = sqr (log (-x))
.
Note than these short cuts are allowed only for common functions, not
for user functions even if they require only one parameter.CalculatorParser
class.true
if the syntax supports short cuts.AbstractSyntax.setShortSyntax(boolean)
public boolean isValidIdentifier(java.lang.String identifier)
true
if the string identifier
is a correctly written identifier
to be used as a user function name, a user function paramater name or an expression parameter.
identifier
may contain special characters as : or . if these
characters are not used as delimiters.CalculatorParser
parser.identifier
- the string to test.true
if identifier
is correct.
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |