Exercício 07.26

Apresente uma derivação à extrema direita (DED) da sentença A := B * (C * (A + B)) 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 > * ( < ter > )
< id > := < ter > * ( < ter > * < fat > )
< id > := < ter > * ( < ter > * ( < exp > ) )
< id > := < ter > * ( < ter > * ( < exp > + < ter > ) )
< id > := < ter > * ( < ter > * ( < exp > + < fat > ) )
< id > := < ter > * ( < ter > * ( < exp > + < id > ) )
< id > := < ter > * ( < ter > * ( < exp > + B ) )
< id > := < ter > * ( < ter > * ( < ter > + B ) )
< id > := < ter > * ( < ter > * ( < fat > + B ) )
< id > := < ter > * ( < ter > * ( < id > + B ) )
< id > := < ter > * ( < ter > * ( A + B ) )
< id > := < ter > * ( < fat > * ( A + B ) )
< id > := < ter > * ( < id > * ( A + B ) )
< id > := < ter > * ( C * ( A + B ) )
< id > := < fat > * ( C * ( A + B ) )
< id > := < id > * ( C * ( A + B ) )
< id > := B * ( C * ( A + B ) )
A := B * ( C * ( A + B ) )


Recomendamos

cert.br Kinghost Duolingo