Professional Documents
Culture Documents
21CS51 ATCD MODULE 2 - 2 Lexical Analyser Part1
21CS51 ATCD MODULE 2 - 2 Lexical Analyser Part1
LEXICAL ANALYSIS
VENKATESH BHAT
SENIOR ASSOCIATE PROFESSOR
DEPARTMENT OF CSE
AIET, MOODBIDRI
Friday 12 April 2024 1
MODULE 2 SYLLABUS
• Regular Expressions and Languages: Regular
Expressions, Finite Automata and Regular
• Expressions, Proving Languages Not to Be Regular
• Lexical Analysis Phase of compiler Design: Role of
Lexical Analyzer, Input Buffering , Specification of
• Token, Recognition of Token.
• Textbook 1: Chapter3 – 3.1, 3.2, Chapter4- 4.1
• Textbook 2: Chapter3- 3.1 to 3.4
3.1 Role of Lexical Analyzer
Lexeme Begin
Forward
■ Note that eof retains its use as a marker for the end of the of the
entire input.
■ Any eof that appears other than at the end of the buffer means
that the input is at an end.
Positive Closure of L L+ =
■ L = {a,b,c,d} L2 = {1,2}
■ L1L2 = {a1,a2,b1,b2,c1,c2,d1,d2}
■ L1 ∪ L2 = {a,b,c,d,1,2}
❑(0|1) *
=> all strings with 0 and 1, including the empty string
LAW DESCRIPTION
r|s=s|r | is commutative
r | (s | t) = (r | s) | t | is associative
r (st) =(rs) t Concatenation is associative
r (s | t) = rs | rt; (s|t) r =sr | tr Concatenation distributes over |
Ɛr=rƐ=r Ɛ is the identity for Concatenation
r* =( r | Ɛ ) * Ɛ is guaranteed in closure
r**= r* * is idempotent
digit → 0 | 1 | ... | 9
digits → digit digit *
optionalFraction → . digits | €
optionalExponent → ( E (+ | - | € ) digits )| €
number → digits optionalFraction
optionalExponent
Friday 12 April 2024 34
Extensions of Regular expressions