Você está na página 1de 4

RevisodaProva

1Questo(20ptos)
G4: S | abA | abB | abC
A aSaa | b
B bSbb | c
C cScc | d

Analisador sinttico descendente: w = abcabaaacc


S
abC
S abC
abcScc
C cScc
abcabAcc
S abA
abcabaSaacc
S aSaa
abcabaaacc
S
Analisador sinttico ascendente: w = abaabcaa
abaabcaa
abaabBaa
abaSaa
abaSaa
abA
S

Bc
S abB
A aSaa
S abA

2Questo(30ptos)e3Questo(30ptos)
G1: SAB
A aA | a
B bB | b
first(S) = first(A) = {a}
first(A) = {a}
first(B) = {b}
follow(S) = {$}
follow(A) = first(B) = {b}

follow(B) = follow(S) = {$}


G2: SbSb
A CS | a
S bSa
Cc|
first(S) = {b}
first(A) = first(C) U {a} ={a,c,}
first(C) = {c,}
follow(S) = {$} U {b} U {a} U follow(A) = {$, a, b}
follow(A) = {} =
follow(C) = {b}
G3: SA|B|
AA+B|AB|1|2|3|
BA|C
C (A)
first(S) = first(A) U first(B) U {} = {1,2,3,(,}
first(A) = {1,2,3,}
first(B) = first(A) U first(C) ={1,2,3,(,}
first(C) = {(}
follow(S) = {$}
follow(A) = follow(S) U {+, -} U follow(B) U {)} = {$,
+,-,)}
follow(B) = follow(S) U {+, -, )} = {$,+,-,)}
follow(C) = follow(B) = {$,+,-,)}

G4: SS+T|V
TT+V|Q
VV+Q|S
Q (S) | a | b | c
first(S) = first(V) = {}
first(T) = first(Q) = {(,a,b,c}
first(V) = first(S) = {}
first(Q) = {(,a,b,c}
follow(S) = {$, +,)} U follow(V) = {$, +,)}
follow(T) = {+} U follow(S) = {$, +,)} U follow(V) = {$,
+,)}
follow(V) = {+} U follow(S) U follow(T) = {$, +,)}
follow(Q) = follow(T) U follow(V) = {$, +,)}
G5: SSba|A
A Aca | S
S Sbc | a
A Acb | a
first(S) = first(S) U first(A) U {a} = {a}
first(A) = first(A) U first(S) U {a} = {a}
follow(S) = {$, b} U follow(A) = {$, b, c}
follow(A) = {c} U follow(S) = {$, b, c}
G6: AAouB|B
BBeC|C
C C nou D | D
D (A) | 0 | 1
first(A) = first(A) U first(B) = {(,0,1}
first(B) = first(B) U first(C) = {(,0,1}
first(C) = first(C) U first(D) = {(,0,1}
first(D) = {(,0,1}
follow(A) = {$, ou, )}
follow(B) = {e} U follow(A) = {$, e, ou, )}
follow(C) = {nou} U follow(B) = {$, e, ou, nou, )}
follow(D) = follow(C) = {$, e, ou, nou, )}

4 Questo (20 ptos)


+

1/2

1/2

1/2

4/5/9

4/5/9

4/5/6

4/5/7

4/5/8

10/11

10/11

10

10

10

C
first(S) = {1,2,3,(,}
first(A) = {1,2,3,}
first(B) = {1,2,3,(,}
first(C) = {(}
follow(S) = {$}
follow(A) = {$,+,-,)}
follow(B) = {$,+,-,)}
follow(C) = {$,+,-,)}

11
12

(1)SA
(2)SB
(3)S
(4)A A + B
(5)A A B
(6)A 1
(7)A 2
(8)A 3
(9)A
(10)
BA
(11)
BC
(12)
C (A)

$
1/2/3

4/5/9

4/5/9

10/11

10/11

Você também pode gostar