Escolar Documentos
Profissional Documentos
Cultura Documentos
1Questo(20ptos)
G4: S | abA | abB | abC
A aSaa | b
B bSbb | c
C cScc | d
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}
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, )}
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