public class DefaultInterpreterInterface extends InterpreterInterface
Modifier and Type | Field and Description |
---|---|
static DefaultInterpreterInterface |
DEFAULT |
Constructor and Description |
---|
DefaultInterpreterInterface() |
Modifier and Type | Method and Description |
---|---|
int |
evaluate(AST expression)
Evaluate an abstract syntax tree representing an integer expression and return the final result
|
AST |
parse(ArrayList<Token> tokens)
Convert sequence of tokens into an abstract syntax tree
|
ArrayList<Token> |
tokenize(String input)
Convert input to an list of tokens
|
tokenizeAndParse, tokenizeParseAndEvaluate
public static final DefaultInterpreterInterface DEFAULT
public ArrayList<Token> tokenize(String input) throws TokenizerException
tokenize
in class InterpreterInterface
input
- the string to be tokenizedTokenizerException
public AST parse(ArrayList<Token> tokens) throws ParserException
parse
in class InterpreterInterface
tokens
- the string to be parsedParserException
public int evaluate(AST expression) throws EvaluatorException
evaluate
in class InterpreterInterface
expression
- the abstract syntax tree to be evaluatedEvaluatorException