First page Back Continue Last page Summary Graphic
The Complete Solution
void nextToken() {
while (ch <= ' ')
nextCh();
switch (ch) {
case EOF_CH:
token = EOF; break;
...
case '/':
nextCh();
if (ch == '=') {
token = NEQ; nextCh();
} else if (ch == '*') {
do {
nextCh();
while (ch == '*') {
nextCh();
if (ch == '/') {
nextCh(); nextToken(); return;
}
}
} while (ch != EOF_CH);
error("unclosed comment");
} else
error("missing =");
break;
default:
error("illegal character: " + ch);
}
}
What about efficiency?