A parser for mathematical expressions. More...

Public Member Functions | |
| ExpressionNode | parse (String expression) |
| Parse a mathematical expression in a string and return an ExpressionNode. | |
| ExpressionNode | parse (LinkedList< Token > tokens) |
| Parse a mathematical expression in contained in a list of tokens and return an ExpressionNode. | |
Private Member Functions | |
| ExpressionNode | expression () |
| handles the non-terminal expression | |
| ExpressionNode | sumOp (ExpressionNode expr) |
| handles the non-terminal sum_op | |
| ExpressionNode | signedTerm () |
| handles the non-terminal signed_term | |
| ExpressionNode | term () |
| handles the non-terminal term | |
| ExpressionNode | termOp (ExpressionNode expression) |
| handles the non-terminal term_op | |
| ExpressionNode | factor () |
| handles the non-terminal factor | |
| ExpressionNode | factorOp (ExpressionNode expr) |
| handles the non-terminal factor_op | |
| ExpressionNode | argument () |
| handles the non-terminal argument | |
| ExpressionNode | value () |
| handles the non-terminal value | |
| void | nextToken () |
| Remove the first token from the list and store the next token in lookahead. | |
A parser for mathematical expressions.
The parser class defines a method parse() which takes a string and returns an ExpressionNode that holds a representation of the expression.
Parsing is implemented in the form of a recursive descent parser.
Definition at line 64 of file Parser.java.
| ExpressionNode uk.co.cogitolearning.cogpar.Parser.parse | ( | String | expression | ) |
Parse a mathematical expression in a string and return an ExpressionNode.
This is a convenience method that first converts the string into a linked list of tokens using the expression tokenizer provided by the Tokenizer class.
| expression | the string holding the input |
Definition at line 83 of file Parser.java.
| ExpressionNode uk.co.cogitolearning.cogpar.Parser.parse | ( | LinkedList< Token > | tokens | ) |
Parse a mathematical expression in contained in a list of tokens and return an ExpressionNode.
| tokens | a list of tokens holding the tokenized input |
Definition at line 100 of file Parser.java.
1.8.1.2