@Override public RobotProgramNode parse(Scanner scan) { if (!Parser.gobble("takeFuel", scan)) { Parser.fail("Should be takeFuel node.", scan); } if (!Parser.gobble("\\;", scan)) { Parser.fail("Should have ; for variables.", scan); } return new TakeFuel(); }
@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; }