示例#1
0
 /**
  * Parses a chunk of statements -> + term { print('+') } rest | - term { print('-') } rest | empty
  *
  * @throws IOException
  */
 public void rest() throws IOException {
   while (true) {
     if (lookahead == '+') {
       match('+');
       term();
       writer.write('+');
       continue;
     } else if (lookahead == '-') {
       match('-');
       term();
       writer.write('-');
       continue;
     }
     break;
   }
 }
示例#2
0
 /**
  * Parses a term -> 0 | .. | 9
  *
  * @throws IOException
  */
 public void term() throws IOException, SyntaxError {
   if (Character.isDigit((char) lookahead)) {
     writer.write((char) lookahead);
     match(lookahead);
   }
 }