public class ParserContext extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
String |
data
The string that is being parsed.
|
static int |
END_OF_STRING
One of the possible token types returned by look() and next().
|
static int |
IDENTIFIER
One of the possible token types returned by look() and next().
|
static int |
NUMBER
One of the possible token types returned by look() and next().
|
static int |
OPCHARS
One of the possible token types returned by look() and next().
|
int |
options
The options from the Parser.
|
int |
pos
Current position in that string, indicating how many
characters have been consumed.
|
ExpressionProgram |
prog
The ExpressionProgram that is being generated as the string
is parsed.
|
protected SymbolTable |
symbols
The Parser's symbol table, which is used for looking up
tokens of type IDENTIFIER.
|
int |
token
The most recently read token type, or NONE if that token
has been consumed by a call to next().
|
MathObject |
tokenObject
If the most recently read token was of type IDENTIFIER, then
this is the corresponding MathObject from the symbol table,
or null if the identifier is not in the symbol table.
|
String |
tokenString
The substring of the parse string that corresponds to the most recently
read token.
|
double |
tokenValue
If the most recently read token was of type NUMBER, then
this is its numerical value.
|
Constructor and Description |
---|
ParserContext(String data,
int options,
SymbolTable symbols)
Create a ParserContext for parsing the data String, using the
specified options and symbol table.
|
Modifier and Type | Method and Description |
---|---|
void |
add(MathObject sym)
Add a new MathObject to the symbol table.
|
MathObject |
get(String name)
Get the MathObject associated with name in the symbol table.
|
int |
look()
Look ahead at the next token in the data string, without consuming it.
|
void |
mark()
MathObjects added to the symbol table after a call to mark() will
be removed by a later, matching call to revert().
|
int |
next()
Consume one token from the string.
|
void |
revert() |
public static final int END_OF_STRING
public static final int NUMBER
public static final int IDENTIFIER
public static final int OPCHARS
public String data
public int pos
public ExpressionProgram prog
public int token
public String tokenString
public MathObject tokenObject
public double tokenValue
public int options
protected SymbolTable symbols
public ParserContext(String data, int options, SymbolTable symbols)
public void mark()
public void revert()
public MathObject get(String name)
public void add(MathObject sym)
public int next()
public int look()