三、属性翻译文法
变量声明(declaration)
<VarDeclaration> ::= <Type>↑var_type,var_size<Idetifier>↑id_name
@varDeclaration↓var_type,var_size,id_name
@varAllocation↓var_size
<Type> ↑var_type,var_size ::= <ArrayType>↑var_type,var_size
<BooleanType>↑var_type,var_size
<IntegerType>↑var_type,var_size
<Identifier>↑var_type,var_size
变量赋值(assignment)
<AssignmentStatement> ::= <Identifier>↑id_name,id_type
“=”
<EXPression>↑exp_type,exp_value
“;”
@checkType↓id_type,exp_type
@insertIntoTable↓id_name,id_type.exp_value
<Expression>↑exp_type,exp_value ::= <AndExpression>↑exp_type,exp_value
<CompareExpression>↑exp_type,exp_value
<PlusExpression>↑exp_type,exp_value
<MinusExpression>↑exp_type,exp_value
<TimesExpression>↑exp_type,exp_value
<ArrayLookup>↑exp_type,exp_value
<ArrayLength>↑exp_type,exp_value
<MessageSend>↑exp_type,exp_value
<PrimaryExpression>↑exp_type,exp_value
<PrimaryExpression>↑exp_type,exp_value ::= <IntegerLiteral>↑exp_type,exp_value
<TrueLiteral>↑exp_type,exp_value
<FalseLiteral>↑exp_type,exp_value
<Identifier>↑exp_type,exp_value