标签:语义 lse das bsp strong 描述 ror nbsp else
1.语法文法G[E]如下所示:
–E→E+T | E-T | T
–T→T* F | T/F | F
–F→P^ F | P
–P→(E) | i
解:
E -> E+T
{ E.place := newtemp; emit( E.place , ‘ := ‘ , E.place , ‘ + ‘ , T.place )}
E -> E-T
{ E.place := newtemp; emit( E.place , ‘ := ‘ , E.place , ‘ - ‘ , T.place )}
E -> T
{ E.place := newtemp; emit( E.place , ‘ := ‘ , T.place )}
T -> T*F
{ T.place := newtemp; emit( T.place , ‘ := ‘ , T.place , ‘ * ‘ , F.place )}
T -> T/F
{ T.place := newtemp; emit( T.place , ‘ := ‘ , T.place , ‘ / ‘ , F.place )}
T -> F
{ T.place := newtemp; emit( T.place , ‘ := ‘ , F.place )}
F -> P^F
{ F.place := newtemp; emit( F.place , ‘ := ‘ , P.place , ‘ ^ ‘ , F.place )}
F -> P
{ P.place := newtemp; emit( F.place , ‘ := ‘ , P.place )}
P -> (E)
{ P.place := E.place;}
P -> i
{ if i <> nil then emit( P.place , ‘:=‘ , i.place ) else error}
标签:语义 lse das bsp strong 描述 ror nbsp else
原文地址:https://www.cnblogs.com/fzybk/p/12109606.html