January 2013
Intermediate to advanced
328 pages
8h 5m
English
For our first lesson, we’re going to learn how to use semantic predicates to deactivate parts of a Java grammar. The effect will be to recognize different dialects, according to results of evaluating Boolean expressions on-the-fly. In particular, we’re going to see how the same parser can switch between allowing and disallowing enumerated types.
The Java language has been extended over the years to include new constructs. For example, prior to Java 5, the following declaration was invalid:
| | enum Temp { HOT, COLD } |
Rather than building separate compilers for the slightly different dialects, the Java compiler javac has a -source option. Here’s what happens when we try to compile ...
Read now
Unlock full access