public interface TokenFactory
The methods of TokenFactory exist for one reason, and one reason only; to decouple the TokenizerTest class from the specific classes used that all inherit from Token.
That way, the instructor can pin down the exact contents of the TokenizerTest.java file, in a way that does not change. But, the TokenizerTest.java file does NOT depend on the names that you give to the classes that implement various kinds of tokens.
That way, you are free, for example, if you are extending the code to add == and != as operators, to either have separate EqualsOpToken and NotEqualsOpToken, or instead to just have an ComparisonOpToken into which you pass either "==" or "!=" as a value (much the same as is done for the IntToken and ErrorToken classes.)
Modifier and Type | Method and Description |
---|---|
Token |
makeDivideToken()
make a token that represents a division operator
/ |
Token |
makeErrorToken(String value)
make a token that indicates there were one or more illegal characters in the input
|
Token |
makeIntToken(String value)
make the type of token that represents an integer
|
Token |
makeLParenToken()
make a token that represents a left parentheses
( |
Token |
makeMinusToken()
make a token that represents a minus sign
- |
Token |
makePlusToken()
make a token that represents a plus sign
+ |
Token |
makeRParenToken()
make a token that represents a right parentheses
) |
Token |
makeTimesToken()
make a token that represents a multiplication operator
* |
Token makeIntToken(String value)
value
- value of the integer, as a string.Token makeErrorToken(String value)
value
- the sequence of illegal charactersToken makeLParenToken()
(
Token makeRParenToken()
)
Token makePlusToken()
+
Token makeMinusToken()
-
Token makeTimesToken()
*
Token makeDivideToken()
/