Package cs2110
Class Token
java.lang.Object
cs2110.Token
- Direct Known Subclasses:
Token.CondOp
,Token.Function
,Token.Number
,Token.Operator
,Token.Variable
Represents a single token (e.g., a number, variable name, operator symbol, or function name)
within an expression string.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A token representing the conditional operator symbol "?:".static class
A token representing a function call.static class
A token representing a floating-point number.static class
A token representing a binary arithmetic operator.static class
A token representing the name of a variable. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
value
The substring corresponding to the token.
-
-
Constructor Details
-
Token
Initialize inherited value field to `value`.
-
-
Method Details
-
value
Return the substring that this token corresponds to. -
parse
Create a new Token of the appropriate class corresponding to the substring `value`. Valid decimal numbers will yield a Number token; recognized operator symbols will yield an Operator or CondOp token; values ending in "()" will yield a Function token, and all other values will yield a Variable token. -
tokenizer
Return the sequence of whitespace-separated tokens contained in `str`.
-