Finite Automata COP 3402 System Software Spring 2008

  • Slides: 11
Download presentation
Finite Automata COP 3402 System Software Spring 2008

Finite Automata COP 3402 System Software Spring 2008

A Sample Automata � 1 is the start state � 4 is the final

A Sample Automata � 1 is the start state � 4 is the final state � abc : recognized � abccabc : recognized � ac : not recognized a 1 a 2 b 3 c 4 c

Identifiers and Keywords 1 A-Za-z 2 A-Za-z 0 -9

Identifiers and Keywords 1 A-Za-z 2 A-Za-z 0 -9

Identifiers and Keywords 2 � Allows character ‘-’, e. g. Next_Line � Can not

Identifiers and Keywords 2 � Allows character ‘-’, e. g. Next_Line � Can not begin with ‘-’ � Can not have consecutive ‘-’ A-Za-z 0 -9 1 A-Za-z 2 A-Z 0 -9 - 3

Integers � Can begin with 0, e. g. 000025 1 0 -9 2 0

Integers � Can begin with 0, e. g. 000025 1 0 -9 2 0 -9

Integers 2 � Can not begin with 0 � Except integer 0, followed by

Integers 2 � Can not begin with 0 � Except integer 0, followed by space 0 -9 1 0 2 0 -9 3 space 4

Float Point Number � Can begin with “ 0” , e. g. 001. 35

Float Point Number � Can begin with “ 0” , e. g. 001. 35 � Can end with “. ”, e. g. 12. � Can end with “ 0”, e. g. 3. 1400 1 0 -9 2 0 -9 . 4 0 -9

All-In-One Automata Token Code PROGRAM 2 VAR 2 BEGIN 2 END. 3 INTEGER 2

All-In-One Automata Token Code PROGRAM 2 VAR 2 BEGIN 2 END. 3 INTEGER 2 FOR 2 READ 2 WRITE 2 TO 2 DO 2 1 A-Za-z 0 -9 2 3 A-Za-z 0 -9 4 0 -9 ; , +-*() : . 5 6 = 7

All-In-One Automata Token Code ; 5 : 6 , 5 : = 7 +

All-In-One Automata Token Code ; 5 : 6 , 5 : = 7 + 5 - 5 * 5 DIV 2 ( 5 ) 5 id 2 int 4 1 A-Za-z 0 -9 2 3 A-Za-z 0 -9 4 0 -9 ; , +-*() : . 5 6 = 7

Reserved Words Token Code null 1 begin 21 end 22 if 23 then 24

Reserved Words Token Code null 1 begin 21 end 22 if 23 then 24 while 25 do 26 call 27 const 28 X 2 Y 2 A 2 0 n b u 3 3 e 3 6 l 3 4 3 7 . 3 l 5 g . 3 8 1 i n 3 9 21 e 4 0 i n d 4 1 4 2 f 22 23

Special Symbols Token Code + 4 - 5 * 6 / 7 = 9

Special Symbols Token Code + 4 - 5 * 6 / 7 = 9 ( 15 ) 16 , 17 ; 18 . 19 + 0 * 4 5 6 / 7 = 9 ( 15