of 107 /107
Μεταγλωττιστές Ενότητα 7: Συντακτική ανάλυση (Μέρος 1 ο ) Αγγελική Σγώρα Τμήμα Μηχανικών Πληροφορικής ΤΕ
• Author

others
• Category

## Documents

• view

6

0

Embed Size (px)

### Transcript of Μεαγλωισές - openclass.teiwm.gr · •Συντακτικό δένδρο....

• 7: ( 1)

• Creative Commons.

, , , .

2

• .

.

( ) .

3

• ( 1)

• .

5

• (1/3)

.

.

.

.

Chomsky.

.

6

• (2/3)

.

Backus-Naur Form (BNF) Extended BNF (EBNF).

.

.

.

.

7

• (3/3)

.

.

LL(1).

LL(1).

.

.

8

• 1. , (: , 2014).

9

• (1/2)

.

.

.

.

10

• (2/2)

.

.

.

;

.

11

• (1/6)

12

. G.

(T, N,P, S).

: .

: . =.

• (2/6)

13

: . U . UN ( )u.

.

( ), G: {x1,,xn|xi , i=1, }.

• (3/6)

S: . .

.

.

, .

, .

14

• (4/6)

().

.

.

.

15

• (5/6)

.

.

L(G) = { T * | S + }.

+.

.

16

• (6/6)

G=(T,N,P,S).

L(G) T *.

.

.

17

• (1/2)

.

, :

.

.

-.

-.

18

• (2/2)

().

.

19

• Chomsky (1/5)

20

4 :

3 2 1 0.

0.

.

• Chomsky (2/5)

21

1.

.

.

||||.

S .

(S).

• Chomsky (3/5)

2.

.

.

: .

: .

.

22

• Chomsky (4/5)

3.

.

a, a.

,: .

a: .

.

23

• Chomsky (5/5)

3 ().

.

24

• .

.

.

.

.

.

25

• (1/2)

.

.

.. .

.

26

• (2/2)

.

.

.

27

• BNF EBNF (1/2)

,

< >

|

( )

[ ]

{ }

1. BNF EBNF.

28

• BNF EBNF (2/2)

,

< >

=

::=

.

(* *)

1 (). BNF EBNF.

29

• BNF EBNF

.

30

• .

.

.

31

• S = .

:

| ( ) |

:

+ | - | * | /

: (32-6)*12

32

• - (1/6)

.

[ = ].

[ = ].

* [ = *].

( ) * [ = ( )].

33

• - (2/6)

().

( ) *

[ = ].

( ) *

[ = ].

( - ) *

[ = -].

( - ) *

[ = ].

34

• - (3/6)

[ = ]

()

[ = ( )]

( )

[ = ]

( )

[ = ]

35

• - (4/6)

().

( - )

[ = -].

( - )

[ = ].

( - ) *

[ = *].

( - ) *

[ = ].

36

• - (5/6)

2. (: , 2014).

37

• - (6/6)

.

.

.

3. (: , 2014).

38

• (1/18)

.

.

39

• (2/18)

[ = ].

[ = ].

[ = ].

-

[ = -].

40

• (3/18)

-

[ = ].

- *

[ = *].

- *

[ = ].

41

• (4/18)

4. (1), (: , 2014).

42

• (5/18)

[ = ].

[ = ].

-

[ = -].

-

[ = ].

43

• (6/18)

-

[ = ].

- *

[ = *].

- *

[ = ].

44

• (7/18)

5. (2), (: , 2014).

45

• (8/18)

.

.

.

.

46

• (9/18)

S =

= _ | .

= + | -.

= _ | .

= * | /.

= ( ) | .

47

• (10/18)

:

32-6-12.

.

(32-6)-12.

32-(6-12).

48

• (11/18)

.

:

.

49

• (12/18)

:

S = .

= _ | .

_ = + | -.

= _ |

_ = * | /.

= ( ) | .

: 32-5*12.

50

• (13/18)

6. (3), (: , 2014).

51

• (14/18)

: 32-6-12.

7. 32-6-12, (: , 2014).

52

• (15/18)

else.

53

• (16/18)

8. (4), (: , 2014).

54

• (17/18)

9. (5), (: , 2014).

55

• (18/18)

else .

56

• .

.

.

. .

.

57

• (1/3)

1. .

.

2. .

.

58

• (2/3)

3. 2.

.

:

.

.

.

59

• (3/3)

3. ().

.

.

, .

.

.

60

• -

S = k X n k Y

X = l m

Y = mmn nnm : kmmm

10. , (: , 2014).

61

• -

.

.

.

.

.

.

62

• (1/3)

.

.

.

63

• (2/3)

:

.

.

.

.

.

64

• (3/3)

():

.

.

.

.

.

65

• -

S =

= + -

= * /

= ( )

66

• - (1/26)

.

.

.

.

67

• - (2/26)

:

S = = _

_ = + _ - _

= _

_ = * _ / _

= ( )

68

• - (3/26)

, :

_ _ _ () _ _ . . .

_ _ _ _ _ . . .

69

• - (4/26)

.

.

o .

, .

FIRST.

70

• - (5/26)

-.

.

.

.

FOLLOW.

71

• - (6/26)

.

A .

& .

FIRST.

G.

FIRST() .

72

• - (7/26)

.

x FIRST() * x .

.

LL(1).

A A FIRST() FIRST() = .

!.

73

• - (8/26)

LL(1).

.

.

.

74

• - (9/26)

LL(1).

.

.

LL(1).

.

.

75

• - (10/26)

.

:

.

.

76

• - (11/26)

():

.

.

.

77

• - (12/26)

.

.

.

.

78

• - (13/26)

.

:

...|2|1X pp

79

• - (14/26)

first .

.

FIRST() .

.

80

• - (15/26)

FIRST(X) X.

.

FIRST(X) .

X .

FIRST(X) {X}.

81

• - (16/26)

X .

FIRST(X).

X X Y1Y2 ... Yk .

FIRST(X) FIRST(Y1) .

82

• - (17/26)

X X Y1Y2 ... Yk .

a FIRST(X).

a FIRST(Yi) FIRST(Yj) 1 j i.

83

• - (18/26)

X X Y1Y2 ... Yk .

FIRST(X).

FIRST(Yi) 1 i k.

84

• - (19/26)

first .

FIRST X1X2 ... Xn .

FIRST X1, 2 , ... , Xn ( ).

85

• - (20/26)

FIRST(X1X2 ... Xn) :

FIRST(X1) .

FIRST(Xi) .

FIRST(Xj) 1 j i.

.

FIRST(Xi) 1 i n.

86

• - (21/26)

first.

S = = _ _ = + _ - _ = _ _ = * _ / _ . = ( )

87

• - (22/26)

A FOLLOW(A).

A.

.

88

• - (23/26)

FOLLOW(A) A.

.

FOLLOW(A).

\$ FOLLOW(S).

\$ .

S .

89

• - (24/26)

A B .

FOLLOW(B) FIRST() .

A B.

FOLLOW(B) FOLLOW(A).

90

• - (25/26)

A B FIRST().

FOLLOW(B) FOLLOW(A).

91

• - (26/26)

.

, LL(1), ..:

_ = ; _

=

92

• LL(1) (1/3)

11. LL(1), (: , 2014).

93

• LL(1) (2/3)

.

A , :

a FIRST().

A M[A, a].

FIRST().

A M[A, b] b FOLLOW(A).

A M[A, \$] \$ FOLLOW(A).

94

• LL(1) (3/3)

M .

( ).

S = = _ _ = + _ - _ = _. _ = * _ / _ = ( )

95

• (1/2)

.

:

:

......|2pYX

......|1pXY

= _

96

• (2/2)

:

:

mn qqqpXpXpXX |...||||...|| 2121

'.|...|'|' 21 XqXqXqX m

.|'|...|'|'' 21 XpXpXpX n

97

• -

S = .

:

= + -

= * /

= ( )

= _

_ = + _ - _

= _

_ = * _ / _

= ( )

98

• - (1/4)

.

.

G -.

.

.

99

• - (2/4)

.

.

.

.

100

• - (3/4)

101

• - (4/4)

.

.

.

:

.

102

• .

.

.

103

• -

104

• -

, :

:

.

G.

.

LL(1).

."|""" 21 pypyX

'."" XyX

.|' 21 ppX

105

• 1. : , , .., .., , .. (2004), , [ISBN:960-87723-4-6].

2. , , .. , . (2002), , 2002, [ISBN: 978-960-266-135-2].

106

• 107