SlideShare a Scribd company logo
1 of 13
PRINCIPLES OF COMPILER DESIGN
 REGULAR EXPRESSION
Concepts :
• Regular Expression
• Strings
• Languages
Regular Expressions

• A regular expression is a pattern that defines a
  string or portion thereof. When comparing this
  pattern against a string, it'll either be true or
  false. If true, it'll return something.
• The return value will depend on the specific
  function used and its attributes.
Strings And Languages
• Strings:
  A string is a data type used in programming, such as
    an integer and floating point unit, but is used to
    represent text rather than numbers. It is comprised
    of a set of characters that can also contain spaces and
    numbers. For example, the word “hamburger”. Even
    "12345" could be considered a string, if specified
    correctly.
   Two important examples of programming language
    alphabets are ASCII and EBCDIC character sets.
Strings (contd…):
• A string is a finite sequence of symbols such as 001.
  The length of a string x, usually denoted |x|, is the total
  number of symbols in x.
• For eg.: 110001 is a string of length 6. A special string
  is a empty string which is denoted by ε. This string is
  of length 0(zero).
• If x and y are strings, then the concatenation of x and y,
  written as x.y or just xy, is the string formed by
  following the symbols of x by the symbols of y.
• For eg.:abd.ce = abdce i.e. if x= abd & y=ce , then
   xy = abdce.
Strings (contd…)
• The concatenation of the empty string with any
  string is that string i.e. εx = xε = x.
• Concatenation is not any sort of product, thus it is
  an iterated product in form of exponential.
• E.g.: X1 = x, X2 = XX, X3 =XXX
• In general xi is the string x repeated i times. We
  take x0 to be ε for any string x. Thus, ε plays the
  role of 1, the multiplicative identity.
Strings (contd…)
• If x is some string, then any string formed by discarding
  zero or more trailing symbols of x is called a prefix of x.
• For e.g.: abc is a prefix of abcde.
• A suffix of x is a string formed by deleting zero or more of
  the leading symbols of x. cde is a suffix of abcde. A
  substring of x is any string obtained by deleting a prefix
  and a suffix from x.
• For any string x, both x and ε are prefixes, suffixes and
  substrings of x.
• Any prefix or suffix of x is a substring of x, but a
  substring need not be a prefix or suffix.
• For e.g..: cd is a substring of abcde but not a prefix or
  suffix .
Languages
• The term language means any set of strings formed
  from some specific alphabets.
• Simple set such as Φ, the empty set {ε} having no
  members or the set containing only the empty
  string, are languages.
• The notation of concatenation can also be applied to
  languages.
• For e.g.: If L and M are languages, then L.M, or just
  LM
• LM is language consisting of all strings xy which can
  be formed by selecting a string x from L, a string y
  from M, and concatenating them in that order.
   LM= {xy| x is in L and y is in M}
Languages (contd…)
• E.g.: If L={0, 01, 110} and M= {10, 110}. Then
  LM={010, 0110, 01110, 11010, 110110}
• 11010 can be written as the concatenation of of
  110 from L and 10 from M.
• 0110 can be written as either 0.110 or 01.10 i.e. it
  is a string from L followed by one from M.
• In analogy with strings, we use Li to stand for
  LL….L (i times). It is logicat to define L0 to be {ε},
  since {ε} is the identity under concatenation of
  languages. i.e. {ε}L = L{ε} = L
• The union of languages L & M is given by
  L ∪ M ={x | x is in L or x is in M}
Languages (contd…)
• If concatenation is analogous to multiplication.
  Then ø, the empty set is the identity under union
  (analogous to zero)
                 øUL=LUø=L
                       &
                 ø L=Lø=ø
• Any string in the concatenation of ø with L
 must be formed from x in ø and y in L.
• There is another operation in specifying
  tokens, that is closure or “any number of”
  operator. We use L* to denote the concatenation of
  language L with itself any number of times.
       ∞
• L* = U Li
      i=0


• Consider D be the language consisting of the
  strings 0,1,……9 i.e. each string is a single decimal
  digit. Then D* is all strings of digits including
  empty string.
• If L ={aa}, the L* is all strings of an even number of
  a’s.
• LO = {ε}
Regular expression (compiler)

More Related Content

What's hot

Regular Expression in Compiler design
Regular Expression in Compiler designRegular Expression in Compiler design
Regular Expression in Compiler designRiazul Islam
 
Formal language
Formal languageFormal language
Formal languageRajendran
 
introduction to C programming (C)
introduction to C programming (C)introduction to C programming (C)
introduction to C programming (C)Abhishek Walia
 
NFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikNFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikMudsaraliKhushik
 
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptChapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptFamiDan
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignAkhil Kaushik
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First SearchKevin Jadiya
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler DesignKuppusamy P
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramAbdullah Jan
 
Toc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computationToc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computationnarayan dudhe
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C BasicsBharat Kalia
 

What's hot (20)

Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Java program structure
Java program structureJava program structure
Java program structure
 
NFA and DFA
NFA and DFANFA and DFA
NFA and DFA
 
Regular Expression in Compiler design
Regular Expression in Compiler designRegular Expression in Compiler design
Regular Expression in Compiler design
 
Formal language
Formal languageFormal language
Formal language
 
introduction to C programming (C)
introduction to C programming (C)introduction to C programming (C)
introduction to C programming (C)
 
NFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikNFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushik
 
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptChapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.ppt
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
 
Toc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computationToc 1 | gate | Theory of computation
Toc 1 | gate | Theory of computation
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 

Similar to Regular expression (compiler)

1 introduction
1 introduction1 introduction
1 introductionparmeet834
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfDrIsikoIsaac
 
01-Introduction&Languages.pdf
01-Introduction&Languages.pdf01-Introduction&Languages.pdf
01-Introduction&Languages.pdfTariqSaeed80
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 028threspecter
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.pptRatnakar Mikkili
 
Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdfGaurav447273
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesMarina Santini
 
Automata
AutomataAutomata
AutomataGaditek
 
Automata
AutomataAutomata
AutomataGaditek
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptxmainakmail2585
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdfkenilpatel65
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2shah zeb
 

Similar to Regular expression (compiler) (20)

Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 
1 introduction
1 introduction1 introduction
1 introduction
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdf
 
01-Introduction&Languages.pdf
01-Introduction&Languages.pdf01-Introduction&Languages.pdf
01-Introduction&Languages.pdf
 
Unit-1-part-1.pptx
Unit-1-part-1.pptxUnit-1-part-1.pptx
Unit-1-part-1.pptx
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 02
 
Flat unit 1
Flat unit 1Flat unit 1
Flat unit 1
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt
 
Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdf
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Theory of computation
Theory of computationTheory of computation
Theory of computation
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx
 
Syntax
SyntaxSyntax
Syntax
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdf
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
 

More from Jagjit Wilku

More from Jagjit Wilku (7)

Health insurance
Health insuranceHealth insurance
Health insurance
 
Auto insurance
Auto insuranceAuto insurance
Auto insurance
 
Mobile communication
Mobile communicationMobile communication
Mobile communication
 
Neural networks
Neural networksNeural networks
Neural networks
 
Decision trees
Decision treesDecision trees
Decision trees
 
Complier designer
Complier designerComplier designer
Complier designer
 
Mc wireless lan
Mc wireless lanMc wireless lan
Mc wireless lan
 

Recently uploaded

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

Regular expression (compiler)

  • 1. PRINCIPLES OF COMPILER DESIGN REGULAR EXPRESSION
  • 2. Concepts : • Regular Expression • Strings • Languages
  • 3. Regular Expressions • A regular expression is a pattern that defines a string or portion thereof. When comparing this pattern against a string, it'll either be true or false. If true, it'll return something. • The return value will depend on the specific function used and its attributes.
  • 4. Strings And Languages • Strings: A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. For example, the word “hamburger”. Even "12345" could be considered a string, if specified correctly.  Two important examples of programming language alphabets are ASCII and EBCDIC character sets.
  • 5. Strings (contd…): • A string is a finite sequence of symbols such as 001. The length of a string x, usually denoted |x|, is the total number of symbols in x. • For eg.: 110001 is a string of length 6. A special string is a empty string which is denoted by ε. This string is of length 0(zero). • If x and y are strings, then the concatenation of x and y, written as x.y or just xy, is the string formed by following the symbols of x by the symbols of y. • For eg.:abd.ce = abdce i.e. if x= abd & y=ce , then xy = abdce.
  • 6. Strings (contd…) • The concatenation of the empty string with any string is that string i.e. εx = xε = x. • Concatenation is not any sort of product, thus it is an iterated product in form of exponential. • E.g.: X1 = x, X2 = XX, X3 =XXX • In general xi is the string x repeated i times. We take x0 to be ε for any string x. Thus, ε plays the role of 1, the multiplicative identity.
  • 7. Strings (contd…) • If x is some string, then any string formed by discarding zero or more trailing symbols of x is called a prefix of x. • For e.g.: abc is a prefix of abcde. • A suffix of x is a string formed by deleting zero or more of the leading symbols of x. cde is a suffix of abcde. A substring of x is any string obtained by deleting a prefix and a suffix from x. • For any string x, both x and ε are prefixes, suffixes and substrings of x. • Any prefix or suffix of x is a substring of x, but a substring need not be a prefix or suffix. • For e.g..: cd is a substring of abcde but not a prefix or suffix .
  • 8. Languages • The term language means any set of strings formed from some specific alphabets. • Simple set such as Φ, the empty set {ε} having no members or the set containing only the empty string, are languages. • The notation of concatenation can also be applied to languages. • For e.g.: If L and M are languages, then L.M, or just LM • LM is language consisting of all strings xy which can be formed by selecting a string x from L, a string y from M, and concatenating them in that order. LM= {xy| x is in L and y is in M}
  • 9. Languages (contd…) • E.g.: If L={0, 01, 110} and M= {10, 110}. Then LM={010, 0110, 01110, 11010, 110110} • 11010 can be written as the concatenation of of 110 from L and 10 from M. • 0110 can be written as either 0.110 or 01.10 i.e. it is a string from L followed by one from M. • In analogy with strings, we use Li to stand for LL….L (i times). It is logicat to define L0 to be {ε}, since {ε} is the identity under concatenation of languages. i.e. {ε}L = L{ε} = L • The union of languages L & M is given by L ∪ M ={x | x is in L or x is in M}
  • 10. Languages (contd…) • If concatenation is analogous to multiplication. Then ø, the empty set is the identity under union (analogous to zero) øUL=LUø=L & ø L=Lø=ø • Any string in the concatenation of ø with L must be formed from x in ø and y in L.
  • 11. • There is another operation in specifying tokens, that is closure or “any number of” operator. We use L* to denote the concatenation of language L with itself any number of times. ∞ • L* = U Li i=0 • Consider D be the language consisting of the strings 0,1,……9 i.e. each string is a single decimal digit. Then D* is all strings of digits including empty string. • If L ={aa}, the L* is all strings of an even number of a’s.
  • 12. • LO = {ε}