Java Reference
In-Depth Information
Exercise 2.10. Modify
Scanner
in the j-- compiler to scan (and ignore) Java multi-line
comments.
Exercise 2.11. Modify
Scanner
in the j-- compiler to recognize and return all Java oper-
ators.
Exercise 2.12. Modify
Scanner
in the j-- compiler to recognize and return all Java reserved
words.
Exercise 2.13. Modify
Scanner
in the j-- compiler to recognize and return Java double
precision literal (returned as
DOUBLE_LITERAL
).
Exercise 2.14. Modify
Scanner
in the j-- compiler to recognize and return all other literals
in Java, for example,
FLOAT_LITERAL
,
LONG_LITERAL
, etc.
Exercise 2.15. Modify
Scanner
in the j-- compiler to recognize and return all other rep-
resentations of integers (hexadecimal, octal, etc.).
The following exercises ask you to modify the
j--.jj
file in the j-- compiler for recog-
nizing new categories of tokens. For each of these, write a suitable set of tests, then add the
necessary code, and run the tests. Consult Appendix A to learn how tests work.
Exercise 2.16. Modify the
j--.jj
file in the j-- compiler to scan (and ignore) Java multi-
line comments.
Exercise 2.17. Modify the
j--.jj
file in the j-- compiler to deal with nested Java multi-
line comments, using lexical states and lexical actions.
Exercise 2.18. Re-do Exercise 2.17, but insuring that any nested parentheses inside the
comment are balanced.
Exercise 2.19. Modify the
j--.jj
file in the j-- compiler to recognize and return all Java
operators.
Exercise 2.20. Modify the
j--.jj
file in the j-- compiler to recognize and return all Java
reserved words.
Exercise 2.21. Modify the
j--.jj
file in the j-- compiler to recognize and return Java
double precision literal (returned as
DOUBLE_LITERAL
).
Exercise 2.22. Modify the
j--.jj
file in the j-- compiler to recognize and return all other
literals in Java, for example,
FLOAT_LITERAL
,
LONG_LITERAL
, etc.
Exercise 2.23. Modify the
j--.jj
file in the j-- compiler to recognize and return all other
representations of integers (hexadecimal, octal, etc.).
Search WWH ::
Custom Search