{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter1Section3_F11

Chapter1Section3_F11 - 91.304 Foundations of(Theoretical...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
91.304 Foundations of (Th ti l) C t S i (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.3: Regular Expressions) David Martin d @ l d [email protected] with some modifications by Prof. Karen Daniels, Fall 2011 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by- 1 sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Regular expressions You might be familiar with these You might be familiar with these. Example: "^int .*\(.*\);" is a (flex format) regular expression that appears to match C function prototypes that return ints. In our treatment, a regular expression is a program that generates a language of matching strings when you "run it“. ll d f h We will use a very compact definition that simplifies things later. 2 Flex = Fast Lexical Analyzer Generator
Background image of page 2
Regular expressions Definition Let Σ be an alphabet not containing any of Definition. the special characters in this list: ε ) ( · We define the syntax of the (programming) language REX( Σ ), abbreviated as REX, inductively: Base cases 1. For all a Σ , a REX. In other words, each single character from Σ is a regular expression all by itself. 2 REX In other words the literal symbol is a regular 2. ε REX. In other words, the literal symbol ε expression. In this context it is not the empty string but rather the single-character name for the empty string. 3. ∅∈ REX. Similarly, the literal symbol is a regular expression. Notes : -REX is not defined in our textbook, but is helpful in continuing to build our diagram of languages 3 diagram of languages. -In our textbook, a represents language {a}, ε represents language { ε }.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Regular expressions D fi iti ti d Definition continued Induction cases 4 For all r r REX 4. 1 , 2 REX, ( r 1 r 2 ) REX also literal symbols variables 5. For all r 1 , r 2 REX, ( r 1 · r 2 ) REX also 4 Note: Later we remove dot, which is denoted by empty circle in textbook (later also removed).
Background image of page 4
Regular expressions Definition continued Induction cases continued 6. For all r REX, ( r * ) REX also Examples over Σ ={0,1} ε and 0 and 1 and (((1 · 0) · ( ε ∪∅ )) * ) εε is not a regular expression Remember, in the context of regular expressions, ε and are ordinary characters 5 Note: Textbook also defines R + = R R *, where R is a regular expression.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Semantics of regular expressions Definition We define the meaning of the Definition. language REX( Σ ) inductively using the L() operator so that L(r) denotes the l t d b f ll language generated by r as follows: Base cases 1. For all a Σ , L(a) = { a }. A single-character regular expression generates the corresponding single-character string. 2. L( ε ) = { ε }. The symbol for the empty string actually generates the empty string.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}