Exemple #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;
   }
 }
Exemple #2
0
 public void finish() throws IOException {
   writer.close();
 }
Exemple #3
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);
   }
 }