Beispiel #1
0
//<标识符>=<标识符>(+|-)<步长>	<步长>::= <非零数字>{<数字>}
Stmt Parser::pace(ifstream &file, Token tok) {
	Token temp;
	Arith arith;
	Id id;
	Expr n;
	Set s;
	if (look.tag == ID && look.lexeme == tok.lexeme) {
		id = (*(tables.get(proc))).get(look.lexeme);
		move(file);
		if (look.tag == PLUS || look.tag == MINUS) {
			temp = look;
			move(file);
			if (look.tag == INTEGER) {
				n.op.lexeme = look.lexeme;
				n.op.tag = INTEGER;
				n.type = Type::_int;
				arith = Arith(temp, id, n);
				(*(tables.get(proc))).putTemp(arith.temp.op.lexeme, arith.temp);
				arith.gen();				
				s = Set(id, arith.temp);
				s.gen();
				move(file);
				return s;
			}
		}
	}
	Error(12, lex.line).print();
	return s;
}