WEB开发网
开发学院WEB开发Jsp Mini Java编译器(三)——属性翻译文法 阅读

Mini Java编译器(三)——属性翻译文法

 2008-01-05 09:12:59 来源:WEB开发网   
核心提示:三、属性翻译文法变量声明(declaration)<VarDeclaration> ::= <Type>↑var_type,var_size<Idetifier>↑id_name

  三、属性翻译文法
变量声明(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

Tags:Mini Java 编译器

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接