Пример #1
0
  // ensure current token is tk and skip over it.
  private void mustbe(TK tk) {

    if (tok.kind != tk) {
      //	System.out.println(tk+"%%%%%%%%%%%%%%%%%");
      System.err.println("mustbe: want " + tk + ", got " + tok);
      parse_error("missing token (mustbe)");
    }
    scan();
  }
Пример #2
0
  Parser(Scan scanner) {
    System.out.println("#include <stdio.h>");
    System.out.println("int main(){");
    if (first) {
      addBlock();
      first = false;
      curBlock--;
    }
    this.scanner = scanner;
    scan();
    program();

    if (tok.kind != TK.EOF)
      // System.out.println(tok+"#############");
      parse_error("junk after logical end of program");
    System.out.println();
  }