Exercício 07.114

Exercício 07.114 Apresente uma derivação à extrema direita (DED) da sentença a = b + (c * (d - e) - d) * c sobre a gramática a seguir.

G = ({A, B, C, D, E, F, G}, {a, b, c, d, e, =, +, -, *, /, (, )}, P, A)
P = {< A >  ->  < G > = < B >
     < B >  ->  < D > < C >  |  < D >
     < C >  ->  + < D > < C >  |  - < D > < C >  |  + < D >  |  - < D >
     < D >  ->  < F > < E >  |  < F >
     < E >  ->  * < F > < E >  |  / < F > < E >  |  * < F >  |  / < F >
     < F >  ->  ( < B > )  |  < G >
     < G >  ->  a  |  b  |  c  |  d  |  e }

Resposta

< A >
< G > = < B >
< G > = < D > < C >
< G > = < D > + < D >
< G > = < D > + < F > < E >
< G > = < D > + < F > * < F >
< G > = < D > + < F > * < G >
< G > = < D > + < F > * c
< G > = < D > + ( < B > ) * c
< G > = < D > + ( < D > < C > ) * c
< G > = < D > + ( < D > - < D > ) * c
< G > = < D > + ( < D > - < F > ) * c
< G > = < D > + ( < D > - < G > ) * c
< G > = < D > + ( < D > - d ) * c
< G > = < D > + ( < F > < E > - d ) * c
< G > = < D > + ( < F > * < F > - d ) * c
< G > = < D > + ( < F > * ( < B > ) - d ) * c
< G > = < D > + ( < F > * ( < D > < C > ) - d ) * c
< G > = < D > + ( < F > * ( < D > - < D > ) - d ) * c
< G > = < D > + ( < F > * ( < D > - < F > ) - d ) * c
< G > = < D > + ( < F > * ( < D > - < G > ) - d ) * c
< G > = < D > + ( < F > * ( < D > - e ) - d ) * c
< G > = < D > + ( < F > * ( < F > - e ) - d ) * c
< G > = < D > + ( < F > * ( < G > - e ) - d ) * c
< G > = < D > + ( < F > * ( d - e ) - d ) * c
< G > = < D > + ( < G > * ( d - e ) - d ) * c
< G > = < D > + ( c * ( d - e ) - d ) * c
< G > = < F > + ( c * ( d - e ) - d ) * c
< G > = < G > + ( c * ( d - e ) - d ) * c
< G > = b + ( c * ( d - e ) - d ) * c
a = b + ( c * ( d - e ) - d ) * c

        

Recomendamos

Copy Java Magazine Revista Espírito Livre