/** * 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; } }
public void finish() throws IOException { writer.close(); }
/** * Parses a term -> 0 | .. | 9 * * @throws IOException */ public void term() throws IOException, SyntaxError { if (Character.isDigit((char) lookahead)) { writer.write((char) lookahead); match(lookahead); } }