http://www.eteks.com

com.eteks.parser
Interface Syntax

All Known Implementing Classes:
AbstractSyntax

public interface Syntax

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 :

The 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.
The getLiteral () method extracts the string of a literal from parsed strings and returns the value of the literal valid for the syntax.
The other get... () following methods are called by the parser to get the other elements that describes a syntax : Finally, the 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.
Note that these methods simply returns 0 or null if a string or an element isn't accepted by the syntax. You can use the 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.
The classes implementing the Interpreter interface implements how to compute all the litterals, operators or functions of the syntax.
You can add a new litteral, operator or function in your syntax if you respect the following steps : For example, imagine you want to add a common function "INV" in the syntax that computes the inverse of a number (1 / x). One solution could be : You should notice that the key is only used by the parser and the interpreter to link the recognized element by the syntax at parsing time to its computation code at interpretation time. This allows to interpret the same parsed expression or function with different implementations of Interpreter.
For example, the com.eteks.tools.calculator.JeksCalculator class implements the Syntax and Interpreter interfaces in a way it uses uppercase strings for all its keys.
Caution : The operators or functions syntax doesn't specify the type of the operands or the parameters. The type is checked at runtime by the class that implements the Interpreter interface.
It's possible also to add a new function with any number of parameters to the syntax, if this function implements the Function interface and if it's returned by the getFunction () method.

Since:
Jeks 1.0
Version:
1.0
Author:
Emmanuel Puybaret
See Also:
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

CONSTANT_PI

public static final java.lang.Integer CONSTANT_PI
Key returned by getConstantKey () for the constant PI.

CONSTANT_E

public static final java.lang.Integer CONSTANT_E
Key returned by getConstantKey () for the constant number E (exp (1)).

CONSTANT_FALSE

public static final java.lang.Integer CONSTANT_FALSE
Key returned by getConstantKey () for the constant false.

CONSTANT_TRUE

public static final java.lang.Integer CONSTANT_TRUE
Key returned by getConstantKey () for the constant true.

OPERATOR_POSITIVE

public static final java.lang.Integer OPERATOR_POSITIVE
Key returned by getUnaryOperatorKey () for the positive operator.

OPERATOR_OPPOSITE

public static final java.lang.Integer OPERATOR_OPPOSITE
Key returned by getUnaryOperatorKey () for the opposite operator.

OPERATOR_LOGICAL_NOT

public static final java.lang.Integer OPERATOR_LOGICAL_NOT
Key returned by getUnaryOperatorKey () for the logical not operator.

OPERATOR_BITWISE_NOT

public static final java.lang.Integer OPERATOR_BITWISE_NOT
Key returned by getUnaryOperatorKey () for the bitwise not operator.

OPERATOR_ADD

public static final java.lang.Integer OPERATOR_ADD
Key returned by getBinaryOperatorKey () for the add operator.

OPERATOR_SUBSTRACT

public static final java.lang.Integer OPERATOR_SUBSTRACT
Key returned by getBinaryOperatorKey () for the substract operator.

OPERATOR_MULTIPLY

public static final java.lang.Integer OPERATOR_MULTIPLY
Key returned by getBinaryOperatorKey () for the multiply operator.

OPERATOR_DIVIDE

public static final java.lang.Integer OPERATOR_DIVIDE
Key returned by getBinaryOperatorKey () for the divide operator.

OPERATOR_POWER

public static final java.lang.Integer OPERATOR_POWER
Key returned by getBinaryOperatorKey () for the power operator.

OPERATOR_MODULO

public static final java.lang.Integer OPERATOR_MODULO
Key returned by getBinaryOperatorKey () for the modulo operator.

OPERATOR_REMAINDER

public static final java.lang.Integer OPERATOR_REMAINDER
Key returned by getBinaryOperatorKey () for the remainder operator.

OPERATOR_EQUAL

public static final java.lang.Integer OPERATOR_EQUAL
Key returned by getBinaryOperatorKey () for the equal operator.

OPERATOR_DIFFERENT

public static final java.lang.Integer OPERATOR_DIFFERENT
Key returned by getBinaryOperatorKey () for the different operator.

OPERATOR_GREATER_OR_EQUAL

public static final java.lang.Integer OPERATOR_GREATER_OR_EQUAL
Key returned by getBinaryOperatorKey () for the greater or equal operator.

OPERATOR_LESS_OR_EQUAL

public static final java.lang.Integer OPERATOR_LESS_OR_EQUAL
Key returned by getBinaryOperatorKey () for the less or equal operator.

OPERATOR_GREATER

public static final java.lang.Integer OPERATOR_GREATER
Key returned by getBinaryOperatorKey () for the greater operator.

OPERATOR_LESS

public static final java.lang.Integer OPERATOR_LESS
Key returned by getBinaryOperatorKey () for the less operator.

OPERATOR_LOGICAL_OR

public static final java.lang.Integer OPERATOR_LOGICAL_OR
Key returned by getBinaryOperatorKey () for the logical or operator.

OPERATOR_LOGICAL_AND

public static final java.lang.Integer OPERATOR_LOGICAL_AND
Key returned by getBinaryOperatorKey () for the logical and operator.

OPERATOR_LOGICAL_XOR

public static final java.lang.Integer OPERATOR_LOGICAL_XOR
Key returned by getBinaryOperatorKey () for the logical xor operator.

OPERATOR_BITWISE_OR

public static final java.lang.Integer OPERATOR_BITWISE_OR
Key returned by getBinaryOperatorKey () for the bitwise or operator.

OPERATOR_BITWISE_XOR

public static final java.lang.Integer OPERATOR_BITWISE_XOR
Key returned by getBinaryOperatorKey () for the bitwise xor operator.

OPERATOR_BITWISE_AND

public static final java.lang.Integer OPERATOR_BITWISE_AND
Key returned by getBinaryOperatorKey () for the bitwise and operator.

OPERATOR_SHIFT_LEFT

public static final java.lang.Integer OPERATOR_SHIFT_LEFT
Key returned by getBinaryOperatorKey () for the shift left operator.

OPERATOR_SHIFT_RIGHT

public static final java.lang.Integer OPERATOR_SHIFT_RIGHT
Key returned by getBinaryOperatorKey () for the shift right operator.

OPERATOR_SHIFT_RIGHT_0

public static final java.lang.Integer OPERATOR_SHIFT_RIGHT_0
Key returned by getBinaryOperatorKey () for the shift right operator (Java operator >>>).

CONDITION_IF

public static final java.lang.Integer CONDITION_IF
Key returned by 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.

CONDITION_THEN

public static final java.lang.Integer CONDITION_THEN
Key returned by getConditionPartKey () for the then part of a condition.

CONDITION_ELSE

public static final java.lang.Integer CONDITION_ELSE
Key returned by getConditionPartKey () for the else part of a condition.

FUNCTION_LN

public static final java.lang.Integer FUNCTION_LN
Key returned by getCommonFunctionKey () for the nepierian logarithm function.

FUNCTION_LOG

public static final java.lang.Integer FUNCTION_LOG
Key returned by getCommonFunctionKey () for the decimal logarithm function.

FUNCTION_EXP

public static final java.lang.Integer FUNCTION_EXP
Key returned by getCommonFunctionKey () for the exponential function.

FUNCTION_SQR

public static final java.lang.Integer FUNCTION_SQR
Key returned by getCommonFunctionKey () for the square function.

FUNCTION_SQRT

public static final java.lang.Integer FUNCTION_SQRT
Key returned by getCommonFunctionKey () for the square root function.

FUNCTION_COS

public static final java.lang.Integer FUNCTION_COS
Key returned by getCommonFunctionKey () for the cosine function.

FUNCTION_SIN

public static final java.lang.Integer FUNCTION_SIN
Key returned by getCommonFunctionKey () for the sine function.

FUNCTION_TAN

public static final java.lang.Integer FUNCTION_TAN
Key returned by getCommonFunctionKey () for the tangent function.

FUNCTION_ACOS

public static final java.lang.Integer FUNCTION_ACOS
Key returned by getCommonFunctionKey () for the arc cosine function.

FUNCTION_ASIN

public static final java.lang.Integer FUNCTION_ASIN
Key returned by getCommonFunctionKey () for the arc sine function.

FUNCTION_ATAN

public static final java.lang.Integer FUNCTION_ATAN
Key returned by getCommonFunctionKey () for the arc tangent function.

FUNCTION_COSH

public static final java.lang.Integer FUNCTION_COSH
Key returned by getCommonFunctionKey () for the hyperbolic sine function.

FUNCTION_SINH

public static final java.lang.Integer FUNCTION_SINH
Key returned by getCommonFunctionKey () for the hyperbolic sine function.

FUNCTION_TANH

public static final java.lang.Integer FUNCTION_TANH
Key returned by getCommonFunctionKey () for the hyperbolic tangent function.

FUNCTION_INTEGER

public static final java.lang.Integer FUNCTION_INTEGER
Key returned by getCommonFunctionKey () for the integer part function.

FUNCTION_FLOOR

public static final java.lang.Integer FUNCTION_FLOOR
Key returned by getCommonFunctionKey () for the floor value function.

FUNCTION_CEIL

public static final java.lang.Integer FUNCTION_CEIL
Key returned by getCommonFunctionKey () for the ceil value function.

FUNCTION_ROUND

public static final java.lang.Integer FUNCTION_ROUND
Key returned by getCommonFunctionKey () for the round value function.

FUNCTION_ABS

public static final java.lang.Integer FUNCTION_ABS
Key returned by getCommonFunctionKey () for the absolute value function.

FUNCTION_OPPOSITE

public static final java.lang.Integer FUNCTION_OPPOSITE
Key returned by getCommonFunctionKey () for the opposite function.

FUNCTION_NOT

public static final java.lang.Integer FUNCTION_NOT
Key returned by getCommonFunctionKey () for the not function.

USER_STARTING_KEY

public static final int USER_STARTING_KEY
Key starting value for user keys.
Method Detail

getLiteral

public 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. 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.
Parameters:
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.
Returns:
the value of the extracted literal or 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.

getConstantKey

public 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). 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).
This method is not used by CalculatorParser parser.
Parameters:
constant - the string to test. Numeric and string literals are not checked by this method.
Returns:
the key matching the constant string or null if constant isn't a constant of the syntax.
See Also:
Interpreter, AbstractSyntax.setConstantKey(java.lang.String, java.lang.Object)

getUnaryOperatorKey

public 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). 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.
Parameters:
unaryOperator - the string to test.
Returns:
the key matching the unary operator or null if unaryOperator isn't a unary operator the syntax.
See Also:
Interpreter, AbstractSyntax.setUnaryOperatorKey(java.lang.String, java.lang.Object)

getBinaryOperatorKey

public 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). 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.
Parameters:
binaryOperator - the string to test.
Returns:
the key matching the binary operator or null if binaryOperator isn't a binary operator of the syntax.
See Also:
Interpreter, AbstractSyntax.setBinaryOperatorKey(java.lang.String, java.lang.Object)

getConditionPartKey

public java.lang.Object getConditionPartKey(java.lang.String conditionPart)
Returns the key matching 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.
This method is not used by CalculatorParser parser.
Parameters:
conditionPart - the string to test.
Returns:
the key matching the conditional part or null if conditionPart isn't a conditional part of the syntax or if no condition is supported by the syntax.
See Also:
Interpreter, AbstractSyntax.setConditionPartKey(java.lang.String, java.lang.Object)

getConditionPartCount

public 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.
This method is not used by CalculatorParser parser.
Returns:
2 or 3.

getCommonFunctionKey

public 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). 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.
Parameters:
commonFunction - the string to test.
Returns:
the key matching the common function or null if commonFunction isn't a common function of the syntax.
See Also:
Interpreter, AbstractSyntax.setCommonFunctionKey(java.lang.String, java.lang.Object)

getFunction

public Function getFunction(java.lang.String functionName)
Returns a reference to the instance of 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.
This method is not used by CalculatorParser parser.
Parameters:
functionName - the string to test.
Returns:
a Function reference or null if functionName isn't a function of the syntax.
See Also:
Function, Interpreter, AbstractSyntax.addFunction(com.eteks.parser.Function)

getBinaryOperatorPriority

public int getBinaryOperatorPriority(java.lang.Object binaryOperatorKey)
Returns the priority of the binary operator matching the key binaryOperatorKey. Two operators may have the same priority. A greater value is returned for an operator with higher priority.
Parameters:
binaryOperatorKey - a binary operator key (one of OPERATOR_ADD, OPERATOR_SUBSTRACT, OPERATOR_MULTIPLY, OPERATOR_DIVIDE,... or an other user defined key).
Returns:
a positive value equal to the priority of binaryOperatorKey.
See Also:
AbstractSyntax.setBinaryOperatorPriority(java.lang.Object, int)

getWhiteSpaceCharacters

public java.lang.String getWhiteSpaceCharacters()
Returns a string that contains all the delimiters allowed by the syntax as white spaces (tab, spaces,...).
Returns:
A string containing a set of white spaces or null.
See Also:
AbstractSyntax.setWhiteSpaceCharacters(java.lang.String)

getOpeningBracket

public char getOpeningBracket()
Returns the char used as the opening bracket of the syntax. Brackets are use to brackets expressions and to pass parameters to a function.
Returns:
the opening bracket char or 0 if no brackets are used.
See Also:
AbstractSyntax.setOpeningBracket(char)

getClosingBracket

public char getClosingBracket()
Returns the char used as the closing bracket of the syntax. Brackets are use to brackets expressions and to pass parameters to a function.
Returns:
the closing bracket char or 0 if no brackets are used.
See Also:
AbstractSyntax.setClosingBracket(char)

getParameterSeparator

public char getParameterSeparator()
Returns the char used to separate parameters in a function call.
This method is not used by CalculatorParser parser.
Returns:
the separator of parameters or 0 if no multi parameters function calls are allowed by the syntax.
See Also:
AbstractSyntax.setParameterSeparator(char)

getDelimiters

public java.lang.String getDelimiters()
Returns all the chars of the syntax that may be used as delimiters between literals, constants and other identifiers. This string must contain at least the delimiters returned by 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.
Returns:
a string containing the set of delimiters of the syntax.
See Also:
AbstractSyntax.getDelimiters()

getAssignmentOperator

public java.lang.String getAssignmentOperator()
Returns the string used as the operator of assignment by the parsers FunctionParser and ExpressionParser. This method is not used by CalculatorParser parser.
Returns:
the operator of assignment.
See Also:
FunctionParser, AbstractSyntax.setAssignmentOperator(java.lang.String)

isCaseSensitive

public boolean isCaseSensitive()
Returns 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.
This method is not used by CalculatorParser parser.
Returns:
true if the syntax is case sensitive.
See Also:
AbstractSyntax.AbstractSyntax()

isShortSyntax

public boolean isShortSyntax()
Returns true if expressions parsed with this syntax supports short cuts.
Returns:
true if the syntax supports short cuts.
See Also:
AbstractSyntax.setShortSyntax(boolean)

isValidIdentifier

public 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. identifier may contain special characters as : or . if these characters are not used as delimiters.
This method is not used by CalculatorParser parser.
Parameters:
identifier - the string to test.
Returns:
true if identifier is correct.

&cp; 1998-2003 eTeks - All rights reserved