# Regular Expressions. Languages. Recall. A language is a set of strings made up of symbols from a given alphabet. Computer Science Theory 2

Save this PDF as:

Size: px
Start display at page:

Download "Regular Expressions. Languages. Recall. A language is a set of strings made up of symbols from a given alphabet. Computer Science Theory 2"

## Transcription

1 Regular Expressions Languages Recall. A language is a set of strings made up of symbols from a given alphabet. Computer Science Theory 2 1

2 String Recognition Machine Given a string and a definition of a language (set of strings), is the string a member of the language? Input string Language recognition machine YES, string is in Language NO, string is not in Language Computer Science Theory 3 Language Classes We will be looking at classes of languages: Each class will have its own means for describing the language Each class will have its own machine model for string recognition Languages and machines get more complex as we move forward in the course. Computer Science Theory 4 2

3 Languages A language is a set of strings. A class of languages is nothing more than a set of languages Computer Science Theory 5 Regular Languages Today we start looking at our first class of languages: Regular languages Means of defining: Regular Expressions Machine for accepting: Finite Automata We ll be studying different aspects of regular languages until the midterm. Computer Science Theory 6 3

4 Specifying Languages Recall: how do we specify languages? If language is finite, you can list all of its strings. L = {a, aa, aba, aca} Descriptive: L = {x n a (x) = n b (x)} Using basic Language operations L= {aa, ab} * {b}{bb} * Regular languages are described using this last method Computer Science Theory 7 Regular Languages A regular language over Σ is a language that can be expressed using only the set operations of Union Concatenation Kleene Star Computer Science Theory 8 4

5 Kleene Star Operation The set of strings that can be obtained by concatenating any number of elements of a language L is called the Kleene Star, L * L * = U i= 0 i L = L L L L 3 L Note that since, L * contains L 0, Λ is an element of L * Computer Science Theory 9 Regular Expressions Regular expressions are the mechanism by which regular languages are described: Take the set operation definition of the language and: Replace with + Replace {} with () And you have a regular expression Computer Science Theory 10 5

6 Regular expressions {Λ} {011} {0,1} {0, 01} {110} * {0,1} (110) * (0+1) {10, 11, 01} * ( ) * Λ {0, 11} * ({11} * {101, Λ}) (0 + 11) * ((11) * Λ) Computer Science Theory 11 Regular Expression Recursive definition of regular languages / expressions over an alphabet, Σ : 1. is a regular language and its regular expression is 2. {Λ} is a regular language and Λ is its regular expression 3. For each a Σ, {a} is a regular language and its regular expression is a Computer Science Theory 12 6

7 Regular Expression 4. If L 1 and L 2 are regular languages with regular expressions r 1 and r 2 then -- L 1 L 2 is a regular language with regular expression (r 1 + r 2 ) -- L 1 L 2 is a regular language with regular expression (r 1 r 2 ) -- L 1* is a regular language with regular expression (r 1* ) Only languages obtainable by using rules 1-4 are regular languages. Computer Science Theory 13 Regular Expressions Some shorthand If we apply precedents to the operators, we can relax the full parenthesized definition: Kleene star has highest precedent Concatenation has mid precedent + has lowest precedent Thus a + b * c is the same as (a + ((b * )c)) (a + b) * is not the same as a + b * Computer Science Theory 14 7

8 Regular Expressions More shorthand Equating regular expressions. Two regular expressions are considered equal if they describe the same language 1 * 1 * = 1 * (a + b) * a + b * Computer Science Theory 15 Regular Expressions Even more shorthand Sometimes you might see in the book: r n where n indicates the number of concatenations of r (e.g. r 6 ) r + to indicate one or more concatenations of r. Note that this is only shorthand! r 6 and r + are not regular expressions. Computer Science Theory 16 8

9 Regular Expressions Important thing to remember A regular expression is not a language A regular expression is used to describe a language. It is incorrect to say that for a language L, L = (a + b + c) * But it s okay to say that L is described by (a + b + c) * Computer Science Theory 17 Examples of Regular Languages All finite languages are regular Can anyone tell why? Computer Science Theory 18 9

10 Examples of Regular Languages All finite languages are regular A finite language L can be expressed as the union of languages each with one string corresponding to a string in L Example: L = {a, aa, aba, aca} L = {a} {aa} {aba} {aca} Regular expression: (a + aa + aba + abc) Computer Science Theory 19 Examples of Regular Languages L = {x {0,1} * x is even} Any string of even length can be obtained by concatenating strings length 2. Any concatenation of strings of length 2 will be even L = {00, 01, 10, 11} * Regular expressions describing L: ( ) * ((0 + 1)(0 + 1)) * Computer Science Theory 20 10

11 Examples of Regular Languages L = {x {0,1} * x does not end in 01 } If x does not end in 01, then either x < 2 or x ends in 00, 10, or 11 A regular expression that describes L is: Λ (0 + 1) * ( ) Computer Science Theory 21 Examples of Regular Languages L = {x {0,1} * x contains an odd number of 0s } Express x = yz y is a string of the form y=1 i 01 j In z, there must be an even number of additional 0s or z = (01 k 01 m ) * x can be described by (1 * 01 * )(01 * 01 * ) * Computer Science Theory 22 11

12 Practical uses for regular expressions grep Global (search for) Regular Expressions and Print Finds patterns of characters in a text file. grep man foo.txt grep [ab]*c[de]? foo.txt Computer Science Theory 23 Practical uses for regular expressions How a compiler works Source file lexer Stream parser Parse of tokens codegen Tree Object code Computer Science Theory 24 12

13 Practical uses for regular expressions How a compiler works The Lexical Analyzer (lexer) reads source code and generates a stream of tokens What is a token? Identifier Keyword Number Operator Punctuation Computer Science Theory 25 Practical uses for regular expressions How a compiler works Tokens can be described using regular expressions! Computer Science Theory 26 13

14 Examples of Regular Languages L = set of valid C keywords This is a finite set L can be described by if + then + else + while + do + goto + break + switch + Computer Science Theory 27 Examples of Regular Languages L = set of valid C identifiers A valid C identifier begins with a letter or _ A valid C identifier contains letters, numbers, and _ If we let: l = {a, b,, z, A, B,, Z} d = {1, 2,, 9, 0} Then a regular expression for L: (l + _)(l + d + _) * Computer Science Theory 28 14

15 Practical uses for regular expressions lex Program that will create a lexical analyzer. Input: set of valid tokens Tokens are given by regular expressions. Computer Science Theory 29 Summary Regular languages can be expressed using only the set operations of union, concatenation, Kleene Star. Regular languages Means of describing: Regular Expression Machine for accepting: Finite Automata Practical uses Text search (grep) Compilers / Lexical Analysis (lex) Computer Science Theory 30 15

### Definition: String concatenation. Definition: String. Definition: Language (cont.) Definition: Language

CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata Introduction That s it for the basics of Ruby If you need other material for your project, come to office hours or

### Lexical Analysis. Scanners, Regular expressions, and Automata. cs4713 1

Lexical Analysis Scanners, Regular expressions, and Automata cs4713 1 Phases of compilation Compilers Read input program optimization translate into machine code front end mid end back end Lexical analysis

### Automata Theory and Languages

Automata Theory and Languages SITE : http://www.info.univ-tours.fr/ mirian/ Automata Theory, Languages and Computation - Mírian Halfeld-Ferrari p. 1/1 Introduction to Automata Theory Automata theory :

### Compiler Construction

Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation

### CS F-02 Formal Languages 1

CS411 2015F-02 Formal Languages 1 02-0: Alphabets & Strings An alphabetσis a finite set of symbols Σ 1 = {a, b,..., z} Σ 2 = {0, 1} A string is a finite sequence of symbols from an alphabet fire, truck

### Context-Free Grammars

Context-Free Grammars Describing Languages We've seen two models for the regular languages: Automata accept precisely the strings in the language. Regular expressions describe precisely the strings in

### Computer Science Theory. From the course description:

Computer Science Theory Goals of Course From the course description: Introduction to the theory of computation covering regular, context-free and computable (recursive) languages with finite state machines,

### CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

CSC45 AUTOMATA 2. Finite Automata: Examples and Definitions Finite Automata: Examples and Definitions A finite automaton is a simple type of computer. Itsoutputislimitedto yes to or no. It has very primitive

### Reading 13 : Finite State Automata and Regular Expressions

CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

### Context Free and Non Context Free Languages

Context Free and Non Context Free Languages Part I: Pumping Theorem for Context Free Languages Context Free Languages and Push Down Automata Theorems For Every Context Free Grammar there Exists an Equivalent

### C H A P T E R Regular Expressions regular expression

7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

### CSCI-GA Compiler Construction Lecture 4: Lexical Analysis I. Mohamed Zahran (aka Z)

CSCI-GA.2130-001 Compiler Construction Lecture 4: Lexical Analysis I Mohamed Zahran (aka Z) mzahran@cs.nyu.edu Role of the Lexical Analyzer Remove comments and white spaces (aka scanning) Macros expansion

### Chapter 2. Finite Automata. 2.1 The Basic Model

Chapter 2 Finite Automata 2.1 The Basic Model Finite automata model very simple computational devices or processes. These devices have a constant amount of memory and process their input in an online manner.

### the lemma. Keep in mind the following facts about regular languages:

CPS 2: Discrete Mathematics Instructor: Bruce Maggs Assignment Due: Wednesday September 2, 27 A Tool for Proving Irregularity (25 points) When proving that a language isn t regular, a tool that is often

### Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

### Programming Language Syntax

Programming Language Syntax Natural language vs. programming language No ambiguity allowed in programming languages in form (syntax) and meaning (semantics) Thus, programming language specifications use

### Deterministic Push-Down Store Automata

Deterministic Push-Down tore Automata 1 Context-Free Languages A B C D... A w 0 w 1 D...E The languagea n b n : a b ab 2 Finite-tate Automata 3 Pushdown Automata Pushdown automata (pda s) is an fsa with

### Automata and Formal Languages

Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

### Finite Automata and Formal Languages

Finite Automata and Formal Languages TMV026/DIT321 LP4 2011 Lecture 14 May 19th 2011 Overview of today s lecture: Turing Machines Push-down Automata Overview of the Course Undecidable and Intractable Problems

### CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions Theory of Formal Languages In the English language, we distinguish between three different identities: letter, word, sentence.

### Compiler I: Syntax Analysis Human Thought

Course map Compiler I: Syntax Analysis Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy Translator Chapters 7-8 Assembly

### Regular Languages and Finite State Machines

Regular Languages and Finite State Machines Plan for the Day: Mathematical preliminaries - some review One application formal definition of finite automata Examples 1 Sets A set is an unordered collection

### Motivation. Automata = abstract computing devices. Turing studied Turing Machines (= computers) before there were any real computers

Motivation Automata = abstract computing devices Turing studied Turing Machines (= computers) before there were any real computers We will also look at simpler devices than Turing machines (Finite State

### Please note that there is more than one way to answer most of these questions. The following only represents a sample solution.

HOMEWORK THREE SOLUTION CSE 355 DUE: 10 MARCH 2011 Please note that there is more than one way to answer most of these questions. The following only represents a sample solution. (1) 2.4 and 2.5 (b),(c),(e),(f):

### Monday, August 27, 12. Scanners

Scanners Scanners Sometimes called lexers Recall: scanners break input stream up into a set of tokens Identifiers, reserved words, literals, etc. What do we need to know? How do we define tokens? How can

### CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

CMPSCI 250: Introduction to Computation Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 Regular Expressions and Their Languages Alphabets, Strings and Languages

### Plan for this class. Welcome to Introduction to CS Theory. Logistics. Logistics. Logistics. Logistics. Logistics.

Plan for this class Welcome to 4003-380 Introduction to CS Theory Joe Geigel Syllabus & Ground Rules Student Info Forms / Attendance What is this Course About ------ break --------- Discrete Math Review

### Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Master s Degree Course in Computer Engineering Formal Languages FORMAL LANGUAGES AND COMPILERS Lexical analysis Floriano Scioscia 1 Introductive terminological distinction Lexical string or lexeme = meaningful

### 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

### Scanner. tokens scanner parser IR. source code. errors

Scanner source code tokens scanner parser IR errors maps characters into tokens the basic unit of syntax x = x + y; becomes = + ; character string value for a token is a lexeme

### Compilers Lexical Analysis

Compilers Lexical Analysis SITE : http://www.info.univ-tours.fr/ mirian/ TLC - Mírian Halfeld-Ferrari p. 1/3 The Role of the Lexical Analyzer The first phase of a compiler. Lexical analysis : process of

### Programming Assignment II Due Date: See online CISC 672 schedule Individual Assignment

Programming Assignment II Due Date: See online CISC 672 schedule Individual Assignment 1 Overview Programming assignments II V will direct you to design and build a compiler for Cool. Each assignment will

### Regular Expressions in JLex

Regular Expressions in JLex To define a token in JLex, the user to associates a regular expression with commands coded in Java. When input characters that match a regular expression are read, the corresponding

### Quick Look at Using Bison Top-Down Parsers

Syntax Analysis Part II Quick Look at Using Bison Top-Down Parsers EECS 483 Lecture 5 University of Michigan Wednesday, September 20, 2006 Reading/Announcements Reading: Section 4.4 (top-down parsing)

### Automata Theory CS F-15 Undecidiability

Automata Theory CS411-2015F-15 Undecidiability David Galles Department of Computer Science University of San Francisco 15-0: Universal TM Turing Machines are Hard Wired Addition machine only adds 0 n 1

### COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing

### Lecture 18 Regular Expressions

Lecture 18 Regular Expressions Many of today s web applications require matching patterns in a text document to look for specific information. A good example is parsing a html file to extract tags

### University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005

University of Toronto Department of Electrical and Computer Engineering Midterm Examination CSC467 Compilers and Interpreters Fall Semester, 2005 Time and date: TBA Location: TBA Print your name and ID

### Automata and Languages

Automata and Languages Computational Models: An idealized mathematical model of a computer. A computational model may be accurate in some ways but not in others. We shall be defining increasingly powerful

### 03 - Lexical Analysis

03 - Lexical Analysis First, let s see a simplified overview of the compilation process: source code file (sequence of char) Step 2: parsing (syntax analysis) arse Tree Step 1: scanning (lexical analysis)

### Flex/Bison Tutorial. Aaron Myles Landwehr aron+ta@udel.edu CAPSL 2/17/2012

Flex/Bison Tutorial Aaron Myles Landwehr aron+ta@udel.edu 1 GENERAL COMPILER OVERVIEW 2 Compiler Overview Frontend Middle-end Backend Lexer / Scanner Parser Semantic Analyzer Optimizers Code Generator

### CS 164 Programming Languages and Compilers Handout 8. Midterm I

Mterm I Please read all instructions (including these) carefully. There are six questions on the exam, each worth between 15 and 30 points. You have 3 hours to work on the exam. The exam is closed book,

### FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION REDUCIBILITY ( LECTURE 16) SLIDES FOR 15-453 SPRING 2011 1 / 20 THE LANDSCAPE OF THE CHOMSKY HIERARCHY ( LECTURE 16) SLIDES FOR 15-453 SPRING 2011 2 / 20 REDUCIBILITY

### Lex The Idea Program Structure What Lex does Using Lex Lex Operators States in Lex

Lex The Idea Program Structure What Lex does Using Lex Lex Operators States in Lex The Lex Idea Lex is an implementation that uses an extension of RE notation as well as states and C/C++ Extending REs

### Programming Languages: Syntax Description and Parsing

Programming Languages: Syntax Description and Parsing Onur Tolga Şehitoğlu Computer Engineering,METU 27 May 2009 Outline Introduction Introduction Syntax: the form and structure of a program. Semantics:

### 2110711 THEORY of COMPUTATION

2110711 THEORY of COMPUTATION ATHASIT SURARERKS ELITE Athasit Surarerks ELITE Engineering Laboratory in Theoretical Enumerable System Computer Engineering, Faculty of Engineering Chulalongkorn University

### Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Automata Theory Automata theory is the study of abstract computing devices. A. M. Turing studied an abstract machine that had all the capabilities of today s computers. Turing s goal was to describe the

### CAs and Turing Machines. The Basis for Universal Computation

CAs and Turing Machines The Basis for Universal Computation What We Mean By Universal When we claim universal computation we mean that the CA is capable of calculating anything that could possibly be calculated*.

### Grammars & Parsing. Lecture 13 CS 2112 Fall 2014

Grammars & Parsing Lecture 13 CS 2112 Fall 2014 Motivation The cat ate the rat. The cat ate the rat slowly. The small cat ate the big rat slowly. The small cat ate the big rat on the mat slowly. The small

### TDDD65 Introduction to the Theory of Computation

TDDD65 Introduction to the Theory of Computation Lecture 3 Gustav Nordh Department of Computer and Information Science gustav.nordh@liu.se 2012-09-05 Outline Context-free Grammars Ambiguity Pumping Lemma

### Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples

Identifiers and Expressions CSE 130: Introduction to C Programming Spring 2005 Punctuation in C Statements are terminated with a ; Groups of statements are enclosed by curly braces: { and } Commas separate

### Introduction to Finite Automata

Introduction to Finite Automata Our First Machine Model Captain Pedro Ortiz Department of Computer Science United States Naval Academy SI-340 Theory of Computing Fall 2012 Captain Pedro Ortiz (US Naval

### Automata and Computability. Solutions to Exercises

Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

### CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

CS54 Turing Machines Turing Machine q 0 AI N P U T IN TAPE read write move read write move Language = {0} q This Turing machine recognizes the language {0} Turing Machines versus DFAs TM can both write

### Homework Four Solution CSE 355

Homework Four Solution CSE 355 Due: 29 March 2012 Please note that there is more than one way to answer most of these questions. The following only represents a sample solution. Problem 1: Linz 5.1.23

### NFA and regex. the Boolean algebra of languages. non-deterministic machines. regular expressions

NFA and regex cl the Boolean algebra of languages non-deterministic machines regular expressions Informatics School of Informatics, University of Edinburgh The intersection of two regular languages is

### Introduction to Automata Theory. Reading: Chapter 1

Introduction to Automata Theory Reading: Chapter 1 1 What is Automata Theory? Study of abstract computing devices, or machines Automaton = an abstract computing device Note: A device need not even be a

### CS 341 Homework 9 Languages That Are and Are Not Regular

CS 341 Homework 9 Languages That Are and Are Not Regular 1. Show that the following are not regular. (a) L = {ww R : w {a, b}*} (b) L = {ww : w {a, b}*} (c) L = {ww' : w {a, b}*}, where w' stands for w

### CS 4120 Introduction to Compilers

CS 4120 Introduction to Compilers Andrew Myers Cornell University Lecture 5: Top-down parsing 5 Feb 2016 Outline More on writing CFGs Top-down parsing LL(1) grammars Transforming a grammar into LL form

### Polynomial Expression

DETAILED SOLUTIONS AND CONCEPTS - POLYNOMIAL EXPRESSIONS Prepared by Ingrid Stewart, Ph.D., College of Southern Nevada Please Send Questions and Comments to ingrid.stewart@csn.edu. Thank you! PLEASE NOTE

### 3. Recurrence Recursive Definitions. To construct a recursively defined function:

3. RECURRENCE 10 3. Recurrence 3.1. Recursive Definitions. To construct a recursively defined function: 1. Initial Condition(s) (or basis): Prescribe initial value(s) of the function.. Recursion: Use a

### Compilers. Topic 4. The Symbol Table and Block Structure. Mick O Donnell: Alfonso Ortega:

Compilers Topic 4 and Block Structure Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.es Topic 1: 2 1 s (i) Motivation: Previously, we have seen how source code is analysed as

### COMP 356 Sample Midterm Exam I

COMP 356 Sample Midterm Exam I 1. (8 points) What are the relative advantages disadvantages of implementing a programming language with an interpreter as compared with implementing the language with a

### A Lex Tutorial. Victor Eijkhout. July 2004. 1 Introduction. 2 Structure of a lex file

A Lex Tutorial Victor Eijkhout July 2004 1 Introduction The unix utility lex parses a file of characters. It uses regular expression matching; typically it is used to tokenize the contents of the file.

### 5HFDOO &RPSLOHU 6WUXFWXUH

6FDQQLQJ 2XWOLQH 2. Scanning The basics Ad-hoc scanning FSM based techniques A Lexical Analysis tool - Lex (a scanner generator) 5HFDOO &RPSLOHU 6WUXFWXUH 6RXUFH &RGH /H[LFDO \$QDO\VLV6FDQQLQJ 6\QWD[ \$QDO\VLV3DUVLQJ

### Modeling Computation

Modeling Computation 11.1.1 Language and Grammars Natural Languages: English, French, German, Programming Languages: Pascal, C, Java, Grammar is used to generate sentences from basic words of the language

### A New Parser. Neil Mitchell. Neil Mitchell

A New Parser Neil Mitchell Neil Mitchell 2004 1 Disclaimer This is not something I have done as part of my PhD I have done it on my own I haven t researched other systems Its not finished Any claims may

### SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK (2110003) [F.Y.B.E.

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK Subject: Computer Programming and Utilization (2110003) [F.Y.B.E.: ALL BRANCHES] Unit 1

### Context free grammars and predictive parsing

Context free grammars and predictive parsing Programming Language Concepts and Implementation Fall 2012, Lecture 6 Context free grammars Next week: LR parsing Describing programming language syntax Ambiguities

### 5.1 Radical Notation and Rational Exponents

Section 5.1 Radical Notation and Rational Exponents 1 5.1 Radical Notation and Rational Exponents We now review how exponents can be used to describe not only powers (such as 5 2 and 2 3 ), but also roots

### Mathematical induction & Recursion

CS 441 Discrete Mathematics for CS Lecture 15 Mathematical induction & Recursion Milos Hauskrecht milos@cs.pitt.edu 5329 Sennott Square Proofs Basic proof methods: Direct, Indirect, Contradiction, By Cases,

### Lecture 7: Definite Clause Grammars

Lecture 7: Definite Clause Grammars Theory Introduce context free grammars and some related concepts Introduce definite clause grammars, the Prolog way of working with context free grammars (and other

### How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

How to make the computer understand? Fall 2005 Lecture 15: Putting it all together From parsing to code generation Write a program using a programming language Microprocessors talk in assembly language

### Basics of Compiler Design

Basics of Compiler Design Anniversary edition Torben Ægidius Mogensen DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF COPENHAGEN Published through lulu.com. c Torben Ægidius Mogensen 2000 2010 torbenm@diku.dk

### Fundamentele Informatica II

Fundamentele Informatica II Answer to selected exercises 1 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 Let L be a language. It is clear

### Sets and Subsets. Countable and Uncountable

Sets and Subsets Countable and Uncountable Reading Appendix A Section A.6.8 Pages 788-792 BIG IDEAS Themes 1. There exist functions that cannot be computed in Java or any other computer language. 2. There

### Programming Languages Third Edition

Programming Languages Third Edition Chapter 6 Syntax Objectives Understand the lexical structure of programming languages Understand context-free grammars and BNFs Become familiar with parse trees and

### Finite Automata and Regular Languages

CHAPTER 3 Finite Automata and Regular Languages 3. Introduction 3.. States and Automata A finite-state machine or finite automaton (the noun comes from the Greek; the singular is automaton, the Greek-derived

### Compilers I - Chapter 2: An introduction to syntax analysis (and a complete toy compiler)

Compilers I - Chapter 2: An introduction to syntax analysis (and a complete toy compiler) Lecturers: Part I: Paul Kelly (phjk@doc.ic.ac.uk) Office: room 423 Part II: Naranker Dulay (nd@doc.ic.ac.uk) Office:

### Nondeterministic Finite Automata

Chapter, Part 2 Nondeterministic Finite Automata CSC527, Chapter, Part 2 c 202 Mitsunori Ogihara Fundamental set operations Let A and B be two languages. In addition to union and intersection, we consider

### Computational Linguistics: Syntax I

Computational Linguistics: Syntax I Raffaella Bernardi KRDB, Free University of Bozen-Bolzano P.zza Domenicani, Room: 2.28, e-mail: bernardi@inf.unibz.it Contents 1 Syntax...................................................

### ( ) ( ) + ( ) ( ) ( ) ( ) ( ) = ( ) Page

Page 8.542.1 ( ) ( ) ( ) ( ) Page 8.542.2 ( ) ( ) Page 8.542.3 Λ Page 8.542.4 Page 8.542.5 Page 8.542.6 Page 8.542.7 ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) Page 8.542.8 ( ) ( ) Page 8.542.9 ( ) ( ) Page 8.542.10

### Computability. COMP2600 Formal Methods for Software Engineering. Katya Lebedeva. Australian National University Semester 2, 2016

Computability COMP2600 Formal Methods for Software Engineering Katya Lebedeva Australian National University Semester 2, 2016 Slides created by Katya Lebedeva COMP 2600 Turing Machines 1 Definition of

### Computing Functions with Turing Machines

CS 30 - Lecture 20 Combining Turing Machines and Turing s Thesis Fall 2008 Review Languages and Grammars Alphabets, strings, languages Regular Languages Deterministic Finite and Nondeterministic Automata

### Programming Project 1: Lexical Analyzer (Scanner)

CS 331 Compilers Fall 2015 Programming Project 1: Lexical Analyzer (Scanner) Prof. Szajda Due Tuesday, September 15, 11:59:59 pm 1 Overview of the Programming Project Programming projects I IV will direct

### Programming Fundamental. Instructor Name: Lecture-2

Programming Fundamental Instructor Name: Lecture-2 Today s Lecture What is Programming? First C++ Program Programming Errors Variables in C++ Primitive Data Types in C++ Operators in C++ Operators Precedence

### PP2: Syntax Analysis

PP2: Syntax Analysis Date Due: 09/20/2016 11:59pm 1 Goal In this programming project, you will extend your Decaf compiler to handle the syntax analysis phase, the second task of the front-end, by using

### Programming Languages

Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately

### Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Pushdown Automata In the last section we found that restricting the computational power of computing devices produced solvable decision problems for the class of sets accepted by finite automata. But along

### MIT Aurangabad FE Computer Engineering

MIT Aurangabad FE Computer Engineering Unit 1: Introduction to C 1. The symbol # is called a. Header file c. include b. Preprocessor d. semicolon 2. The size of integer number is limited to a. -32768 to

### Understanding Regular Expressions, Special Characters, and Patterns

APPENDIX D Understanding Regular Expressions, Special Characters, and Patterns This appendix describes the regular expressions, special or wildcard characters, and patterns that can be used with filters

### Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety

### MATH REVIEW KIT. Reproduced with permission of the Certified General Accountant Association of Canada.

MATH REVIEW KIT Reproduced with permission of the Certified General Accountant Association of Canada. Copyright 00 by the Certified General Accountant Association of Canada and the UBC Real Estate Division.

### Induction and Recursion

Induction and Recursion Winter 2010 Mathematical Induction Mathematical Induction Principle (of Mathematical Induction) Suppose you want to prove that a statement about an integer n is true for every positive

### Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac.

Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free