This presentation is the property of its rightful owner.
Sponsored Links
1 / 56

第二章 文法和语言 2.1 文法的基本概念 PowerPoint PPT Presentation


  • 74 Views
  • Uploaded on
  • Presentation posted in: General

第二章 文法和语言 2.1 文法的基本概念 一个程序设计语言是一个记号系统,如自然语言一样,它的完整的定义应包括语法和语义两方面。所谓一个语言的语法是指一组规则,用它可以形成和产生一个合适的程序,目前在程序设计语言的识别中广泛使用的是上下文无关的文法。在这理主要介绍文法和语言的概念。. 例:设有文法: < 句子 >→< 主语 >< 谓语 > < 主语 >→< 冠词 >< 形容词 >< 名词 > < 冠词 >→the < 形容词 >→big < 谓语 >→< 动词 >< 直接宾语 > < 动词 >→ate|caught < 直接宾语 >→< 冠词 >< 名词 >

Download Presentation

第二章 文法和语言 2.1 文法的基本概念

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


2 1

2.1


2 1

<><><>

<><><><>

<>the

<>big

<><><>

<>ate|caught

<><><>

<>mouse|cat


2 1

<>=><><>=><><><><>

=>the<><><>=> the big<><>

=>the big cat <>=>the big cat <><>

=>the big cat ate<>=>the big cat ate<><>=>the big cat ate the <> =>the big cat ate the mouse


2 1

2.1.1

2.1

{01}

C

2.2

a,b,c,ba,bbac,caacb,{a,b,c}


2 1

2.3

2.4

xx|x|(x)

|abc|=3 |a|=1 ||=0

2.5

u=xvy,v,vu,|u|> |v|vu


2 1

2.6

z=xyxzyzxyyx

z=abcz,aababcabcz,cbcabcz,cbc


2 1

2.7

xy yXxy

x=aby=wabu

z=xy=abywabu

|x|+|y|=|z|

x=x=x


2 1

2.8

xxnz,z=xxxx(nx)x,z=xn

x0= x1=x x2=xx x3=xxx

2.9

AA

{}


2 1

2.10

ABAB

AB={xy|xAyB}

A={a,bc}B=b,c,daAB={ab,ac,ada,bcb,bcc,bcda

x=x=x {}A=A{}=A A=A=

A0={}

A1=A

A2=AA

An=An-1A=AAn-1n>0


2 1

1

2

3

nn

2.11

A A*=A0A1A2

A A+= A1A2A3

A+=AA*=A*A A*=A0A+


2 1

={0,1},*=,0,100,0110,11,000001010,

L={A,B,C,,Z,a,b, ,z},D={0,1, 9}

1.LD 2.LD 3.L4 4. L(LD)* 5. D+ 6.D+L*

1.

2.

3.

4.

5.

6.


2 1

z=xyz=xxz:z=xxz:z=x


2 1

2.1.2

=


2 1

2.12

GVn,VtPS

:

VnVt

P

S,

VnVtP

VnVtVnVt =


2 1

2.13

VVnVtVG

:G=Vn,VtPS Vn={S},Vt={0l,

P=SOS1S01S;01S


2 1

: G=Vn,VtPS

:

Vn={<>,<>,<>,<>}

Vt={+,-,0,1,2,3,4,5,6,7,8,9}

P={<><><>

<><>

<>+

<>-

<><><>

<><>

<>0

<>1


2 1

<>2

<>3

<>4

<>5

<>6

<>7

<>8

<>9

}

S=<>


2 1

1<>

2G[Z]G

3A1A2A3 A 4 AkAAA1|2|3|4|k,1,2,3,4,kA


2 1

:<><><>|<>

<>+|-

<><><>|<>

<>0|1|2|3|4|5|6|7|8|9

2.14

G121=1A22=12A G1221(211=>2


2 1

:G[<>]:

<><><>|<>

<>+|-

<><><>|<>

<>0|1|2|3|4|5|6|7|8|9

2006

<>=><>=><><>=>

<><><>=><><><><>=><><><><>=>2<><><>=>20<><>=>200<>=>2006


2 1

2.15

1=>2=>3=>4=>n ,1n1n1+nn11=+=>n

<>=+=>2006

2.16 =+=>==*=> *

: G[<>]<>=*=>2006

G[<>]<>=*=><>

<>=*=>the big cat ate the mouse


2 1

2.17

G[S]S=*=>VtVn*G[S]Vt*G[S]

: G[<>]:

<><>

<><><>|<>

<>0|1|2|3|4|5|6|7|8|9

00002006123456789<><><>G[<>] 00002006123456789G

3<> <><>


2 1

2.18

G

LG={|S=*=>Vt*}

LG[<>]={}

2.19

LG1= LG2G1G2

G1[<>]

<><>

<><><>|<>

<>0|1|2|3|4|5|6|7|8|9

G2[<>]

<><>

<> <> 0| <> 1| <> 2| <> 3| <> 4| <> 5| <> 6| <> 7| <> 8| <> 9 |0|1|2|3|4|5|6|7|8|9

L G1= L G2


2 1

1

2

3


2 1

1

2

3


2 1

1

2

3


2 1

2.1.

2.20

=l=>

2.21

=r=>


2 1

AA

AA

AA

AA(


2 1

AB

BA

A=>B=> A


2 1

2.1.4

1956Chomsky

0123

G=Vn,VtPSVnVt*VnVt V* G 0

00

Turing00


2 1

G=Vn,VtPSPS||||G1

||||AA

G= Vn,VtPS PVnVnVt* 2

G= Vn,VtPS PAaBAaABaG3AaBAa ABaAa

0123


2 1

3210

210

10

1L={aibjck|i,j,k1}

SaS|aB BbB|bC CcC|c

2L={aibick|i,k1}

SAC AaAb|ab CcC|c

3L={aibici|i1}

SaSBC|aBC

CBBC aBab bBbb bCbc cCcc

30,03


2 1

2.2

GOTO <> GOTO;


2 1

2.2.1

G[S]

SAB AaAb|ab BcBd|cd

s=>AB=>AcBd=>Accdd=>abccdd


2 1

1

2

3

4

5

6


2 1

2.22

2.23


2 1

G[E]

EE+E|E*E|E|i

i*i+i

G[E]i*i+i


2 1

G1G2

G1[E]:

EE+E|E*E|(E)|i

G2[E]:

EE+T|T

TT*F|F

F(E)|i


2 1

Sif E then S|if E then S else S|b

if E then E then S else S

then else

SS1|S2

S1if E then S1 else S1|b

S2if E then S1|if E then S1 else S2


2 1

2.2.2

,,

2.23

GUU


2 1

G[S]

SS|DS|D

D0|1

SS

G'[S]

SDS|D

D0|1

L(G[S])=L(G'[S])


2 1

2.24

GU

1U,,

2


2 1

G[S]

(1) S Be

(2) B Ce

(3) B Af

(4) A Ae

(5) A e

(6) C Cf

(7) D f

DC672


2 1

G[S]

(1) S Be

(2) B Af

(3) A Ae

(4) A e


2 1

2.2.2


2 1


2 1

,

G[S]

ScAd

Aab

Aa

w=cabd


2 1

:

G[S]

ScAd

Aab

Aa

w=cabd


2 1

A1|2|3|4|k

ABAB

:G[S]:

SaBC

Bib|b

CDE|FG

Dd

Eeh

Fde

Gt

abdet,CDEFG


2 1

G[S]:SaAcBe

Ab

AAb

Bb

abbbcbe

a bbcbe

ab bcbe

aA bcbe

aAb cbe

aA cbe

aAc be

aAcb e

aAcB e

aAcBe

S


2 1

2.25

G[S]GS=*=>AA=+=>AA A

S=*=>A=+=>

2.26


2 1

G[<>]:

<><>

<><><>|<>

<>0|1|2|3|4|5|6|7|8|9

<> <>3

3 <> <> <> <> 3

<> <> 3

<> <>

<> <> 3


2 1


2 1

1

2

3

4

5AA


2 1

LG=Vn,VtPSPAAVnVnVt*L

AAAVnVnVt+SS

G=Vn,VtPSG1GG1G1GG1GG1


2 1

G[E]:EE+T|T

TT*F|F

F(E)|i

i+i*i+i

i+i*i+i i+i*i i i*i i i i

i i i i

i


  • Login