www.sdmetrics.com

com.sdmetrics.math
Class ExpressionParser

java.lang.Object
  extended by com.sdmetrics.math.ExpressionParser

public class ExpressionParser
extends java.lang.Object

Parses metric, set, and condition expressions.


Constructor Summary
ExpressionParser()
          Creates a new parser instance without custom functions and relations.
ExpressionParser(java.util.Set<java.lang.String> functionNames, java.util.Set<java.lang.String> highPrecedenceRelationNames, java.util.Set<java.lang.String> lowPrecedenceRelationNames)
          Creates a new parser instance with custom functions and relations.
 
Method Summary
 java.lang.String getErrorInfo()
          Retrieves a string describing the syntax error that occurred during expression parsing.
static boolean isIdentifierCharacter(char c)
          Tests if a character is a valid identifier character.
 ExpressionNode parseExpression(java.lang.String expr)
          Parses an expression and returns its operator tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionParser

public ExpressionParser()
Creates a new parser instance without custom functions and relations.

Since:
2.3

ExpressionParser

public ExpressionParser(java.util.Set<java.lang.String> functionNames,
                        java.util.Set<java.lang.String> highPrecedenceRelationNames,
                        java.util.Set<java.lang.String> lowPrecedenceRelationNames)
Creates a new parser instance with custom functions and relations. Note: the feature to provide custom relations will probably be removed in future versions of SDMetrics, and the existing special relation operators (onlist, topmost etc) be replaced with functions.

Parameters:
functionNames - The set of names the parser recognizes as function calls (e.g. ln, exp, ...)
highPrecedenceRelationNames - The set of names the parser recognizes as high precedence relations. These relations have the same precedence as the comparison relations ( >, <, >=, <=)
lowPrecedenceRelationNames - The set of names the parser recognizes as low precedence relations. These relations all have the same precedence which is lower than the and relation (&)
Since:
2.3
Method Detail

parseExpression

public ExpressionNode parseExpression(java.lang.String expr)
Parses an expression and returns its operator tree.

Parameters:
expr - The expression to parse.
Returns:
Root node of the operator tree for the expression, or null if the expression could not be parsed.

getErrorInfo

public java.lang.String getErrorInfo()
Retrieves a string describing the syntax error that occurred during expression parsing.

Returns:
Description of the parse error.

isIdentifierCharacter

public static boolean isIdentifierCharacter(char c)
Tests if a character is a valid identifier character.

Parameters:
c - Character to test.
Returns:
true if the character is a letter, digit, or underscore.

www.sdmetrics.com