示例#1
0
 @Override
 public boolean parse(Scanner s) {
   Parser.require(Parser.EQUALPAT, LOG + "Expecting " + Parser.EQUALPAT.toString(), s);
   Parser.require(Parser.OPENPAREN, LOG + "Expecting (", s);
   left = new EXP(getRoot());
   if (!left.parse(s)) {
     return false;
   }
   Parser.require(Parser.COMMAPAT, LOG + "Expecting ,", s);
   right = new EXP(getRoot());
   if (!right.parse(s)) {
     return false;
   }
   Parser.require(Parser.CLOSEPAREN, LOG + "Expecting )", s);
   return true;
 }
 @Override
 public boolean parse(Scanner s) {
   Parser.require(Parser.WHILEPAT, LOG + "Expecting " + Parser.WHILEPAT.toString(), s);
   Parser.require(Parser.OPENPAREN, LOG + "Expecting (", s);
   condition = new COND(getRoot());
   if (!condition.parse(s)) {
     return false;
   }
   Parser.require(Parser.CLOSEPAREN, LOG + "Expecting )", s);
   Parser.require(Parser.OPENBRACE, LOG + "Expecting {", s);
   block = new BLOCK(getRoot());
   if (!block.parse(s)) {
     return false;
   }
   Parser.require(Parser.CLOSEBRACE, LOG + "Expecting }", s);
   return true;
 }