public class ASTNodeFactory extends java.lang.Object implements IParserFactory
| Modifier and Type | Field and Description |
|---|---|
static int |
DIVIDE_PRECEDENCE |
static ASTNodeFactory |
MMA_STYLE_FACTORY |
static int |
PLUS_PRECEDENCE |
static int |
POWER_PRECEDENCE |
static ASTNodeFactory |
RELAXED_STYLE_FACTORY |
static int |
TIMES_PRECEDENCE |
DEFAULT_OPERATOR_CHARACTERS| Constructor and Description |
|---|
ASTNodeFactory(boolean ignoreCase)
Create a default ASTNode factory
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addOperator(java.util.Map<java.lang.String,Operator> operatorMap,
java.util.Map<java.lang.String,java.util.ArrayList<Operator>> operatorTokenStartSet,
java.lang.String operatorStr,
java.lang.String headStr,
Operator oper) |
FunctionNode |
createAST(ASTNode headExpr)
Creates a new list with no arguments from the given header object .
|
ASTNode |
createDouble(java.lang.String doubleString)
Create an double node from the given double value string
|
FractionNode |
createFraction(IntegerNode numerator,
IntegerNode denominator)
Create a "fractional" number
|
FunctionNode |
createFunction(SymbolNode head)
Creates a new function with head
head and 0 arguments. |
FunctionNode |
createFunction(SymbolNode head,
ASTNode arg0)
Creates a new function with head
head and 1 argument. |
FunctionNode |
createFunction(SymbolNode head,
ASTNode arg0,
ASTNode arg1)
Creates a new function with head
head and 2 arguments. |
static InfixOperator |
createInfixOperator(java.lang.String operatorStr,
java.lang.String headStr,
int precedence,
int grouping) |
IntegerNode |
createInteger(int intValue)
Create an integer node from the given value
|
IntegerNode |
createInteger(java.lang.String integerString,
int numberFormat)
Create an integer node from the given string
|
PatternNode |
createPattern(SymbolNode patternName,
ASTNode check)
Create a pattern from the given symbol node (i.e.
|
PatternNode |
createPattern(SymbolNode patternName,
ASTNode check,
boolean optional)
Create a pattern from the given symbol node
|
PatternNode |
createPattern2(SymbolNode patternName,
ASTNode check)
Create a pattern from the given symbol node (i.e.
|
PatternNode |
createPattern3(SymbolNode patternName,
ASTNode check)
Create a pattern from the given symbol node (i.e.
|
static PostfixOperator |
createPostfixOperator(java.lang.String operatorStr,
java.lang.String headStr,
int precedence) |
static PrefixOperator |
createPrefixOperator(java.lang.String operatorStr,
java.lang.String headStr,
int precedence) |
StringNode |
createString(java.lang.StringBuffer buffer)
Create a string node from the scanned double quoted string
|
SymbolNode |
createSymbol(java.lang.String symbolName)
Create a symbol from the scanned identifier string
|
Operator |
get(java.lang.String identifier)
Get the operator for a given identifier string like Times, Plus, Sin,...
|
java.util.Map<java.lang.String,Operator> |
getIdentifier2OperatorMap()
public Map
|
java.util.Map<java.lang.String,java.util.ArrayList<Operator>> |
getOperator2ListMap()
Get the operator-string to possible operator-list map
|
java.lang.String |
getOperatorCharacters()
The set of characters, which could form an operator
|
java.util.List<Operator> |
getOperatorList(java.lang.String key)
Get the operator-list for a given operator-string
|
boolean |
isValidIdentifier(java.lang.String identifier)
Check if the identifier name is valid.
|
public static final int PLUS_PRECEDENCE
public static final int TIMES_PRECEDENCE
public static final int DIVIDE_PRECEDENCE
public static final int POWER_PRECEDENCE
public static final ASTNodeFactory MMA_STYLE_FACTORY
public static final ASTNodeFactory RELAXED_STYLE_FACTORY
public ASTNodeFactory(boolean ignoreCase)
public static void addOperator(java.util.Map<java.lang.String,Operator> operatorMap, java.util.Map<java.lang.String,java.util.ArrayList<Operator>> operatorTokenStartSet, java.lang.String operatorStr, java.lang.String headStr, Operator oper)
public java.lang.String getOperatorCharacters()
IParserFactorygetOperatorCharacters in interface IParserFactorypublic java.util.Map<java.lang.String,Operator> getIdentifier2OperatorMap()
getIdentifier2OperatorMap in interface IParserFactorypublic Operator get(java.lang.String identifier)
IParserFactoryget in interface IParserFactorypublic java.util.Map<java.lang.String,java.util.ArrayList<Operator>> getOperator2ListMap()
IParserFactorygetOperator2ListMap in interface IParserFactorypublic java.util.List<Operator> getOperatorList(java.lang.String key)
IParserFactorygetOperatorList in interface IParserFactorypublic static InfixOperator createInfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence, int grouping)
public static PrefixOperator createPrefixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)
public static PostfixOperator createPostfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)
public ASTNode createDouble(java.lang.String doubleString)
IParserFactorycreateDouble in interface IParserFactorypublic FunctionNode createFunction(SymbolNode head)
IParserFactoryhead and 0 arguments.createFunction in interface IParserFactorypublic FunctionNode createFunction(SymbolNode head, ASTNode arg0)
IParserFactoryhead and 1 argument.createFunction in interface IParserFactorypublic FunctionNode createFunction(SymbolNode head, ASTNode arg0, ASTNode arg1)
IParserFactoryhead and 2 arguments.createFunction in interface IParserFactorypublic FunctionNode createAST(ASTNode headExpr)
createAST in interface IParserFactorypublic IntegerNode createInteger(java.lang.String integerString, int numberFormat)
IParserFactorycreateInteger in interface IParserFactoryintegerString - the integer number represented as a StringnumberFormat - the format of the number (usually 10)public IntegerNode createInteger(int intValue)
IParserFactorycreateInteger in interface IParserFactoryintValue - the integer number's valuepublic FractionNode createFraction(IntegerNode numerator, IntegerNode denominator)
IParserFactorycreateFraction in interface IParserFactorynumerator - numerator of the fractional numberdenominator - denominator of the fractional numberpublic PatternNode createPattern(SymbolNode patternName, ASTNode check)
IParserFactory_ or
x_)createPattern in interface IParserFactorypublic PatternNode createPattern(SymbolNode patternName, ASTNode check, boolean optional)
IParserFactorycreatePattern in interface IParserFactorypublic PatternNode createPattern2(SymbolNode patternName, ASTNode check)
IParserFactory__ or
x__)createPattern2 in interface IParserFactorypublic PatternNode createPattern3(SymbolNode patternName, ASTNode check)
IParserFactory___ or
x___)createPattern3 in interface IParserFactorypublic StringNode createString(java.lang.StringBuffer buffer)
IParserFactorycreateString in interface IParserFactorypublic SymbolNode createSymbol(java.lang.String symbolName)
IParserFactorycreateSymbol in interface IParserFactorypublic boolean isValidIdentifier(java.lang.String identifier)
IParserFactoryisValidIdentifier in interface IParserFactoryidentifier - the currently parsed identifierfalse if the identifier is not valid (in this case the
parser creates a SyntaxError exception); otherwise return
true