Compiler. --- Lexical Analysis: Principle&Implementation. Zhang Zhizheng.

Similar documents
Left Recursion. Lecture 8 Section Robb T. Koether. Hampden-Sydney College. Wed, Feb 4, 2015

A Note on H-Cordial Graphs

MyPlate ipad Webquest

John Perry. Fall 2009

Algorithms. How data is processed. Popescu

CS 322: (Social and Information) Network Analysis Jure Leskovec Stanford University

Chapter 1: The Ricardo Model

DEVELOPING PROBLEM-SOLVING ABILITIES FOR MIDDLE SCHOOL STUDENTS

a WOW Lab Prep Instructions

GEORGIA DEPARTMENT OF CORRECTIONS Standard Operating Procedures. Policy Number: Effective Date: 2/9/2018 Page Number: 1 of 5

Recursion. John Perry. Spring 2016

Section 2.3 Fibonacci Numbers and the Golden Mean

Managing Multiple Ontologies in Protégé

Semantic Web. Ontology Engineering. Gerd Gröner, Matthias Thimm. Institute for Web Science and Technologies (WeST) University of Koblenz-Landau

3-Total Sum Cordial Labeling on Some New Graphs

GCSE 4091/01 DESIGN AND TECHNOLOGY UNIT 1 FOCUS AREA: Food Technology

APPENDIX PROPER USE GUIDELINES INGREDIENT BRANDING

The Dun & Bradstreet Asia Match Environment. AME FAQ. Warwick R Matthews

TEACHER NOTES MATH NSPIRED

VIII. Claim Drafting Methodologies. Becky White

Dairy Marketing. Dr. Roger Ginder Econ 338a Fall 2009 Lecture # 2

Lecture 9: Tuesday, February 10, 2015

Predicting Wine Quality

MUMmer 2.0. Original implementation required large amounts of memory

User Studies for 3-Sweep

Lesson 23: Newton s Law of Cooling

Case Study 8. Topic. Basic Concepts. Team Activity. Develop conceptual design of a coffee maker. Perform the following:

Roux Bot Home Cooker. UC Santa Cruz, Baskin Engineering Senior Design Project 2015

OPERATING MANUAL. Sample PRO 100 Series. Electric Heating. Applies to Versions: SPE1*, SPE2, SPE4, SPE6

Better Punctuation Prediction with Hierarchical Phrase-Based Translation

Recent U.S. Trade Patterns (2000-9) PP542. World Trade 1929 versus U.S. Top Trading Partners (Nov 2009) Why Do Countries Trade?

6.2.2 Coffee machine example in Uppaal

Kiosks: An Easy and Effective Nutrition Labeling Solution for Grocery Stores

DIVIDED SQUARE DIFFERENCE CORDIAL LABELING OF SPLITTING GRAPHS

Step 1: Prepare To Use the System

Square Divisor Cordial, Cube Divisor Cordial and Vertex Odd Divisor Cordial Labeling of Graphs

Haccp Manual For Institutional Food Service. Operations >>>CLICK HERE<<<

Association Rule Mining

CAUTION!!! Do not eat anything (Skittles, cylinders, dishes, etc.) associated with the lab!!!

Assignment # 1: Answer key

Algorithms in Percolation. Problem: how to identify and measure cluster size distribution

EAST AFRICAN STANDARD

MATLAB PROGRAM FOR ENERGY OF EVEN SUM CORDIAL GRAPHS

Caffeine And Reaction Rates

Activity 10. Coffee Break. Introduction. Equipment Required. Collecting the Data

This document is a preview generated by EVS

Chapter 3 Labor Productivity and Comparative Advantage: The Ricardian Model

Algebra I: Strand 3. Quadratic and Nonlinear Functions; Topic 3. Exponential; Task 3.3.4

Directions for Menu Worksheet. General Information:

Instruction (Manual) Document

Big Green Lessons Germination: Kindergarten-2 nd Grade

COMPARISON OF THREE METHODOLOGIES TO IDENTIFY DRIVERS OF LIKING OF MILK DESSERTS

Demand, Supply and Market Equilibrium. Lecture 4 Shahid Iqbal

Introduction to Management Science Midterm Exam October 29, 2002

(Definition modified from APSnet)

Cafeteria Ron software

TRTP and TRTA in BDS Application per CDISC ADaM Standards Maggie Ci Jiang, Teva Pharmaceuticals, West Chester, PA

Introduction to the Practical Exam Stage 1. Presented by Amy Christine MW, DC Flynt MW, Adam Lapierre MW, Peter Marks MW

STATE OF MICHIGAN DEPARTMENT OF LICENSING AND REGULATORY AFFAIRS LANSING

Quotient Cordial Labeling of Graphs

Dr APJ A K TECHNICAL UNIVERSITY ODD SEMESTER EXAMINATION th Semester

Software engineering process. Literature on UML. Modeling as a Design Technique. Use-case modelling. UML - Unified Modeling Language

Archdiocese of New York Practice Items

Subject Area: High School French State-Funded Course: French III

Reading Essentials and Study Guide

LEVEL: BEGINNING HIGH

Girl Guides of Canada Cookie Challenge. Guides

Algorithmic Thinking. Alison Pamment. On behalf of the course team (STFC/NERC:CEDA, NERC:NCAS, NERC:NCEO)

Remembering The Kana: The Hiragana / The Katakana By James W. Heisig, Helmut Morsbach READ ONLINE

STACKING CUPS STEM CATEGORY TOPIC OVERVIEW STEM LESSON FOCUS OBJECTIVES MATERIALS. Math. Linear Equations

-- CS341 info session is on Thu 3/18 7pm in Gates Final exam logistics

ISO INTERNATIONAL STANDARD. Infusion equipment for medical use Part 6: Freeze drying closures for infusion bottles

Ideas for group discussion / exercises - Section 3 Applying food hygiene principles to the coffee chain

Economics 101 Spring 2016 Answers to Homework #1 Due Tuesday, February 9, 2016

Sierpinski Cookies. Wednesday, April 09 09:15 AM PST. Contributed by: Lenore

Learning Connectivity Networks from High-Dimensional Point Processes

Dum Ka Biryani, Make for each other

Thought: The Great Coffee Experiment

Pineapple Cake Recipes

OALCF Task Cover Sheet. Goal Path: Employment Apprenticeship Secondary School Post Secondary Independence

CS 322: (Social and Information) Network Analysis Jure Leskovec Stanford University

PELICAN PUBLISHING COMPANY

User s Manual. User s Manual Version 1.0. Chulalongkorn University. Raks Thai Foundation. Worcester Polytechnic Institute. January 29 th, 2013

Introduction. Background Information

What Is This Module About?

Slow Rot or Not! By Jennifer Goldstein

PHYSICAL DIFFERENCES BETWEEN SWEET CORN AND FIELD CORN. Objective: After the lesson and activity, students should be able to distinguish the

Pevzner P., Tesler G. PNAS 2003;100: Copyright 2003, The National Academy of Sciences

Swiss Trade Mediamatics (Sample for year 2017)

Set! Designing Your Food Sovereignty. Assessment

Objective: Decompose a liter to reason about the size of 1 liter, 100 milliliters, 10 milliliters, and 1 milliliter.

Chapter 3: Labor Productivity and Comparative Advantage: The Ricardian Model

Sustainable Coffee Challenge FAQ

Information on County 4-H Favorite Foods

Alcolyzer Plus Spirits

Introduction to the Practical Exam Stage 1

What is it? These are the departments in a supermarket/grocery store. Look at the items you can easily find in each department.

Decision making with incomplete information Some new developments. Rudolf Vetschera University of Vienna. Tamkang University May 15, 2017

FOR PERSONAL USE. Capacity BROWARD COUNTY ELEMENTARY SCIENCE BENCHMARK PLAN ACTIVITY ASSESSMENT OPPORTUNITIES. Grade 3 Quarter 1 Activity 2

Develop the skills and knowledge to use a range of cookery methods to prepare menu items for the kitchen of a hospitality or catering operation.

Transcription:

Compiler --- Lexical Analysis: Principle&Implementation Zhang Zhizheng seu_zzz@seu.edu.cn School of Computer Science and Engineering, Software College Southeast University 2013/10/20 Zhang Zhizheng, Southeast University 1

Question Addressed MESSAGE? Scanner Token Pattern1 Token Pattern k 1 E 2 M 3 C 2013/10/20 Zhang Zhizheng, Southeast University 2

Basic Definitions Token E.g., id, if, then, number Token Pattern E.g., id is a string of character and digits and begin with a character, if is if,. Lexeme E.g., variable, if, then, =, ==,, 60, 60.0 2013/10/20 Zhang Zhizheng, Southeast University 3

Basic Principles I Token patterns are represented in Regular expressions (RE), or equally Regular grammar (RG) RE Languages of RE (RG) Recognized by Finite State Automata (FA) RG FA 2013/10/20 Zhang Zhizheng, Southeast University 4

NOTE For any language L(G) defined by a RG G, there exists a RE E such that L(G)=L(E) For any language define by a RG/RE, there is a FA that can recognize it. 2013/10/20 Zhang Zhizheng, Southeast University 5

Basic Principles II Regular Grammar Right Linear Grammar G=(V T, V N, P, S) is LLG, if every production in P is of the form A B, or A where A,B V N,, V T * E.g., <ID> (a b c A Z)<REST> <REST> (a b c A Z 0 9)<REST> <REST> a b c A Z 0 9 2013/10/20 Zhang Zhizheng, Southeast University 6

Basic Principles II Regular Grammar Left Linear Grammar G=(V T, V N, P, S) is LLG, if every production in P is of the form A B, or A where A,B V N,, V T * E.g., <ID> <HEAD> (a b c A Z 0 9 ) <HEAD> <HEAD>(a b c A Z 0 9) <HEAD> a b c A Z 2013/10/20 Zhang Zhizheng, Southeast University 7

Basic Principles III Regular Expression Definition of RE on an alphabet is a RE, and L( ) is { }, a is a RE, and L(a) is {a}, if a, r s is a RE, and L(r s)=l(r) L(s) if both r and s are REs, rs is a RE, and L(r s)=l(r)l(s) if both r and s are REs, r* is a RE, and L(r*)=L(r)* if r is a RE, (r) is a RE, and L((r))=L(r) if r is a RE. E.g., ID=(a b Z) (a b Z 0 9)* 2013/10/20 Zhang Zhizheng, Southeast University 8

Basic Principles IV Finite State Automata I Deterministic FA (DFA) DFA is a quintuple, M(S,,move,s 0,F) S: a set of states : the input symbol alphabet move: a transition function, mapping from S to S, move(s,a)=s s 0 : the start state, s 0 S F: a set of states F distinguished as accepting states, F S 2013/10/20 Zhang Zhizheng, Southeast University 9

Basic Principles IV Finite State Automata II e.g. M=({0,1,2,3},{a,b},move,0,{3}) Move: move(0,a)=1 m(0,b)=2 m(1,a)=3 m(1,b)=2 m(2,a)=1 m(2,b)=3 m(3,a)=3 m(3,b)=3 state input a 0 1 2 1 3 2 2 1 3 3 3 3 b 2013/10/20 Zhang Zhizheng, Southeast University 10 a 1 a 0 b a 3 b b 2 Transition graph a b

Basic Principles IV Finite State Automata III Given a DFA, the language it define is a set of strings recognized by the following equipment. 2013/10/20 Zhang Zhizheng, Southeast University 11

Note: A FA accepts an input string x if and only if there is some path in the transition graph from start state to some accepting state 12 2013/10/20 Zhang Zhizheng, Southeast University

Basic Principles IV Finite State Automata IV Please Construct a DFA M,which can accept the a, b, c strings which begin with a or b, or begin with c and contain at most one a. Please write a C function to implement the DFA. 2013/10/20 Zhang Zhizheng, Southeast University 13

c a b 0 1 b c a b c 2 a b c 3 GET() { State=0; While(1){ switch(state){ case 0: sym=nextchar() if sym==a b state=1; else if sym==c state=2; else return 0; case 1: sym=nextchar() if sym<>a b c return 1; case 2: sym=nextchar() if sym. case 3: } } } 2013/10/20 Zhang Zhizheng, Southeast University 14

Basic Principles IV Finite State Automata V Please Construct a DFA that can recognize ID, then Please write a C function to implement the DFA. 2013/10/20 Zhang Zhizheng, Southeast University 15

Example1 of DFA * retracting one position 2013/10/20 Zhang Zhizheng, Southeast University 16

Example2 of DFA 2013/10/20 Zhang Zhizheng, Southeast University 17

Example3 of DFA 2013/10/20 Zhang Zhizheng, Southeast University 18

Example4 of DFA 2013/10/20 Zhang Zhizheng, Southeast University 19

Example5 of DFA 2013/10/20 Zhang Zhizheng, Southeast University 20

To know more details and tricks in token recognization, please read deeply in 3.4 2013/10/20 Zhang Zhizheng, Southeast University 21

Basic Principles IV Finite State Automata VI Non-deterministic FA (NFA) NFA is a quintuple, M(S,,move,s 0,F) S: a set of states : the input symbol alphabet move: a mapping from S ( ) to S, move(s,a)=2 S, 2 S S s 0 : the start state, s 0 S F: a set of states F distinguished as accepting states, F S 2013/10/20 Zhang Zhizheng, Southeast University 22

Basic Principles IV Finite State Automata VII E.g. An NFA M=({q 0,q 1 },{0,1},move,q 0,{q 1 }) input State 0 1 q 0 q 0 q 1 q 0 1 q 1 q 1 q 0, q 1 q 0 0 1 0 0 2013/10/20 Zhang Zhizheng, Southeast University 23

Basic Principles V RE&RG E.g., E.g, L={a i i 0} 1) If i=0 L 2) if i 1 a i = aa i-1 =aa j j 0 L al 3) The grammar is as following: L al 2013/10/20 Zhang Zhizheng, Southeast University 24

Basic Principles VI RG&FA I For each regular grammar G=(V N,V T,P,S), there is an FA M=(Q,,f,q0,Z), and L(G)=L(M). For each FA M, there is a right-linear grammar and a leftlinear grammar recognize the same language. L(M)=L(G R )=L(G L ) 2013/10/20 Zhang Zhizheng, Southeast University 25

Basic Principles VI RG&FA II E.g., C S 00 b 01 a a 10 b 11 B A S ac ba A ab bs B aa bc C as bb 2013/10/20 Zhang Zhizheng, Southeast University 26

Basic Principles VI RG&FA III See following Algorithm of conversion from each other. 2013/10/20 Zhang Zhizheng, Southeast University 27

Right-linear grammar to FA Input :G=(V N,V T,P,S) Output : FA M=(Q,,move,q 0,Z) Method : Consider each non-terminal symbol in G as a state, and add a new state T as an accepting state. Let Q=V N {T}, = V T, q 0 =S; if there is the production S, then Z={S,T}, else Z={T} ; 28 2013/10/20 Zhang Zhizheng, Southeast University

For each production, construct the function move. a) For the productions similar as A 1 aa 2, construct move(a 1,a)= A 2. b) For the productions similar as A 1 a, construct move(a 1,a)= T. c) For each a in, move(t,a)=, that means the accepting states do not recognize any terminal symbol. 29 2013/10/20 Zhang Zhizheng, Southeast University

E.g. A regular grammar G=({S,A,B},{a,b,c},P,S) P: S as ab B bb ba A ca c Construct a FA for the grammar G. Please Construct it by yourself firstly! 30 2013/10/20 Zhang Zhizheng, Southeast University

Answer: let M=(Q,,f,q 0,Z) 1) Add a state T, So Q={S,B,A,T}; ={a,b,c}; q 0 =S; Z={T}. 2) f: f(s,a)=s f(b,a)=b f(a,c)=a f(s,a)=b f(b,b)=a f(a,c)=t S a a c a b B A c T 31 2013/10/20 Zhang Zhizheng, Southeast University

FA to Right-linear grammar Input : M=(S,,f, s 0,Z) Output : Rg=(V N,V T,P,s 0 ) Method : If s 0 Z, then the Productions are; a) For the mapping f(a i,a)=a j in M, there is a production A i aa j ; b) If A j Z, then add a new production A i a, then we get A i a aa j ; 32 2013/10/20 Zhang Zhizheng, Southeast University

If s 0 Z, then we will get the following productions besides the productions we ve gotten based on the former rule: For the mapping f(s 0, )=s 0, construct new productions, s 0 s 0, and s 0 is the new starting state. 33 2013/10/20 Zhang Zhizheng, Southeast University

e.g. construct a right-linear grammar for the following DFA M=({A,B,C,D},{0,1},f,A,{B}) B 0 1 0 0 34 2013/10/20 Zhang Zhizheng, Southeast University A 1 D 0 1 Answer:Rg=({A,B,C,D},{0,1},P,A) A 0B 1D 0 B 1C 0D C 0B 1D 0 D 0D 1D L(Rg)=L(M)=0(10) * 1 C

Basic Principles VII RE&FA See the following Algorithm of conversion. 2013/10/20 Zhang Zhizheng, Southeast University 35

Algorithm Input. A regular expression r over an alphabet Output. An NFA N accepting L( r) 36 2013/10/20 Zhang Zhizheng, Southeast University

Rules 1. For, 1 2 2. For a in, 1 a 2 37 2013/10/20 Zhang Zhizheng, Southeast University

3. Rules for complex regular expressions 1 2 1 1 2 1 2 1 2 * 1 2 1 1 2 38 2013/10/20 Zhang Zhizheng, Southeast University

e.g. Let us construct N( r) for the regular expression r=(a b) * (aa bb)(a b) * x (a b) * (aa bb)(a b) y * (a b) * (aa bb) (a b) 1 2 * x y a b a b aa x 5 1 2 6 y bb x a 5 b 39 2013/10/20 Zhang Zhizheng, Southeast University a 3 a a 1 2 6 b b y 4 b

Advanced Topics Converting NFA to DFA Minimizing DFA Merging NFAs 2013/10/20 Zhang Zhizheng, Southeast University 40

Advanced Topics I Construct DFA from NFA Find all groups of states that can be distinguished by some input string. At beginning of the process, we assume two distinguished groups of states: the group of non-accepting states and the group of accepting states. Then we use the method of partition of equivalent class on input string to partition the existed groups into smaller groups. 2013/10/20 Zhang Zhizheng, Southeast University 41

Advanced Topics II Minimizing DFA I ---Idea Find all groups of states that can be distinguished by some input string. At beginning of the process, we assume two distinguished groups of states: the group of non-accepting states and the group of accepting states. Then we use the method of partition of equivalent class on input string to partition the existed groups into smaller groups. 2013/10/20 Zhang Zhizheng, Southeast University 42

The idea of conversion algorithm Subset construction: The following state set of a state in a NFA is thought of as a following STATE of the state in the converted DFA 43 2013/10/20 Zhang Zhizheng, Southeast University

Obtain -closure(t) T S (1) -closure(t) definition A set of NFA states reachable from NFA state s in T on -transitions alone x a a 3 a a 5 1 2 6 b b y b 4 b -closure({x})=? 44 2013/10/20 Zhang Zhizheng, Southeast University

(2) -closure(t) algorithm push all states in T onto stack; initialize -closure(t) to T; while stack is not empty do { pop the top element of the stack into t; for each state u with an edge from t to u labeled do { if u is not in -closure(t) { add u to -closure(t) push u into stack}}} 45 2013/10/20 Zhang Zhizheng, Southeast University

Conversion algorithm Input. An NFA N=(S,,move,S 0,Z) Output. A DFA D= (Q,,,I 0,F), accepting the same language 46 2013/10/20 Zhang Zhizheng, Southeast University

(1)I 0 = -closure(s 0 ), I 0 Q (2)For each I i, I i Q, let I t = -closure(move(i i,a)) if I t Q, then put I t into Q (3)Repeat step (2), until there is no new state to put into Q (4)Let F={I I Q, 且 I Z <> } 47 2013/10/20 Zhang Zhizheng, Southeast University

e.g. x a a 3 a a 5 1 2 6 b b y b 4 b I I 0 ={x,5,1} I 1 ={5,3,1} I 2 ={5,4,1} I 3 ={5,3,2,1,6,y} I 4 ={5,4,1,2,6,y} I 5 ={5,1,4,6,y} I 6 ={5,3,1,6,y} a I 1 ={5,3,1} I 3 ={5,3,2,1,6,y} I 1 ={5,3,1} I 3 ={5,3,2,1,6,y} I 6 ={5,3,1,6,y} I 6 ={5,3,1,6,y} I 3 ={5,3,2,1,6,y} b I 2 ={5,4,1} I 2 ={5,4,1} I 4 ={5,4,1,2,6,y} I 5 ={5,1,4,6,y} I 4 ={5,4,1,2,6,y} I 4 ={5,4,1,2,6,y} I 5 ={5,1,4,6,y} 48 2013/10/20 Zhang Zhizheng, Southeast University

I a b I 0 I 1 I 2 I 1 I 3 I 2 I 2 I 1 I 4 I 3 I 3 I 5 I 4 I 6 I 4 I 5 I 6 I 4 I 6 I 3 I 5 DFA is I 1 a b a I 0 b I 2 a b a b I 3 a b b a I 5 I 4 I 6 b 49 2013/10/20 Zhang Zhizheng, Southeast University

Notes: 1)Both DFA and NFA can recognize precisely the regular sets; 2)DFA can lead to faster? recognizers 3)DFA can be much bigger than an equivalent NFA 50 2013/10/20 Zhang Zhizheng, Southeast University

Advanced Topics II Minimizing DFA II Algorithm --Input. A DFA M={S,,move, s 0,F} --Output. A DFA M accepting the same language as M and having as few states as possible. 51 2013/10/20 Zhang Zhizheng, Southeast University

Step 1. Construct an initial partition of the set of states with two groups: the accepting states F and the non-accepting states S-F. 0 ={I 01,I 02 } 52 2013/10/20 Zhang Zhizheng, Southeast University

Step 2. For each group I of i,partition I into subgroups such that two states s and t of I are in the same subgroup if and only if for all input symbols a, states s and t have transitions on a to states in the same group of i ; replace I in i+1_ by the set of subgroups formed. 53 2013/10/20 Zhang Zhizheng, Southeast University

Step 3. If i+1 = i,let final = i+1 and continue with step (4). Otherwise,repeat step (2) with i+1 Step 4. Choose one state in each group of the partition final as the representative for that group. The representatives will be the states of the reduced DFA M. Let s and t be representative states for s s and t s group respectively, and suppose on input a there is a transition of M from s to t. Then M has a transition from s to t on a. 54 2013/10/20 Zhang Zhizheng, Southeast University

Step 5. If M has a dead state(a state that is not accepting and that has transitions to itself on all input symbols),then remove it. Also remove any states not reachable from the start state. 55 2013/10/20 Zhang Zhizheng, Southeast University

Notes: The meaning that string w distinguishes state s from state t is that by starting with the DFA M in state s and feeding it input w, we end up in an accepting state, but starting in state t and feeding it input w, we end up in a non-accepting state, or vice versa. 56 2013/10/20 Zhang Zhizheng, Southeast University

E.g. Minimize the following DFA. a a b 1 3 a b 0 b a a b 2 b a 5 b 4 a b 6 57 2013/10/20 Zhang Zhizheng, Southeast University

1. Initialization: 0 ={{0,1,2},{3,4,5,6}} 2.1 For Non-accepting states in 0 : a: move({0,2},a)={1} ; move({1},a)={3}. 1,3 do not in the same subgroup of 0. So, 1`={{1},{0,2},{3,4,5,6}} b: move({0},b)={2}; move({2},b)={5}. 2,5 do not in the same subgroup of 1. So, 1``={{1},{0},{2},{3,4,5,6}} 58 2013/10/20 Zhang Zhizheng, Southeast University

2.2 For accepting states in 0 : a: move({3,4,5,6},a)={3,6}, which is the subset of {3,4,5,6} in 1 b: move({3,4,5,6},b)={4,5}, which is the subset of {3,4,5,6} in 1 So, 1 ={{1},{0},{2},{3,4,5,6}}. 3.Apply the step (2) again to 1,and get 2. 2 ={{1},{0},{2},{3,4,5,6}}= 1, So, final = 1 4. Let state 3 represent the state group {3,4,5,6} 59 2013/10/20 Zhang Zhizheng, Southeast University

So, the minimized DFA is : 0 a 1 a a b a b b 3 2 b 60 2013/10/20 Zhang Zhizheng, Southeast University

Advanced Topics III Merging DFAs I Step 1. Add a new start state entering each start states of DFAs by Step 2. NFA DFA 2013/10/20 Zhang Zhizheng, Southeast University 61

Advanced Topics III Merging DFAs II Re1 a a 1 2 Re2 abb a b b 3 4 5 6 Re3 a*bb* b 7 8 62 2013/10/20 Zhang Zhizheng, Southeast University a b

Advanced Topics III Merging DFAs III a 1 2 X a b b 3 4 5 6 a b 7 8 b 63 2013/10/20 Zhang Zhizheng, Southeast University

Advanced Topics III Merging DFAs IV L(Re1) L(Re3) b 247 58 a a b L(Re2) X137 7 68 a b b b aac# abb# 64 2013/10/20 Zhang Zhizheng, Southeast University 8 L(Re3)

Implementation Manual Automatic Approach by LEX 2013/10/20 Zhang Zhizheng, Southeast University 65

Implementation I Manual Step 1. Designing REs Step 2. Constructing NFA for each RE Step 3. Merging NFAs Step 4. Constructing DFA Step 5. Minimize DFA Step 6. Implementing DFA 2013/10/20 Zhang Zhizheng, Southeast University 66

Implementation II Automatic Approach by LEX Please See 3.5 2013/10/20 Zhang Zhizheng, Southeast University 67

Assignments Written CH3 Exercises Programming Implementation of a simple LEX (100points) Input REs for tokes. Output a scanner. Manual implementation of a Scanner of subset of C (50 points) 2013/10/20 Zhang Zhizheng, Southeast University 68