COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.

Slides:



Advertisements
Similar presentations
Specifying Languages Our aim is to be able to specify languages for use in the computer. The sketch of the FSA is easy for us to understand, but difficult.
Advertisements

COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
ISBN Regular expressions Mastering Regular Expressions by Jeffrey E. F. Friedl –(on reserve.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Strings and Languages Operations
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Regular expressions Mastering Regular Expressions by Jeffrey E. F. Friedl Linux editors and commands (e.g.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Regular Expressions & Automata Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Overview Regular expressions Notation Patterns Java support.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Filters using Regular Expressions grep: Searching a Pattern.
CPSC 388 – Compiler Design and Construction
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory III Languages And Regular Expressions Construction of FA’s for given languages.
Regular Language & Expressions. Regular Language A regular language is one that a finite state machine (fsm) will accept. ‘Alphabet’: {a, b} ‘Rules’:
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Description of programming languages 1 Using regular expressions and context free grammars.
1 Lexical Analysis - An Introduction Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at.
Lecture # 1 (Automata Theory)
1 Welcome to ! Theory Of Automata. 2 Text and Reference Material 1.Introduction to Computer Theory, by Daniel I. Cohen, John Wiley and Sons, Inc., 1991,
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 7 1.
Formal Methods in SE Theory of Automata Qasiar Javaid Assistant Professor Lecture # 06.
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
Lecture # 3 Chapter #3: Lexical Analysis. Role of Lexical Analyzer It is the first phase of compiler Its main task is to read the input characters and.
1 Language Definitions Lecture # 2. Defining Languages The languages can be defined in different ways, such as Descriptive definition, Recursive definition,
Regular Expression Mohsen Mollanoori. What is RegeX ?  “ A notation to describe regular languages. ”  “ Not necessarily (and not usually) regular ”
Lecture # 3 Regular Expressions 1. Introduction In computing, a regular expression provides a concise and flexible means to "match" (specify and recognize)
CSE 311 Foundations of Computing I Lecture 17 Structural Induction: Regular Expressions, Regular Languages Autumn 2011 CSE 3111.
COMP 3438 – Part II - Lecture 2: Lexical Analysis (I) Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ. 1.
Lexical Analysis I Specifying Tokens Lecture 2 CS 4318/5531 Spring 2010 Apan Qasem Texas State University *some slides adopted from Cooper and Torczon.
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 8.
L ECTURE 3 Chapter 4 Regular Expressions. I MPORTANT T ERMS Regular Expressions Regular Languages Finite Representations.
What is a language? An alphabet is a well defined set of characters. The character ∑ is typically used to represent an alphabet. A string : a finite.
Recursive Definitions & Regular Expressions (RE)
Regular Expressions Theory and Practice Jeff Schoolcraft MDCFUG 12/13/2005.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
Sys Prog & Scrip - Heriot Watt Univ 1 Systems Programming & Scripting Lecture 12: Introduction to Scripting & Regular Expressions.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Lecture 02: Theory of Automata:08 Theory of Automata.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
CSC312 Automata Theory Lecture # 3 Languages-II. Formal Language A formal language is a set of words—that is, strings of symbols drawn from a common alphabet.
Recursive Definations Regular Expressions Ch # 4 by Cohen
Lecture # 4.
Lecture 2 Theory of AUTOMATA
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
1 Chapter 3 Regular Languages.  2 3.1: Regular Expressions (1)   Regular Expression (RE):   E is a regular expression over  if E is one of:
Week 13 - Wednesday.  What did we talk about last time?  Exam 3  Before review:  Graphing functions  Rules for manipulating asymptotic bounds  Computing.
Lecture 03: Theory of Automata:2014 Asif Nawaz Theory of Automata.
CSE 311 Foundations of Computing I Lecture 18 Recursive Definitions: Context-Free Grammars and Languages Autumn 2011 CSE 3111.
Theory of Computation Lecture #
Implementation of Haskell Modules for Automata and Sticker Systems
Language Theory Module 03.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Theory of Automata.
COP4620 – Programming Language Translators Dr. Manuel E. Bermudez
Specifying Languages Our aim is to be able to specify languages for use in the computer. The sketch of the FSA is easy for us to understand, but difficult.
Compiler Construction
1.5 Regular Expressions (REs)
CSC312 Automata Theory Lecture # 5 Chapter # 4 Cont…
CSC312 Automata Theory Lecture # 3 Languages-II.
Welcome to ! Theory Of Automata Irum Feroz
Presentation transcript:

COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University pursuant to Part VB of the Copyright Act 1968 (the Act). The material in this communication may be subject to copyright under the Act. Any further reproduction or communication of this material by you may be the subject of copyright protection under the Act. Do not remove this notice.

Regular Languages CSE2303 Formal Methods I Lecture 2

Overview Some Problems Applications of Regular Expressions Simple Languages Regular Expressions Regular Languages

Some Problems Find all the files which contain old subject course codes. Find all the addresses in a set of mail files. Change the way comments in C programs are formatted in your web pages. Using web server access files, record how many times each page is visited, and how many times each link is used.

Applications of Regular Expressions Useful way to describe simple patterns. Used in several programs: –Editors: vi, emacs –Filters: egrep, sed, gawk –Programming languages: flex, bison, Perl

Filters egrep –A program which searches a file for a pattern described by a regular expression. sed –A program which enables stream editing of files. awk, nawk, gawk –Programming languages which enable text manipulation.

Programming Languages flex, lex –Languages used to generate lexical analysers. bison, yacc –Languages used to generate compilers. Perl –A powerful scripting language, developed in the 1980’s by Larry Wall.

Small Languages No words.  Consisting only of the empty word. {}{} Consisting only of a single word, say abbab. {abbab}

Alternatives and Groupings Alternatives are indicated by +, e.g is a regular expression for: {1, 2, 3, 4, 5, 6, 7, 8, 9} Groupings are indicated by ( ), e.g. (ab + ba)(e + g) is a regular expression for: {abe, abg, bae, bag}

Finite Languages Consist of finite number of words. Eg. {abaaba, abbbba, abbaba} Regular Expression: abaaba + abbbba + abbaba alternatively, ab(aa + bb + ba)ba alternatively, ab(a + b)aba + abb(b + a)ba or

Kleene Star Zero or more times is indicated by * For example: a* represents { , a, aa, aaa, aaaa, …}

Some infinite languages Strings which start with a and whose remaining letters (if any) are b. {a, ab, abb, abbb, abbbb, …} Regular Expression ab* Zero or more *

Strings which are ba repeated zero, one, or more times  ba, baba, bababa, babababa, …} Regular Expression: (ba)* Zero or more *

(aa + bb)* = (aa + bb) 0 + (aa + bb) 1 + (aa + bb) 2 +… =  + (aa + bb) + (aa + bb) (aa + bb) +… represents: { , aa, bb, aaaa, aabb, bbaa, bbbb, aaaaaa, aaaabb, aabbaa,...} (aa + bb)* Zero or more *

Parse Tree (a +  )b* b* (a +  ) b  a a + 

Definition 1.  and  are regular expressions 2. All letters in the alphabet are regular expressions. 3. If R and S are regular expressions, then so are: (i) (R) (ii) RS (iii) R + S (iv) R*

Regular Language A language which can be described by a Regular Expression is called a Regular Language. If a word belongs to the language described by a regular expression, then we say it is matched by the regular expression.

EVEN-EVEN All the strings that contain an even number of a ’s and an even number of b ’s. {  aa, bb, aaaa, aabb, abab, abba, …} Regular Expression (aa + bb + (ab + ba)(aa + bb)*(ab +ba))*

Floating Point Number A one or more digits, which may begin with a minus sign (-), and which may contain a decimal point. E.g

Sequence of Digits One Digit Two Digits ( )( ) Three Digits ( )( ) ( ) One or more Digits ( )( )*

Sequence of Digits Digit D = ( ) Two Digits DD or D 2 Three Digits DDD or D 3 One or more Digits DD*

Numbers One Digit D = ( ) Positive Integers N = DD* e.g Integers Z = N + (-N) Floating Point Number F = Z + (Z.) + (.N) + (-.N) + (Z.N)

Other Notations R | S means R + S [0-9] means [a-z] means any letter a through z R + means RR* R? means  + R

Additional Reading Jeffrey E.F. Friedl, “Mastering Regular Expressions: Powerful Techniques for Perl and Other Tools”, O’Reilly, 1997.

Revision Preparation Read –Text Book: Chapter 5 Regular Expressions –Definition. –How to determine if a string matches a regular expression. –How to use them to define languages