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()
IParserFactory
getOperatorCharacters
in interface IParserFactory
public java.util.Map<java.lang.String,Operator> getIdentifier2OperatorMap()
getIdentifier2OperatorMap
in interface IParserFactory
public Operator get(java.lang.String identifier)
IParserFactory
get
in interface IParserFactory
public java.util.Map<java.lang.String,java.util.ArrayList<Operator>> getOperator2ListMap()
IParserFactory
getOperator2ListMap
in interface IParserFactory
public java.util.List<Operator> getOperatorList(java.lang.String key)
IParserFactory
getOperatorList
in interface IParserFactory
public 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)
IParserFactory
createDouble
in interface IParserFactory
public FunctionNode createFunction(SymbolNode head)
IParserFactory
head
and 0 arguments.createFunction
in interface IParserFactory
public FunctionNode createFunction(SymbolNode head, ASTNode arg0)
IParserFactory
head
and 1 argument.createFunction
in interface IParserFactory
public FunctionNode createFunction(SymbolNode head, ASTNode arg0, ASTNode arg1)
IParserFactory
head
and 2 arguments.createFunction
in interface IParserFactory
public FunctionNode createAST(ASTNode headExpr)
createAST
in interface IParserFactory
public IntegerNode createInteger(java.lang.String integerString, int numberFormat)
IParserFactory
createInteger
in interface IParserFactory
integerString
- the integer number represented as a StringnumberFormat
- the format of the number (usually 10)public IntegerNode createInteger(int intValue)
IParserFactory
createInteger
in interface IParserFactory
intValue
- the integer number's valuepublic FractionNode createFraction(IntegerNode numerator, IntegerNode denominator)
IParserFactory
createFraction
in interface IParserFactory
numerator
- numerator of the fractional numberdenominator
- denominator of the fractional numberpublic PatternNode createPattern(SymbolNode patternName, ASTNode check)
IParserFactory
_
or
x_
)createPattern
in interface IParserFactory
public PatternNode createPattern(SymbolNode patternName, ASTNode check, boolean optional)
IParserFactory
createPattern
in interface IParserFactory
public PatternNode createPattern2(SymbolNode patternName, ASTNode check)
IParserFactory
__
or
x__
)createPattern2
in interface IParserFactory
public PatternNode createPattern3(SymbolNode patternName, ASTNode check)
IParserFactory
___
or
x___
)createPattern3
in interface IParserFactory
public StringNode createString(java.lang.StringBuffer buffer)
IParserFactory
createString
in interface IParserFactory
public SymbolNode createSymbol(java.lang.String symbolName)
IParserFactory
createSymbol
in interface IParserFactory
public boolean isValidIdentifier(java.lang.String identifier)
IParserFactory
isValidIdentifier
in interface IParserFactory
identifier
- the currently parsed identifierfalse
if the identifier is not valid (in this case the
parser creates a SyntaxError exception); otherwise return
true