public class Calculator extends java.lang.Object implements CalculatorConstants
Modifier and Type | Field and Description |
---|---|
Token |
jj_nt
Next token.
|
Token |
token
Current token.
|
CalculatorTokenManager |
token_source
Generated Token Manager.
|
AND, ASSIGN, BEGIN, BREAK, COMMA, CONSTANT, CONTINUE, DEFAULT, DEFINE, DIGIT, DIVIDE, ELSE, END, EOF, EOL, EQ, EXP, FLOAT, GE, GT, ID, IF, ILLEGAL, INTEGER, LE, LETTER, LPAREN, LT, MINUS, MULTIPLY, NE, OR, PLUS, PRINT, RETURN, RPAREN, SEPARATOR, tokenImage, WHILE
Constructor and Description |
---|
Calculator() |
Calculator(CalculatorTokenManager tm)
Constructor with generated Token Manager.
|
Calculator(java.io.InputStream stream)
Constructor with InputStream.
|
Calculator(java.io.InputStream stream,
java.lang.String encoding)
Constructor with InputStream and supplied encoding
|
Calculator(java.io.Reader stream)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
arglist() |
void |
assignment() |
void |
breakStatement() |
void |
checkIdentifier(java.lang.String id)
Check whether id is a legal identifier.
|
int |
compileStream() |
int |
compileString(java.lang.String s) |
void |
conjunction() |
void |
continueStatement() |
void |
definition() |
void |
disable_tracing()
Disable tracing.
|
void |
disjunction() |
void |
enable_tracing()
Enable tracing.
|
double |
evalStream() |
double |
evalString(java.lang.String s) |
void |
expression() |
void |
factor() |
void |
funcall() |
ParseException |
generateParseException()
Generate ParseException.
|
Token |
getNextToken()
Get the next Token.
|
Token |
getToken(int index)
Get the specific Token.
|
void |
identifier() |
void |
ifStatement() |
void |
logical() |
void |
oneLine() |
void |
power() |
void |
print() |
void |
program() |
void |
ReInit(CalculatorTokenManager tm)
Reinitialise.
|
void |
ReInit(java.io.InputStream stream)
Reinitialise.
|
void |
ReInit(java.io.InputStream stream,
java.lang.String encoding)
Reinitialise.
|
void |
ReInit(java.io.Reader stream)
Reinitialise.
|
void |
relational() |
void |
returnStatement() |
void |
setStackMachine(StackMachine sm) |
void |
signed_factor() |
void |
signed_power() |
void |
signed_term() |
void |
simple_expression() |
void |
sum() |
void |
term() |
void |
whileStatement() |
public CalculatorTokenManager token_source
public Token token
public Token jj_nt
public Calculator()
public Calculator(java.io.InputStream stream)
public Calculator(java.io.InputStream stream, java.lang.String encoding)
public Calculator(java.io.Reader stream)
public Calculator(CalculatorTokenManager tm)
public void setStackMachine(StackMachine sm)
public int compileStream() throws ParseException
ParseException
public double evalStream() throws ParseException
ParseException
public int compileString(java.lang.String s) throws ParseException
s
- String to be evaluated.ParseException
- Thrown when the string
does not represent a syntactically correct expression.public double evalString(java.lang.String s) throws ParseException
s
- String to be evaluated.ParseException
- Thrown when the string
does not represent a syntactically correct expression.public void checkIdentifier(java.lang.String id) throws ParseException
id
- The name of the variableParseException
- if id is not a valid identifier.public final void program() throws ParseException
ParseException
public final void oneLine() throws ParseException
ParseException
public final void print() throws ParseException
ParseException
public final void ifStatement() throws ParseException
ParseException
public final void whileStatement() throws ParseException
ParseException
public final void expression() throws ParseException
ParseException
public final void simple_expression() throws ParseException
ParseException
public final void logical() throws ParseException
ParseException
public final void conjunction() throws ParseException
ParseException
public final void disjunction() throws ParseException
ParseException
public final void relational() throws ParseException
ParseException
public final void assignment() throws ParseException
ParseException
public final void definition() throws ParseException
ParseException
public final void continueStatement() throws ParseException
ParseException
public final void breakStatement() throws ParseException
ParseException
public final void returnStatement() throws ParseException
ParseException
public final void funcall() throws ParseException
ParseException
public final void sum() throws ParseException
ParseException
public final void term() throws ParseException
ParseException
public final void power() throws ParseException
ParseException
public final void signed_term() throws ParseException
ParseException
public final void signed_power() throws ParseException
ParseException
public final void signed_factor() throws ParseException
ParseException
public final void factor() throws ParseException
ParseException
public final void identifier() throws ParseException
ParseException
public final int arglist() throws ParseException
ParseException
public void ReInit(java.io.InputStream stream)
public void ReInit(java.io.InputStream stream, java.lang.String encoding)
public void ReInit(java.io.Reader stream)
public void ReInit(CalculatorTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()