public class Parser extends Scanner
ASTNode class-hierarchy from a math
formulas string representation
See
Operator
-precedence parser for the idea, how to parse the operators depending on
their precedence.| Modifier and Type | Field and Description |
|---|---|
static SymbolNode |
DERIVATIVE |
fCurrentChar, fCurrentColumnStartPosition, fCurrentPosition, fFactory, fInputString, fOperatorString, fOperList, fPackageMode, fRecursionDepth, fToken, numFormat, rowCount, TT_ARGUMENTS_CLOSE, TT_ARGUMENTS_OPEN, TT_BLANK, TT_BLANK_BLANK, TT_BLANK_BLANK_BLANK, TT_BLANK_OPTIONAL, TT_COMMA, TT_DERIVATIVE, TT_DIGIT, TT_EOF, TT_FLOATING_POINT, TT_IDENTIFIER, TT_LIST_CLOSE, TT_LIST_OPEN, TT_NEWLINE, TT_OPERATOR, TT_PARTCLOSE, TT_PARTOPEN, TT_PERCENT, TT_PRECEDENCE_CLOSE, TT_PRECEDENCE_OPEN, TT_SLOT, TT_SLOTSEQUENCE, TT_STRING| Constructor and Description |
|---|
Parser() |
Parser(boolean relaxedSyntax) |
Parser(boolean relaxedSyntax,
boolean packageMode) |
Parser(IParserFactory factory,
boolean relaxedSyntax) |
Parser(IParserFactory factory,
boolean relaxedSyntax,
boolean packageMode) |
| Modifier and Type | Method and Description |
|---|---|
IParserFactory |
getFactory() |
ASTNode |
parse(java.lang.String expression)
Parse the given
expression String into an ASTNode. |
java.util.List<ASTNode> |
parsePackage(java.lang.String expression) |
void |
setFactory(IParserFactory factory) |
getIdentifier, getNextToken, getNumberString, getOperator, getStringBuffer, initialize, isWhitespace, throwSyntaxError, throwSyntaxErrorpublic static final SymbolNode DERIVATIVE
public Parser()
public Parser(boolean relaxedSyntax)
throws SyntaxError
relaxedSyntax - if true, use '('...')' as brackets for argumentsSyntaxErrorpublic Parser(boolean relaxedSyntax,
boolean packageMode)
throws SyntaxError
SyntaxErrorpublic Parser(IParserFactory factory, boolean relaxedSyntax) throws SyntaxError
factory - relaxedSyntax - if true, use '('...')' as brackets for argumentsSyntaxErrorpublic Parser(IParserFactory factory, boolean relaxedSyntax, boolean packageMode) throws SyntaxError
SyntaxErrorpublic void setFactory(IParserFactory factory)
public IParserFactory getFactory()
public ASTNode parse(java.lang.String expression) throws SyntaxError
expression String into an ASTNode.expression - a formula string which should be parsed.SyntaxErrorpublic java.util.List<ASTNode> parsePackage(java.lang.String expression) throws SyntaxError
SyntaxError