org.matheclipse.parser.client.operator
Class ASTNodeFactory
- java.lang.Object
-
- org.matheclipse.parser.client.operator.ASTNodeFactory
-
- All Implemented Interfaces:
- IParserFactory
public class ASTNodeFactory extends java.lang.Object implements IParserFactory
-
-
Field Summary
Fields Modifier and Type Field and Description static ASTNodeFactoryMMA_STYLE_FACTORYstatic intPLUS_PRECEDENCEstatic intPOWER_PRECEDENCEstatic ASTNodeFactoryRELAXED_STYLE_FACTORYstatic intTIMES_PRECEDENCE-
Fields inherited from interface org.matheclipse.parser.client.ast.IParserFactory
DEFAULT_OPERATOR_CHARACTERS
-
-
Constructor Summary
Constructors Constructor and Description ASTNodeFactory(boolean ignoreCase)Create a default ASTNode factory
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static voidaddOperator(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)FunctionNodecreateAST(ASTNode headExpr)Creates a new list with no arguments from the given header object .ASTNodecreateDouble(java.lang.String doubleString)Create an double node from the given double value stringFractionNodecreateFraction(IntegerNode numerator, IntegerNode denominator)Create a "fractional" numberFunctionNodecreateFunction(SymbolNode head)Creates a new function with headheadand 0 arguments.FunctionNodecreateFunction(SymbolNode head, ASTNode arg0)Creates a new function with headheadand 1 argument.FunctionNodecreateFunction(SymbolNode head, ASTNode arg0, ASTNode arg1)Creates a new function with headheadand 2 arguments.static InfixOperatorcreateInfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence, int grouping)IntegerNodecreateInteger(int intValue)Create an integer node from the given valueIntegerNodecreateInteger(java.lang.String integerString, int numberFormat)Create an integer node from the given stringPatternNodecreatePattern(SymbolNode patternName, ASTNode check)Create a pattern from the given symbol node (i.e.PatternNodecreatePattern(SymbolNode patternName, ASTNode check, boolean optional)Create a pattern from the given symbol nodePatternNodecreatePattern2(SymbolNode patternName, ASTNode check)Create a pattern from the given symbol node (i.e.PatternNodecreatePattern3(SymbolNode patternName, ASTNode check)Create a pattern from the given symbol node (i.e.static PostfixOperatorcreatePostfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)static PrefixOperatorcreatePrefixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)StringNodecreateString(java.lang.StringBuffer buffer)Create a string node from the scanned double quoted stringSymbolNodecreateSymbol(java.lang.String symbolName)Create a symbol from the scanned identifier stringOperatorget(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 MapgetIdentifier2OperatorMap() java.util.Map<java.lang.String,java.util.ArrayList<Operator>>getOperator2ListMap()Get the operator-string to possible operator-list mapjava.lang.StringgetOperatorCharacters()The set of characters, which could form an operatorjava.util.List<Operator>getOperatorList(java.lang.String key)Get the operator-list for a given operator-stringbooleanisValidIdentifier(java.lang.String identifier)Check if the identifier name is valid.
-
-
-
Field Detail
-
PLUS_PRECEDENCE
public static final int PLUS_PRECEDENCE
- See Also:
- Constant Field Values
-
TIMES_PRECEDENCE
public static final int TIMES_PRECEDENCE
- See Also:
- Constant Field Values
-
POWER_PRECEDENCE
public static final int POWER_PRECEDENCE
- See Also:
- Constant Field Values
-
MMA_STYLE_FACTORY
public static final ASTNodeFactory MMA_STYLE_FACTORY
-
RELAXED_STYLE_FACTORY
public static final ASTNodeFactory RELAXED_STYLE_FACTORY
-
-
Constructor Detail
-
ASTNodeFactory
public ASTNodeFactory(boolean ignoreCase)
Create a default ASTNode factory
-
-
Method Detail
-
addOperator
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)
-
getOperatorCharacters
public java.lang.String getOperatorCharacters()
Description copied from interface:IParserFactoryThe set of characters, which could form an operator- Specified by:
getOperatorCharactersin interfaceIParserFactory
-
getIdentifier2OperatorMap
public java.util.Map<java.lang.String,Operator> getIdentifier2OperatorMap()
public MapgetIdentifier2OperatorMap() - Specified by:
getIdentifier2OperatorMapin interfaceIParserFactory- Returns:
- the map which stores the Operators for a given head string like Times, Plus, Sin,...
-
get
public Operator get(java.lang.String identifier)
Description copied from interface:IParserFactoryGet the operator for a given identifier string like Times, Plus, Sin,...- Specified by:
getin interfaceIParserFactory- Returns:
-
getOperator2ListMap
public java.util.Map<java.lang.String,java.util.ArrayList<Operator>> getOperator2ListMap()
Description copied from interface:IParserFactoryGet the operator-string to possible operator-list map- Specified by:
getOperator2ListMapin interfaceIParserFactory- Returns:
- the map which stores the operator-list for a given operator string like *, +, ==...
-
getOperatorList
public java.util.List<Operator> getOperatorList(java.lang.String key)
Description copied from interface:IParserFactoryGet the operator-list for a given operator-string- Specified by:
getOperatorListin interfaceIParserFactory- Returns:
- the operator-list for a given operator string like *, +, ==...
-
createInfixOperator
public static InfixOperator createInfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence, int grouping)
-
createPrefixOperator
public static PrefixOperator createPrefixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)
-
createPostfixOperator
public static PostfixOperator createPostfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)
-
createDouble
public ASTNode createDouble(java.lang.String doubleString)
Description copied from interface:IParserFactoryCreate an double node from the given double value string- Specified by:
createDoublein interfaceIParserFactory- Returns:
-
createFunction
public FunctionNode createFunction(SymbolNode head)
Description copied from interface:IParserFactoryCreates a new function with headheadand 0 arguments.- Specified by:
createFunctionin interfaceIParserFactory
-
createFunction
public FunctionNode createFunction(SymbolNode head, ASTNode arg0)
Description copied from interface:IParserFactoryCreates a new function with headheadand 1 argument.- Specified by:
createFunctionin interfaceIParserFactory
-
createFunction
public FunctionNode createFunction(SymbolNode head, ASTNode arg0, ASTNode arg1)
Description copied from interface:IParserFactoryCreates a new function with headheadand 2 arguments.- Specified by:
createFunctionin interfaceIParserFactory
-
createAST
public FunctionNode createAST(ASTNode headExpr)
Creates a new list with no arguments from the given header object .- Specified by:
createASTin interfaceIParserFactory
-
createInteger
public IntegerNode createInteger(java.lang.String integerString, int numberFormat)
Description copied from interface:IParserFactoryCreate an integer node from the given string- Specified by:
createIntegerin interfaceIParserFactory- Parameters:
integerString- the integer number represented as a StringnumberFormat- the format of the number (usually 10)- Returns:
- IInteger
-
createInteger
public IntegerNode createInteger(int intValue)
Description copied from interface:IParserFactoryCreate an integer node from the given value- Specified by:
createIntegerin interfaceIParserFactory- Parameters:
intValue- the integer number's value- Returns:
- IInteger
-
createFraction
public FractionNode createFraction(IntegerNode numerator, IntegerNode denominator)
Description copied from interface:IParserFactoryCreate a "fractional" number- Specified by:
createFractionin interfaceIParserFactory- Parameters:
numerator- numerator of the fractional numberdenominator- denominator of the fractional number- Returns:
- IFraction
-
createPattern
public PatternNode createPattern(SymbolNode patternName, ASTNode check)
Description copied from interface:IParserFactoryCreate a pattern from the given symbol node (i.e._orx_)- Specified by:
createPatternin interfaceIParserFactory- Returns:
- Object
-
createPattern
public PatternNode createPattern(SymbolNode patternName, ASTNode check, boolean optional)
Description copied from interface:IParserFactoryCreate a pattern from the given symbol node- Specified by:
createPatternin interfaceIParserFactory- Returns:
- Object
-
createPattern2
public PatternNode createPattern2(SymbolNode patternName, ASTNode check)
Description copied from interface:IParserFactoryCreate a pattern from the given symbol node (i.e.__orx__)- Specified by:
createPattern2in interfaceIParserFactory- Returns:
- Object
-
createPattern3
public PatternNode createPattern3(SymbolNode patternName, ASTNode check)
Description copied from interface:IParserFactoryCreate a pattern from the given symbol node (i.e.___orx___)- Specified by:
createPattern3in interfaceIParserFactory- Returns:
- Object
-
createString
public StringNode createString(java.lang.StringBuffer buffer)
Description copied from interface:IParserFactoryCreate a string node from the scanned double quoted string- Specified by:
createStringin interfaceIParserFactory- Returns:
-
createSymbol
public SymbolNode createSymbol(java.lang.String symbolName)
Description copied from interface:IParserFactoryCreate a symbol from the scanned identifier string- Specified by:
createSymbolin interfaceIParserFactory- Returns:
-
isValidIdentifier
public boolean isValidIdentifier(java.lang.String identifier)
Description copied from interface:IParserFactoryCheck if the identifier name is valid.- Specified by:
isValidIdentifierin interfaceIParserFactory- Parameters:
identifier- the currently parsed identifier- Returns:
falseif the identifier is not valid (in this case the parser creates a SyntaxError exception); otherwise returntrue
-
-
DMelt 3.0 © DataMelt by jWork.ORG