正在加载图片...
Syntax-Directed Definition-Example2 Production Semantic Rules E→E1+T E.loc=newtempO,E.code E.code ll T.code ll add E1.loc,T.loc,E.loc E→T E.loc T.loc,E.code=T.code T→T1*F T.loc=newtemp(,T.code Ti.code ll F.code ll mult T1.loc,F.loc,T.loc T→F T.loc F.loc,T.code=F.code F→(E) F.loc =E.loc,F.code=E.code F→id F.loc id.name,F.code=4 Symbols E,T,and F are associated with synthesized attributes loc and code. The token id has a synthesized attribute name (it is assumed that it is evaluated by the lexical analyzer). It is assumed that is the string concatenation operator. CS308 Compiler Theory 11Syntax-Directed Definition – Example2 Production Semantic Rules E → E T E l () E d E d || T d || dd E l Tl El 1 + T E.loc=newtemp(), E.co de = E1.co de || T.co de || add E1.loc, T.loc, E.loc E → T E.loc = T.loc, E.code=T.code T → T1 * F T.loc=newtemp(), T.code = T1.code || F.code || mult T1.loc,F.loc,T.loc 1 p(), 1 || || 1 , , T → F T.loc = F.loc, T.code=F.code F → ( E ) F.loc = E.loc, F.code=E.code F → id F l. oc = id.name, F d “” .co de=“” • Symbols E T and F are associated with synthesized attributes Symbols E, T, and F are associated with synthesized attributes loc and code. • The token id has a synthesized attribute name (it is assumed that it is evaluated by the lexical analyzer). • It is assumed that || is the string concatenation operator. CS308 Compiler Theory 11
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有