http://www.eteks.com

com.eteks.parser
Class DefaultSyntax

java.lang.Object
  |
  +--com.eteks.parser.AbstractSyntax
        |
        +--com.eteks.parser.DefaultSyntax
All Implemented Interfaces:
Syntax
Direct Known Subclasses:
PascalSyntax

public class DefaultSyntax
extends AbstractSyntax

Default syntax used by parsers for functions and expressions. This syntax supports the following operators, constants and functions :

The literals may be any decimal or integer number. The operator for assignment is =, brackets ( ) and the separator of parameters ,.
The parsed identifiers (name of a function and its parameters) may contain letters, digits, or the character _. The first character can't be a digit.
This syntax isn't case sensitive. A DefaultSyntax object may be modified with the methods of AbstractSyntax.

Since:
Jeks 1.0
Version:
1.0
Author:
Emmanuel Puybaret

Fields inherited from interface com.eteks.parser.Syntax
CONDITION_ELSE, CONDITION_IF, CONDITION_THEN, CONSTANT_E, CONSTANT_FALSE, CONSTANT_PI, CONSTANT_TRUE, FUNCTION_ABS, FUNCTION_ACOS, FUNCTION_ASIN, FUNCTION_ATAN, FUNCTION_CEIL, FUNCTION_COS, FUNCTION_COSH, FUNCTION_EXP, FUNCTION_FLOOR, FUNCTION_INTEGER, FUNCTION_LN, FUNCTION_LOG, FUNCTION_NOT, FUNCTION_OPPOSITE, FUNCTION_ROUND, FUNCTION_SIN, FUNCTION_SINH, FUNCTION_SQR, FUNCTION_SQRT, FUNCTION_TAN, FUNCTION_TANH, OPERATOR_ADD, OPERATOR_BITWISE_AND, OPERATOR_BITWISE_NOT, OPERATOR_BITWISE_OR, OPERATOR_BITWISE_XOR, OPERATOR_DIFFERENT, OPERATOR_DIVIDE, OPERATOR_EQUAL, OPERATOR_GREATER, OPERATOR_GREATER_OR_EQUAL, OPERATOR_LESS, OPERATOR_LESS_OR_EQUAL, OPERATOR_LOGICAL_AND, OPERATOR_LOGICAL_NOT, OPERATOR_LOGICAL_OR, OPERATOR_LOGICAL_XOR, OPERATOR_MODULO, OPERATOR_MULTIPLY, OPERATOR_OPPOSITE, OPERATOR_POSITIVE, OPERATOR_POWER, OPERATOR_REMAINDER, OPERATOR_SHIFT_LEFT, OPERATOR_SHIFT_RIGHT, OPERATOR_SHIFT_RIGHT_0, OPERATOR_SUBSTRACT, USER_STARTING_KEY
 
Constructor Summary
DefaultSyntax()
          Creates a default syntax.
 
Method Summary
 java.lang.Object getLiteral(java.lang.String expression, java.lang.StringBuffer extractedLiteral)
          Returns the value of the number parsed from the string expression or null if expression doesn't start with a number.
 boolean isDigit(char character)
          Returns true if character is a digit.
 boolean isLetter(char character)
          Returns true if character is a letter.
 boolean isValidIdentifier(java.lang.String identifier)
          Returns true if identifier is a correct name of function or parameter.
 
Methods inherited from class com.eteks.parser.AbstractSyntax
addFunction, getAssignmentOperator, getBinaryOperatorKey, getBinaryOperatorPriority, getClosingBracket, getCommonFunctionKey, getConditionPartCount, getConditionPartKey, getConstantKey, getDelimiters, getFunction, getOpeningBracket, getParameterSeparator, getUnaryOperatorKey, getWhiteSpaceCharacters, isCaseSensitive, isShortSyntax, removeFunction, setAssignmentOperator, setBinaryOperatorKey, setBinaryOperatorPriority, setClosingBracket, setCommonFunctionKey, setConditionPartKey, setConstantKey, setOpeningBracket, setParameterSeparator, setShortSyntax, setUnaryOperatorKey, setWhiteSpaceCharacters
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSyntax

public DefaultSyntax()
Creates a default syntax.
Method Detail

getLiteral

public java.lang.Object getLiteral(java.lang.String expression,
                                   java.lang.StringBuffer extractedLiteral)
Returns the value of the number parsed from the string expression or null if expression doesn't start with a number. If a number is found at the beginning of expression, this method extracts it in the string buffer extractedLiteral.
Parameters:
expression - the string to parse.
extractedLiteral - the literal extracted from expression identified as a valid number with the getLiteralNumber () method of the AbstractSyntax class. This string buffer is emptied before the call of this method by the parser.
Returns:
the value of the extracted number or null if expression doesn't start with a number.
See Also:
com.eteks.parser.AbstractSyntax#getLiteralNumber

isValidIdentifier

public boolean isValidIdentifier(java.lang.String identifier)
Returns true if identifier is a correct name of function or parameter. identifier may contain letters, digits, or the character _. Its first character can't be a digit.
Parameters:
identifier - the string to test.
Returns:
true if identifier is a correct identifier.

isLetter

public boolean isLetter(char character)
Returns true if character is a letter. By default letters are limited to ASCII letters (a to z or A to Z). Override this method to have a syntax with a richer set of letters.
Parameters:
character - a char to test.
Returns:
true if character is an ASCII letter (a to z or A to Z).

isDigit

public boolean isDigit(char character)
Returns true if character is a digit. By default digits are limited to ASCII digits (1 to 9). Override this method to have a syntax with a richer set of digits.
Parameters:
character - a char to test.
Returns:
true if character is an ASCII digit (1 to 9).

&cp; 1998-2003 eTeks - All rights reserved