Docsity

Regular Expression compiler instruction, Lecture notes of Compiler Construction

Toggle sidebar
bg1
Regular Expression
•Regular Expression (RE) is a mathematical representation of specifying set of strings
•In this method of defining a language, language is represented in terms of strings
•Operands includes basic symbols and alphabet A – Z , a – z , 0 – 9 , and special string, called
empty string
•Operators includes:
•Union
•Concatenation
•Kleene Closure / Power of String
•Positive Closure
pf3
pf4
pf5

Partial preview of the text

Download Regular Expression compiler instruction and more Lecture notes Compiler Construction in PDF only on Docsity!

Regular Expression

  • (^) Regular Expression (RE) is a mathematical representation of specifying set of strings
    • (^) In this method of defining a language, language is represented in terms of strings
  • (^) Operands includes basic symbols and alphabet A – Z , a – z , 0 – 9 , and special string, called empty string
  • (^) Operators includes:
    • (^) Union
    • (^) Concatenation
    • (^) Kleene Closure / Power of String
    • (^) Positive Closure

Union, Concatenation, Kleene

Closure, Positive Closure

  • (^) Example: String contains a or b, L = {a,b} RE = a + b or a|b
  • (^) Operator symbol + , | (bar)
  • (^) A choice between two symbols, i.e. ‘a’ and ‘b’ is represented by the symbol ( | ) or ( + )
  • (^) Example (Concatenation) : language consisting of strings from Ʃ = {a,b}, where each string starts with a and contains any number of b letters L = {a, ab, abb, abbb, ……}
  • (^) RE = a b* AND OR

Regular Expression Continue…

Example:

  • (^) Consider a language L, of even length, defined over Σ = {a, b}

RE = ((a + b ) ( a + b ))*

L = {λ, aa, ab, ba, bb, aaaa, aaab, baaa, bbbb, ….}

Example:

  • (^) Consider the language, defined over Σ={a , b} of words having at least one a

RE = a

RE = ( a + b )a ( a + b)

Regular Expression Continue…

Example: Consider the language, defined over Σ={a, b} of words starting with a and ending in b OR starting with b and ending in **a RE = a ( a + b )

b + b ( a + b)

a** a???b,……….. b???a, …….. Example: Consider the language, defined over Σ={a, b} of words beginning and ending in same letter RE = a + b + a ( a + b) a + b ( a + b) b a , b , a??? a ,……, b??? b**