SlideShare une entreprise Scribd logo
1  sur  15
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 = {ε}, Li ={aa}, the L* is all strings of an even
  number of a’s LO = {ε}, Li ={aa},L2 = {aaaa} & so
  on.
• If ε is excluded L.(L*) is denoted by,
             ∞      ∞        ∞

• L. (L*)= L.U Li = U Li+1 = U Li
             i=0     i=0      i=0

• The Unary postfix operator + is called positive
  closure and denotes “one or more instances of”.
• Regular Definitions are used to give names to
  regular Expressions and then
• to re-use these names to build new Regular
  Expressions.
• A Regular Definition is a sequence of definitions
  of the form:
• D1  R1
• D2  R2
• ….
• Dn  Rn
• Where each Di is a distinct name and each Ri is
  Regular expression over the extended alphabet
  VU{D1 ,D2,……Di-1}
• Identifiers are usually string of letters and digits
  beginning with a letter:
• letter  A|B|……|Z a|b|…..|z
• digit  0|1|….|9
• id  letter(letter | digit)*

• Using Character Classes we can define identifiers
  as:

• id  [A – Z a - z][A – Z a – z 0 - 9]
Regular expression (compiler)

Contenu connexe

Tendances

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
 
Formal language
Formal languageFormal language
Formal languageRajendran
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2shah zeb
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expressionAnimesh Chaturvedi
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of ComputationAnkur Singh
 
Chapter3pptx__2021_12_23_22_52_54.pptx
Chapter3pptx__2021_12_23_22_52_54.pptxChapter3pptx__2021_12_23_22_52_54.pptx
Chapter3pptx__2021_12_23_22_52_54.pptxDrIsikoIsaac
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of AutomataFarooq Mian
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
3.1 intro toautomatatheory h1
3.1 intro toautomatatheory  h13.1 intro toautomatatheory  h1
3.1 intro toautomatatheory h1Rajendran
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryTsegazeab Asgedom
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 

Tendances (20)

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
 
Formal language
Formal languageFormal language
Formal language
 
SS UI Lecture 4
SS UI Lecture 4SS UI Lecture 4
SS UI Lecture 4
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
FLAT Notes
FLAT NotesFLAT Notes
FLAT Notes
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of Computation
 
Chapter3pptx__2021_12_23_22_52_54.pptx
Chapter3pptx__2021_12_23_22_52_54.pptxChapter3pptx__2021_12_23_22_52_54.pptx
Chapter3pptx__2021_12_23_22_52_54.pptx
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
Flat unit 1
Flat unit 1Flat unit 1
Flat unit 1
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
3.1 intro toautomatatheory h1
3.1 intro toautomatatheory  h13.1 intro toautomatatheory  h1
3.1 intro toautomatatheory h1
 
Language
LanguageLanguage
Language
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
Theory of automata
Theory of automataTheory of automata
Theory of automata
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 

Similaire à Regular expression (compiler)

Similaire à Regular expression (compiler) (20)

1 introduction
1 introduction1 introduction
1 introduction
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Unit-1-part-1.pptx
Unit-1-part-1.pptxUnit-1-part-1.pptx
Unit-1-part-1.pptx
 
01-Introduction&Languages.pdf
01-Introduction&Languages.pdf01-Introduction&Languages.pdf
01-Introduction&Languages.pdf
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 02
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Regular expressions h1
Regular expressions h1Regular expressions h1
Regular expressions h1
 
Theory of computation
Theory of computationTheory of computation
Theory of computation
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdf
 
Syntax
SyntaxSyntax
Syntax
 
Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdf
 
L_2_apl.pptx
L_2_apl.pptxL_2_apl.pptx
L_2_apl.pptx
 
RegularLanguage.pptx
RegularLanguage.pptxRegularLanguage.pptx
RegularLanguage.pptx
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx
 
compiler Design course material chapter 2
compiler Design course material chapter 2compiler Design course material chapter 2
compiler Design course material chapter 2
 
01.ppt
01.ppt01.ppt
01.ppt
 

Plus de ReachLocal Services India (12)

Excel ppt
Excel pptExcel ppt
Excel ppt
 
Virtual reality
Virtual realityVirtual reality
Virtual reality
 
Digital signatures
Digital signaturesDigital signatures
Digital signatures
 
System security
System securitySystem security
System security
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Loop invariant computation
Loop invariant computationLoop invariant computation
Loop invariant computation
 
Distributed dbms
Distributed dbmsDistributed dbms
Distributed dbms
 
Sexual harresment on women
Sexual harresment on womenSexual harresment on women
Sexual harresment on women
 
Digital signal processing
Digital signal processingDigital signal processing
Digital signal processing
 
Mobile network layer (mobile comm.)
Mobile network layer (mobile comm.)Mobile network layer (mobile comm.)
Mobile network layer (mobile comm.)
 
Temporal data mining
Temporal data miningTemporal data mining
Temporal data mining
 

Dernier

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Dernier (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

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 = {ε}, Li ={aa}, the L* is all strings of an even number of a’s LO = {ε}, Li ={aa},L2 = {aaaa} & so on. • If ε is excluded L.(L*) is denoted by, ∞ ∞ ∞ • L. (L*)= L.U Li = U Li+1 = U Li i=0 i=0 i=0 • The Unary postfix operator + is called positive closure and denotes “one or more instances of”.
  • 13. • Regular Definitions are used to give names to regular Expressions and then • to re-use these names to build new Regular Expressions. • A Regular Definition is a sequence of definitions of the form: • D1  R1 • D2  R2 • …. • Dn  Rn • Where each Di is a distinct name and each Ri is Regular expression over the extended alphabet VU{D1 ,D2,……Di-1}
  • 14. • Identifiers are usually string of letters and digits beginning with a letter: • letter  A|B|……|Z a|b|…..|z • digit  0|1|….|9 • id  letter(letter | digit)* • Using Character Classes we can define identifiers as: • id  [A – Z a - z][A – Z a – z 0 - 9]