Exercício 07.23

Apresente uma derivação à extrema direita (DED) da sentença A := A * (B + C) sobre a gramática a seguir (Sebesta, 2000).

G = ({atr, exp, ter, fat, id}, {A, B, C, :=, +, *, (, )}, P, atr)
P = {< atr >  ->  < id > := < exp >
     < exp >  ->  < exp > + < ter >  |  < ter >
     < ter >  ->  < ter > * < fat >  |  < fat >
     < fat >  ->  ( < exp > )  |  < id >
     < id >   ->  A  |  B  |  C }

Resposta

<atr>
<id> := <exp>
<id> := <ter>
<id> := <ter> * <fat>
<id> := <ter> * ( <exp> )
<id> := <ter> * ( <exp> + <ter> )
<id> := <ter> * ( <exp> + <fat> )
<id> := <ter> * ( <exp> + <id> )
<id> := <ter> * ( <exp> + C )
<id> := <ter> * ( <ter> + C )
<id> := <ter> * ( <fat> + C )
<id> := <ter> * ( <id> + C )
<id> := <ter> * ( B + C )
<id> := <fat> * ( B + C )
<id> := <id> * ( B + C )
<id> := A * ( B + C )
A := A * ( B + C )


Recomendamos

Copy Revista Tema Duolingo