Class Expr
java.lang.Object
Expr
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Value
eval()
Evaluate a given Expr.static Expr
Return (our internal representation of) the expression s.static Expr
Return (our internal representation of) the expression at front of s.static Expr
Return (our internal representation of) the expression at front of s.abstract String
toString()
Return a String representation of this Expr.
-
Field Details
-
PUNCTUATION
- See Also:
-
-
Constructor Details
-
Expr
public Expr()
-
-
Method Details
-
eval
Evaluate a given Expr.- Returns:
- the Value this Expr evaluates to. (In X0, all values are numbers (doubles), but in X3 that will change, which is why we have pre-emptively made the return type 'Value'.)
-
toString
Return a String representation of this Expr. The result will be something which can be passed into 'parse(String)' to get the same Expr back. That is, toString and parse are inverses of each other. -
parse
Return (our internal representation of) the expression s.- Parameters:
s
- The source code for exactly one Expr. Must by syntactically correct.- Returns:
- (our internal representation of) the expression s.
-
parse
Return (our internal representation of) the expression at front of s.- Parameters:
s
- A scanner reading the source code for exactly one Expr. May throw InputMismatchExpression if Expr is not syntactically correct.- Returns:
- (our internal representation of) the expression s.
-
parse
Return (our internal representation of) the expression at front of s.- Parameters:
s
- A scanner reading the source code for exactly one Expr. May throw InputMismatchExpression if Expr is not syntactically correct.punctuation
- a string of characters to be considered punctuation (which also delimits).- Returns:
- (our internal representation of) the expression s.
-