There are five sorts of tokens in the lexical syntax:
ID, Integer, ReservedWord, Operator, and Delimiter. When your lexical analyzer
recognizes a token, it should output the sort of token, followed by a
comma, a space, then the value of the token. Case, spacing, and
punctuation count. For example, if the input file were:
/** This is a test. */
class Test {
public static void main (String[] args) {
System.out.println(2 + 13); // cool
}
}
Your lexer should output exactly the following lines:
ReservedWord, class
ID, Test
Delimiter, {
ReservedWord, public
ReservedWord, static
ReservedWord, void
ReservedWord, main
Delimiter, (
ReservedWord, String
Delimiter, [
Delimiter, ]
ID, args
Delimiter, )
Delimiter, {
ReservedWord, System.out.println
Delimiter, (
Integer, 2
Operator, +
Integer, 13
Delimiter, )
Delimiter, ;
Delimiter, }
Delimiter, }
As shown in the example, your program should skip whitespace and comments.
In addition to the example above, here are the remaining examples