Package components.utilities
Class Tokenizer
java.lang.Object
components.utilities.Tokenizer
Tokenizer
utility class with methods to tokenize an input stream and
to perform various checks on tokens.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Reports whether the givenString
is a condition in the BL language.static boolean
Reports whether the givenString
is an identifier in the BL language.static boolean
Reports whether the givenString
is a keyword in the BL language.tokens
(SimpleReader in) Tokenizes the entire input getting rid of all whitespace separators and returning the non-separator tokens in aQueue<String>
.
-
Field Details
-
END_OF_INPUT
Token to mark the end of the input. This token cannot come from the input stream because it contains whitespace.- See Also:
-
-
Method Details
-
tokens
Tokenizes the entire input getting rid of all whitespace separators and returning the non-separator tokens in aQueue<String>
.- Parameters:
in
- the input stream- Returns:
- the queue of tokens
- Updates:
in.content
- Requires:
in.is_open
- Ensures:
tokens = [the non-whitespace tokens in #in.content] * <END_OF_INPUT> and in.content = <>
-
isKeyword
Reports whether the givenString
is a keyword in the BL language.- Parameters:
s
- theString
to check- Returns:
- true if
s
is a keyword, false otherwise - Ensures:
isKeyword = [s is a keyword in the BL language]
-
isCondition
Reports whether the givenString
is a condition in the BL language.- Parameters:
s
- theString
to check- Returns:
- true if
s
is a condition, false otherwise - Ensures:
isCondition = [s is a condition in the BL language]
-
isIdentifier
Reports whether the givenString
is an identifier in the BL language.- Parameters:
s
- theString
to check- Returns:
- true if
s
is an identifier, false otherwise - Ensures:
isIdentifier = [s is an identifier in the BL language]
-