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.

Slides:



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

CS 3240: Languages and Computation
Lexical Analysis. what is the main Task of the Lexical analyzer Read the input characters of the source program, group them into lexemes and produce the.
Kleene's Theorem We have defined the regular languages, using regular expressions, which are convenient to write down and use. We have also defined the.
Deterministic Finite Automata (DFA)
Lex -- a Lexical Analyzer Generator (by M.E. Lesk and Eric. Schmidt) –Given tokens specified as regular expressions, Lex automatically generates a routine.
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
Week 13 - Wednesday.  What did we talk about last time?  Exam 3  Before review:  Graphing functions  Rules for manipulating asymptotic bounds  Computing.
Winter 2007SEG2101 Chapter 81 Chapter 8 Lexical Analysis.
Lexical Analysis III Recognizing Tokens Lecture 4 CS 4318/5331 Apan Qasem Texas State University Spring 2015.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Regular expressions Sipser 1.3 (pages 63-76). CS 311 Fall Looks familiar…
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Topics Automata Theory Grammars and Languages Complexities
1 Regular Expressions/Languages Regular languages –Inductive definitions –Regular expressions syntax semantics Not covered in lecture.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
L ECTURE 2 Chapter 3 Recursive Definitions. R ECURSIVE D EFINITION It is method of defining sets.
Copyright © Cengage Learning. All rights reserved.
Chapter 2 Languages.
Finite-State Machines with No Output
1 Syntax Specification Regular Expressions. 2 Phases of Compilation.
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.
Introduction to Theory of Automata
Compiler Phases: Source program Lexical analyzer Syntax analyzer Semantic analyzer Machine-independent code improvement Target code generation Machine-specific.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
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.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
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.
1 Assignment #1 is due on Friday. Any questions?.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson.
1 Prove the following languages over Σ={0,1} are regular by giving regular expressions for them: 1. {w contains two or more 0’s} 2. {|w| = 3k for some.
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.
1 Module 14 Regular languages –Inductive definitions –Regular expressions syntax semantics.
1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a compiler PART II:
Review: Compiler Phases: Source program Lexical analyzer Syntax analyzer Semantic analyzer Intermediate code generator Code optimizer Code generator Symbol.
CHAPTER 1 Regular Languages
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
Specifying Languages Our aim is to be able to specify languages for use in the computer. The sketch of an FSA is easy for us to understand, but difficult.
Natural Language Processing Lecture 4 : Regular Expressions and Automata.
Brian Mitchell - Drexel University MCS680-FCS 1 Patterns, Automata & Regular Expressions int MSTWeight(int graph[][], int size)
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Finite Automata Chapter 1. Automatic Door Example Top View.
November 2003Computational Morphology III1 CSA405: Advanced Topics in NLP Xerox Notation.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Week 13 - Wednesday.  What did we talk about last time?  Exam 3  Before review:  Graphing functions  Rules for manipulating asymptotic bounds  Computing.
Unix RE’s Text Processing Lexical Analysis.   RE’s appear in many systems, often private software that needs a simple language to describe sequences.
CSE 311 Foundations of Computing I Lecture 18 Recursive Definitions: Context-Free Grammars and Languages Autumn 2011 CSE 3111.
1 Let S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 }. (a) List the elements of S for n= 1, 2, and 3. (b) Prove that the set S.
Page 1. 1)Let B n = { a k | where k is a multiple of n}. I.e. B 1 = { a k | where k is a multiple of 1} = { a k | k Є {0,1,2,3,…}} = {‘’, a, aa, aaa, aaaa,
Introduction to Automata Theory
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Formal Language & Automata Theory
Review: Compiler Phases:
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.
Specification of tokens using regular expressions
Compiler Construction
LECTURE # 07.
Lexical Analysis Uses formalism of Regular Languages
Presentation transcript:

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 to input to a computer. The formal description is unpleasant, and difficult to write. What we need is a simpler method of specifying languages - something we can write down in a line of text.

Regular Expressions (i) denotes { }, denotes {}, t denotes {t} for t T; (ii) if r and s are regular expressions denoting languages R and S, then (r + s) denoting R + S, (rs) denoting RS, and (r*) denoting R* are regular expressions; (iii) nothing else is a regular expression over T. Let T be an alphabet. A regular expression over T defines a language over T as follows: A language L over T is a regular language over T if there is a regular expression denoting it. Note: when writing regular expressions, we can omit most of the brackets. For example, we can write ((a)* + ((b)* + (c))*)((b) + (c)) as (a* + (b* + c)*)(b + c)

Regular Languages Theorem: If A and B are regular languages, then so are: A + B, AB and A* Notation: if T is an alphabet, then T also denotes the regular language consisting of strings over T of length 1. t n denotes ttt...t n times.

Regular Languages Examples: (i) aT* denotes the language consisting of all strings over T starting with a.. (ii) T*(a 2 + b 2 )T* denotes the set of all strings over T with a substring of aa or bb. (iii) 0+1(0+1)* denotes the set of all binary numbers. (iv) The set of all strings over {0,1} not containing two adjacent 0's is (1+01)*( +0)

Applications of Regular Expressions 1. Searching for strings of characters in UNIX in ex and other editors, and using grep and egrep. Note: ex and grep use restricted versions of regular expressions. Example: the ex command /a*[abc]/ means find any line containing a substring starting with any number of a's followed by an a, b, or c. 2. Lexical analysis, the initial phase in compiling, divides the source program into "tokens". The definition of how to divide up the source code is given by regular expressions.

Properties of Regular Languages Theorem: If A and B are regular languages, so are A B and A'. Theorem: Any finite language is regular.