//<语句列>::= <语句>{<语句>} void Parser::stmts(ifstream &file, Stmt &s) { while (look.tag != RBRACE) { if (look.tag == Null) return; s.gen(stmt(file)); } }
//<赋值语句>::= <标识符>=<表达式> Stmt Parser::assign(ifstream &file, Token tok) { Stmt stmt; Id id; if (tok.tag == ID) { id = (*(tables.get(proc))).get(tok.lexeme); if (id.kind == CONSTANT) { Error(24, lex.line, "\'" + id.op.lexeme + "\': cannot assign to a variable that is const.").print(); } } else Error(12, lex.line).print(); if (look.tag == ASSIGN) { move(file); Set stmt(id, expr(file)); match(SEMI, file, Error(6, lex.line)); stmt.gen(); return stmt; } Error(16, lex.line).print(); return stmt; }