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
ParseExceptionpublic double evalStream()
throws ParseException
ParseExceptionpublic 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
ParseExceptionpublic final void oneLine()
throws ParseException
ParseExceptionpublic final void print()
throws ParseException
ParseExceptionpublic final void ifStatement()
throws ParseException
ParseExceptionpublic final void whileStatement()
throws ParseException
ParseExceptionpublic final void expression()
throws ParseException
ParseExceptionpublic final void simple_expression()
throws ParseException
ParseExceptionpublic final void logical()
throws ParseException
ParseExceptionpublic final void conjunction()
throws ParseException
ParseExceptionpublic final void disjunction()
throws ParseException
ParseExceptionpublic final void relational()
throws ParseException
ParseExceptionpublic final void assignment()
throws ParseException
ParseExceptionpublic final void definition()
throws ParseException
ParseExceptionpublic final void continueStatement()
throws ParseException
ParseExceptionpublic final void breakStatement()
throws ParseException
ParseExceptionpublic final void returnStatement()
throws ParseException
ParseExceptionpublic final void funcall()
throws ParseException
ParseExceptionpublic final void sum()
throws ParseException
ParseExceptionpublic final void term()
throws ParseException
ParseExceptionpublic final void power()
throws ParseException
ParseExceptionpublic final void signed_term()
throws ParseException
ParseExceptionpublic final void signed_power()
throws ParseException
ParseExceptionpublic final void signed_factor()
throws ParseException
ParseExceptionpublic final void factor()
throws ParseException
ParseExceptionpublic final void identifier()
throws ParseException
ParseExceptionpublic final int arglist()
throws ParseException
ParseExceptionpublic 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()