public class DefaultXMLGrammar extends Object implements Grammar
| Modifier and Type | Field and Description |
|---|---|
static String |
ALLOWED_PATTERN
This is the constant name for allowed pattern tag in XML
|
static String |
APPROACHABLE_PATTERN
This is the constant name for approachable pattern tag in XML
|
static String |
BRACKET
This is the constant name for bracket tag in XML
|
static String |
BRACKETS
This is the constant name for brackets tag in XML
|
static String |
DELIMITER
This is the constant name for delimiter tag in XML
|
static String |
DELIMITERS
This is the constant name for delimiters tag in XML
|
String |
FILE_PATH
File path for grammar configuration.
|
static String |
FUNCTIONS
This is the constant name for functions tag in XML
|
static String |
IGNORE_BLANK
This is the constant name for ignore blank tag in XML
|
static String |
LEFT
This is the constant name for left tag in XML
|
static String |
NAME
This is the constant name for name tag in XML
|
static String |
OPERATOR
This is the constant name for operator tag in XML
|
static String |
PRECEDENCE
This is the constant name for precedence tag in XML
|
static String |
PRODUCTION_RULE
This is the constant name for production rule tag in XML
|
static String |
PRODUCTION_RULES
This is the constant name for production rules tag in XML
|
static String |
RIGHT
This is the constant name for right tag in XML
|
static String |
TRUE
This is the constant name for true tag in XML
|
static String |
UNARY_OPERATORS
This is the constant name for unary operators tag in XML
|
| Constructor and Description |
|---|
DefaultXMLGrammar()
Constructs the grammar
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFunction(String functionName)
Adds a function name to the grammar.
|
String |
getOppositeBracket(String bracket)
Returns the opposite bracket for the given bracket.
|
int |
getPrecedenceOrder(ExpressionToken operator,
boolean isUnary)
Gets the precedence order of the given operator
|
int |
getPrecedenceOrder(String operator,
boolean isUnary)
Gets the precedence order of the given operator
|
boolean |
isAllowed(String token)
Checks whether the token is allowed or not.
|
boolean |
isApproachable(String token)
Checks whether the given token is approachable using any of the pattern
or not.
|
boolean |
isBinaryOperator(ExpressionToken token)
Checks whether the given token is a binary operator or not.
|
boolean |
isBinaryOperator(String token)
Checks whether the given token is a binary operator or not.
|
boolean |
isBracket(ExpressionToken token)
Check whether the given token is a bracket or not.
|
boolean |
isBracket(String token)
Check whether the given token is a bracket or not.
|
boolean |
isDelimiter(ExpressionToken token)
Checks whether the token is a delimiter or not.
|
boolean |
isDelimiter(String token)
Checks whether the token is a delimiter or not.
|
boolean |
isFunction(ExpressionToken token)
Checks whether the token is an function or not.
|
boolean |
isFunction(String token)
Checks whether the token is an function or not.
|
boolean |
isIgnoreBlank()
Checks whether to ignore the blanks in expression or not.
|
boolean |
isLeftBracket(ExpressionToken token)
Checks whether the token is a left bracket or not.
|
boolean |
isLeftBracket(String token)
Checks whether the token is a left bracket or not.
|
boolean |
isOperator(ExpressionToken token)
Checks whether the given token is an operator or not.
|
boolean |
isOperator(String token)
Checks whether the given token is an operator or not.
|
boolean |
isRightBracket(ExpressionToken token)
Checks whether the token is a right bracket or not.
|
boolean |
isRightBracket(String token)
Checks whether the token is a right bracket or not.
|
boolean |
isUnary(ExpressionToken operator)
Checks whether the given operator is a unary operator or not.
|
boolean |
isUnary(String operator)
Checks whether the given operator is a unary operator or not.
|
static void |
main(String[] args)
Runs the test for grammar.
|
public final String FILE_PATH
public static final String PRODUCTION_RULES
public static final String UNARY_OPERATORS
public static final String FUNCTIONS
public static final String DELIMITERS
public static final String BRACKETS
public static final String IGNORE_BLANK
public static final String TRUE
public static final String NAME
public static final String BRACKET
public static final String LEFT
public static final String RIGHT
public static final String OPERATOR
public static final String PRECEDENCE
public static final String DELIMITER
public static final String PRODUCTION_RULE
public static final String APPROACHABLE_PATTERN
public static final String ALLOWED_PATTERN
public boolean isDelimiter(ExpressionToken token)
isDelimiter in interface Grammartoken - the tokentrue if the token is delimiter false otherwise.public boolean isDelimiter(String token)
isDelimiter in interface Grammartoken - the tokentrue if the token is delimiter false otherwise.public boolean isApproachable(String token)
isApproachable in interface Grammartoken - the token, partially or full constructed, to check whether
it can approach to any expression token pattern or not.true if the token pattern is approachable false otherwise.public boolean isAllowed(String token)
public boolean isIgnoreBlank()
isIgnoreBlank in interface Grammartrue if parser wants to exclude the blanks false otherwise.public boolean isOperator(ExpressionToken token)
isOperator in interface Grammartoken - the token to checktrue if the token is an operator false otherwisepublic boolean isOperator(String token)
isOperator in interface Grammartoken - the token to checktrue if the token is an operator false otherwisepublic boolean isBinaryOperator(ExpressionToken token)
isBinaryOperator in interface Grammartoken - the token to checktrue if the token is a binary operator false otherwisepublic boolean isBinaryOperator(String token)
isBinaryOperator in interface Grammartoken - the token to checktrue if the token is a binary operator false otherwisepublic void addFunction(String functionName)
addFunction in interface Grammarname - name of the function to addpublic boolean isFunction(ExpressionToken token)
isFunction in interface Grammartoken - the token to checktrue if the token is an function false otherwisepublic boolean isFunction(String token)
isFunction in interface Grammartoken - the token to checktrue if the token is an function false otherwisepublic boolean isUnary(ExpressionToken operator)
public boolean isUnary(String operator)
public boolean isLeftBracket(ExpressionToken token)
isLeftBracket in interface Grammartoken - the token to checktrue if the token can be used as left bracket false otherwise.public boolean isLeftBracket(String token)
isLeftBracket in interface Grammartoken - the token to checktrue if the token can be used as left bracket false otherwise.public boolean isRightBracket(ExpressionToken token)
isRightBracket in interface Grammartoken - the token to checktrue if the token can be used as right bracket false otherwise.public boolean isRightBracket(String token)
isRightBracket in interface Grammartoken - the token to checktrue if the token can be used as right bracket false otherwise.public boolean isBracket(ExpressionToken token)
public boolean isBracket(String token)
public String getOppositeBracket(String bracket)
getOppositeBracket in interface Grammarbracket - the bracket for which we need to find the opposite bracketpublic int getPrecedenceOrder(ExpressionToken operator, boolean isUnary)
getPrecedenceOrder in interface Grammaroperator - the operator to check for precedenceisUnary - true if the operator is unary, as an operator can behave
either as unary or as binarypublic int getPrecedenceOrder(String operator, boolean isUnary)
getPrecedenceOrder in interface Grammaroperator - the operator to check for precedenceisUnary - true if the operator is unary, as an operator can behave
either as unary or as binarypublic static void main(String[] args)