SlideShare a Scribd company logo
2
Most read
A sequence of symbols and characters
expressing a string or pattern to be
searched for within a longer piece of
text.
Regular Expressions
Regular Expressions
 we were able to describe identifiers by giving
names to sets of letters and digits and using the
language operators union, concatenation, and
closure. This process is so useful that a notation
called regular expressions has come into
common use for describing all the languages that
can be built from these operators applied to the
symbols of some alphabet. In this notation, if
letter- is established to stand for any letter or the
underscore, and digit- is established to stand for
any digit.
Regular Expressions
 The regular expressions are built recursively out
of smaller regular expres- sions, using the rules
described below. Each regular expression r
denotes a language L(r), which is also defined
recursively from the languages denoted by r's
subexpressions. Here are the rules that define
the regular expressions over some alphabet C
and the languages that those expressions
denote.
BASIS
 1. E is a regular expression, and L (E) is {E) , that
is, the language whose sole member is the empty
string.
 2. If a is a symbol in C, then a is a regular
expression, and L(a) = {a), that is, the language
with one string, of length one, with a in its one
position. Note that by convention, we use italics
for symbols, and boldface for their corresponding
regular expression.
INDUCTION
 1. (r) 1 (9) is a regular expression denoting the
language L(r) U L(s).
 2. (r) (s) is a regular expression denoting the
language L(r) L(s) .
 3. (r) * is a regular expression denoting (L (r)) * .
 4. (r) is a regular expression denoting L(r). This last
rule says that we can add additional pairs of
parentheses around expressions without changing the
language they denote
Precedence
 As defined, regular expressions often contain
unnecessary pairs of paren- theses. We may drop
certain pairs of parentheses if we adopt the
conventions that:
 a) The unary operator * has highest precedence
and is left associative.
 b) Concatenation has second highest precedence
and is left associative.
 c) I has lowest precedence and is left
associative.
Precedence
 Under these conventions, for example, we may
replace the regular expression (a) I ((b) * (c)) by
a/ b*c. Both expressions denote the set of strings
that are either a single a or are zero or more b's
followed by one c.
Let C = {a, b}.
 1. The regular expression a1 b denotes the
language {a, b}.
 2. (a1 b) (alb) denotes {aa, ab, ba, bb), the
language of all strings of length two over the
alphabet C. Another regular expression for the
same language is aalablbal bb.
 3. a* denotes the language consisting of all
strings of zero or more a's, that is, {E, a, aa, aaa,
. . . }.
Let C = {a, b}
 4. (alb)* denotes the set of all strings consisting of
zero or more instances of a or b, that is, all
strings of a's and b's: {e, a, b, aa, ab, ba, bb, aaa,
. . .}. Another regular expression for the same
language is (a*b*)*.
 5. ala*b denotes the language {a, b, ab,
aab,aaab,. . .), that is, the string a and all strings
consisting of zero or more a's and ending in b.

More Related Content

What's hot (20)

PPTX
Theory of automata and formal language
Rabia Khalid
 
PPTX
Context free grammar
Mohammad Ilyas Malik
 
PPTX
Syntax Analysis in Compiler Design
MAHASREEM
 
PPTX
Concurrency control
Soumyajit Dutta
 
PDF
Lecture 01 introduction to compiler
Iffat Anjum
 
PPT
Lecture 3,4
shah zeb
 
PPT
Parsing
khush_boo31
 
PPTX
Data structures and algorithms
Julie Iskander
 
PPT
Regular expressions-Theory of computation
Bipul Roy Bpl
 
PPTX
Semantics analysis
Bilalzafar22
 
PDF
Symbol table in compiler Design
Kuppusamy P
 
PPT
Lecture 3,4
shah zeb
 
PPT
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
PDF
Formal Languages and Automata Theory Unit 1
Srimatre K
 
PPTX
Compiler design syntax analysis
Richa Sharma
 
PPTX
Regular Expression
valuebound
 
PPTX
Intermediate code generator
sanchi29
 
PPTX
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 
PPTX
Graph coloring using backtracking
shashidharPapishetty
 
PPT
16. Concurrency Control in DBMS
koolkampus
 
Theory of automata and formal language
Rabia Khalid
 
Context free grammar
Mohammad Ilyas Malik
 
Syntax Analysis in Compiler Design
MAHASREEM
 
Concurrency control
Soumyajit Dutta
 
Lecture 01 introduction to compiler
Iffat Anjum
 
Lecture 3,4
shah zeb
 
Parsing
khush_boo31
 
Data structures and algorithms
Julie Iskander
 
Regular expressions-Theory of computation
Bipul Roy Bpl
 
Semantics analysis
Bilalzafar22
 
Symbol table in compiler Design
Kuppusamy P
 
Lecture 3,4
shah zeb
 
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Compiler design syntax analysis
Richa Sharma
 
Regular Expression
valuebound
 
Intermediate code generator
sanchi29
 
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 
Graph coloring using backtracking
shashidharPapishetty
 
16. Concurrency Control in DBMS
koolkampus
 

Similar to Regular Expression in Compiler design (20)

PDF
Regular Expression
A. S. M. Shafi
 
PPTX
Regular Expressions here we have .pptx
arslanahmadkhan295
 
PPTX
Regular expressions
Shiraz316
 
PPT
2_2Specification of Tokens.ppt
Ratnakar Mikkili
 
PDF
Chapter2CDpdf__2021_11_26_09_19_08.pdf
DrIsikoIsaac
 
PPTX
REGULAR EXPRESSION FOR NATURAL LANGUAGES
ssuser77162c
 
PPT
Chapter Two(1)
bolovv
 
PPTX
AUTOMATA AUTOMATA Automata4Chapter3.pptx
ArjayBalberan1
 
PPTX
Lexical analyzer
Princess Doll
 
PDF
Lecture: Regular Expressions and Regular Languages
Marina Santini
 
PPTX
L_2_apl.pptx
ReehaamMalikArain
 
PPTX
Mod 2_RegularExpressions.pptx
RaviAr5
 
PPTX
[Compilers23] Lexical Analysis – Scanning Part I.pptx
nourelhudaawny
 
PPT
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
PPT
3-regular_expressions_and_languages.ppt 1
gokikayal1998
 
PPT
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
PPT
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
PPT
3-regular_expressions_and_languages.ppt 1
gokikayal1998
 
PPT
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
DOCX
theory of computation notes for school of engineering
FIONACHATOLA
 
Regular Expression
A. S. M. Shafi
 
Regular Expressions here we have .pptx
arslanahmadkhan295
 
Regular expressions
Shiraz316
 
2_2Specification of Tokens.ppt
Ratnakar Mikkili
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
DrIsikoIsaac
 
REGULAR EXPRESSION FOR NATURAL LANGUAGES
ssuser77162c
 
Chapter Two(1)
bolovv
 
AUTOMATA AUTOMATA Automata4Chapter3.pptx
ArjayBalberan1
 
Lexical analyzer
Princess Doll
 
Lecture: Regular Expressions and Regular Languages
Marina Santini
 
L_2_apl.pptx
ReehaamMalikArain
 
Mod 2_RegularExpressions.pptx
RaviAr5
 
[Compilers23] Lexical Analysis – Scanning Part I.pptx
nourelhudaawny
 
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
3-regular_expressions_and_languages.ppt 1
gokikayal1998
 
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
3-regular_expressions_and_languages.ppt 1
gokikayal1998
 
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
theory of computation notes for school of engineering
FIONACHATOLA
 
Ad

More from Riazul Islam (7)

PPTX
Introduction wireless communication network
Riazul Islam
 
PDF
Data link control in computer networks
Riazul Islam
 
PDF
Optical communication in communication engineering
Riazul Islam
 
PDF
Channel capacity and coding in communication engineering
Riazul Islam
 
PPTX
Algorithm in computer science
Riazul Islam
 
PPTX
Finite Automata in compiler design
Riazul Islam
 
PPTX
Compiler Design LR parsing SLR ,LALR CLR
Riazul Islam
 
Introduction wireless communication network
Riazul Islam
 
Data link control in computer networks
Riazul Islam
 
Optical communication in communication engineering
Riazul Islam
 
Channel capacity and coding in communication engineering
Riazul Islam
 
Algorithm in computer science
Riazul Islam
 
Finite Automata in compiler design
Riazul Islam
 
Compiler Design LR parsing SLR ,LALR CLR
Riazul Islam
 
Ad

Recently uploaded (20)

PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 

Regular Expression in Compiler design

  • 1. A sequence of symbols and characters expressing a string or pattern to be searched for within a longer piece of text. Regular Expressions
  • 2. Regular Expressions  we were able to describe identifiers by giving names to sets of letters and digits and using the language operators union, concatenation, and closure. This process is so useful that a notation called regular expressions has come into common use for describing all the languages that can be built from these operators applied to the symbols of some alphabet. In this notation, if letter- is established to stand for any letter or the underscore, and digit- is established to stand for any digit.
  • 3. Regular Expressions  The regular expressions are built recursively out of smaller regular expres- sions, using the rules described below. Each regular expression r denotes a language L(r), which is also defined recursively from the languages denoted by r's subexpressions. Here are the rules that define the regular expressions over some alphabet C and the languages that those expressions denote.
  • 4. BASIS  1. E is a regular expression, and L (E) is {E) , that is, the language whose sole member is the empty string.  2. If a is a symbol in C, then a is a regular expression, and L(a) = {a), that is, the language with one string, of length one, with a in its one position. Note that by convention, we use italics for symbols, and boldface for their corresponding regular expression.
  • 5. INDUCTION  1. (r) 1 (9) is a regular expression denoting the language L(r) U L(s).  2. (r) (s) is a regular expression denoting the language L(r) L(s) .  3. (r) * is a regular expression denoting (L (r)) * .  4. (r) is a regular expression denoting L(r). This last rule says that we can add additional pairs of parentheses around expressions without changing the language they denote
  • 6. Precedence  As defined, regular expressions often contain unnecessary pairs of paren- theses. We may drop certain pairs of parentheses if we adopt the conventions that:  a) The unary operator * has highest precedence and is left associative.  b) Concatenation has second highest precedence and is left associative.  c) I has lowest precedence and is left associative.
  • 7. Precedence  Under these conventions, for example, we may replace the regular expression (a) I ((b) * (c)) by a/ b*c. Both expressions denote the set of strings that are either a single a or are zero or more b's followed by one c.
  • 8. Let C = {a, b}.  1. The regular expression a1 b denotes the language {a, b}.  2. (a1 b) (alb) denotes {aa, ab, ba, bb), the language of all strings of length two over the alphabet C. Another regular expression for the same language is aalablbal bb.  3. a* denotes the language consisting of all strings of zero or more a's, that is, {E, a, aa, aaa, . . . }.
  • 9. Let C = {a, b}  4. (alb)* denotes the set of all strings consisting of zero or more instances of a or b, that is, all strings of a's and b's: {e, a, b, aa, ab, ba, bb, aaa, . . .}. Another regular expression for the same language is (a*b*)*.  5. ala*b denotes the language {a, b, ab, aab,aaab,. . .), that is, the string a and all strings consisting of zero or more a's and ending in b.