编译原理 赋值翻译

来源:百度知道 编辑:UC知道 时间:2024/06/19 17:41:25
〈赋值语句〉::= 〈标识符〉 := 〈算术表达式〉
算术表达式的文法:
〈算术表达式〉∷=〈项〉{〈加法运算符〉〈项〉}
〈项〉∷= 〈因子〉{〈乘法运算符〉〈因子〉}
〈因子〉∷= 〈标识符〉|〈无符号整数〉|‘(’〈表达式〉‘)’
〈加法运算符〉∷= +|-
〈乘法运算符〉∷= *|/
设计赋值语句文法,给出该文法的属性文法,用递归下降分析法实现对赋值语句的翻译,给出翻译的逆波兰式结果。
ps:不要求代码 给出设计的文法以及实现翻译方法就可以了(稍微具体点) 谢谢了.
一楼很无聊啊~

< > assignment statements: = < < > identifier: = > arithmetic expression
The arithmetic expressions of grammar:
< > arithmetic expression ∷ = > < < the addition of > operator {a} >"
< > a ∷ = > < < factor multiplication operator {> < >} factor,
< < > factor ∷ = > identifier | | > < unsigned integer '< > expression "(")"
< > addition operator ∷ = + | -
< > ∷ multiplication operator = * | /
Design assignment statements, this method of grammar, attribute grammar with recursive descent method for realization of translation assignment statements, the translation of inverse Poland.