Regular Expressions in Compiler Design: A Comprehensive Guide, Schemes and Mind Maps of Computer science

A comprehensive introduction to regular expressions, a fundamental concept in compiler design. It explains how patterns are specified using operators like union, concatenation, kleene closure, and positive closure. The document also includes numerous examples illustrating the use of regular expressions in defining various language constructs. It is a valuable resource for students and professionals seeking to understand the role of regular expressions in compiler design.

Typology: Schemes and Mind Maps

2024/2025

Uploaded on 02/10/2025

ether-marker
ether-marker 🇸🇬

1 document

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Regular Expression
Course Name: Compiler Design
Course Code: CSE331
Level:3, Term:3
Department of Computer Science and Engineering
Daffodil International University
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Regular Expressions in Compiler Design: A Comprehensive Guide and more Schemes and Mind Maps Computer science in PDF only on Docsity!

Regular Expression

Course Name: Compiler Design Course Code: CSE Level:3, Term: Department of Computer Science and Engineering Daffodil International University

A Regular expression (sometimes called a rational expression) is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. “find and replace”-like operations.

Regular expression is a notation for defining the set of tokens that

normally occur in programming languages.

Regular Expression

  • Letters or alphabets and digits are the most important elements of language.
  • Let L be the set of alphabets {A, B,…Z, a, b,….z} and D be the set of digits { 0 , 1 , …., 9 }
  • L could be in form of upper case and lower case.
  • Examples: L U D is the set of letters and digits. LD is the set of strings consisting of a letter followed by a digit.
  • LLLL = L 4 is the set of all four-letter strings.

Operations of Language

• L

is the set of all strings of letters, including ε, the empty string

  • L(L U D)
    • is the set of all strings of letters and digits beginning with a letter.
  • D
    • is the set of all strings of one or more digits.

Operations of Language

  • (a|b)
    • or (a * |b * ) *
  • Denotes the set of all strings containing zero or more instances of an a or b, that is, the set of all strings of a’s and b’s.
  • a | a
    • b
  • Denotes the set containing the string a and all strings consisting of zero or more a’s followed by a b

Examples

Examples:

  • “Set of all strings having at least one ab”  (ab)
  • “Set of all strings having even number of aa”  (aa)
  • “Set of all strings having odd number of bb”  b(bb)
  • “Set of all strings having even number of aa and even number of bb”  (aa)
    • (bb) * Language to Regular Expressions

THANK YOU