Java Reference
In-Depth Information
FIGURE 2.5 Dealing with white space.
Comments
Comments can be considered a special form of white space because the compiler ignores
them. A j-- comment extends from a double-slash, // , to the end of the line. This complicates
the skipping of white space somewhat, as illustrated in Figure 2.6.
FIGURE 2.6 Treating one-line ( //... ) comments as white space.
Notice that a / operator on its own is meaningless in j--. Adding it (for denoting division)
is left as an exercise. But notice that when coming upon an erroneous single / , the lexical
analyzer reports the error and goes back into the start state in order to fetch the next valid
token. This is all captured in the code:
booleanmoreWhiteSpace=true;
while(moreWhiteSpace){
while(isWhitespace(ch)){
nextCh();
}
 
Search WWH ::




Custom Search