- 8
- 0
- 约7.44千字
- 约 45页
- 2017-04-04 发布于江苏
- 举报
4-RegularExp13
2009-2010第一学期 西安交通大学《编译原理》课件 Yinliang Zhao (赵银亮) Regular Expression and Language Yinliang Zhao Xi’an Jiaotong University 2013 String concatenation Operations on languages Example Operations on languages The star of L are all strings made up of zero or more chunks from L: Example: L1 = {01, 0}, L2 = {e, 1, 11, 111, …}. What is L1* and L2*? Example Example Combining languages We can construct languages by starting with simple ones, like {0}, {1} and combining them Regular expressions A regular expression over S is an expression formed using the following rules: The symbols ? and e are regular expressions Every a in S is a regular expression If R and S are regular expressions, so are R+S, RS and R*. Analyzing regular expressions Analyzing regular expressions Analyzing regular expressions Analyzing regular expressions Analyzing regular expressions Analyzing regular expressions Writing regular expressions Write a regular expression forall strings with two consecutive 0s. Writing regular expressions Write a regular expression forall strings that do not contain two consecutive 0s. Writing regular expressions Write a regular expression forall strings with an even number of 0s. Summary of Regular Expressions FA Regular Expressions To show that they are interchangeable, consider the following theorems: Theorem 3.4: For every DFA A there exists a regular expression R such that L(R)=L(A) Theorem 3.7: For every regular expression R there exists an ? -NFA E such that L(E)=L(R) Three ways of doing it They are all the same Road map Examples: regular expression → NFA Examples: regular expression → NFA Regular expressions A regular expression over S is an expression formed using the following rules: The symbols ? and e are regular expressions Every a in S is a regular expression If R and S are regular expressions, so are R+S, RS and R*. General method General method continued Road map Road map Road map Simplify the NFA First, we simplify the NFA so that It has exactly one
原创力文档

文档评论(0)