Regular expression in compiler design


Regular expression in compiler design 

The finite set of valid string token lexeme which belongs to the language in hand are scarred and identified by the lexical analyzer. The pattern defined by the language rules is searched by the lexical analyzer.

It defines a search pattern for stings.Regular expressions have the capability to express finite language by defining a pattern for finite strings of symbol. The grammar defined by regular expression Is known as regular grammar . The  language defined by regular grammar is known as regular language.

 

Why Regular expression is important?

>> Regular expression is an important notation for specifying patterns.Each patterns matches a set string , so regular expression server as names for a set of strings,programming language . Regular expression is an example of recursive definition . Regular languages are easy to understand and have efficient implementation.


Rules of regular expressions 

Regular expressions are used to denote regular languages, AN expression is regular if

1) Ã¸ is regular expression for regular language ø.
2) Îµ is a regular expression for regular language { ε }.
3) If a ε Æ© ( Æ© represents the input alphabet ) a is regular expression with language { a }.
4) If a and b are regular expression, a+b is also regular expression with language {a,b}.
5) If a,b are regular expression , ab (concatenation of a and b ) is also regular .
6) If a is regular expression a* (0 or more times a ) is also regular .


Closure properties of regular language

Union 
If L1 and L2 are two regular languages,their union  L1 U L2 will also be regular . for example ,
L1 = {an | 0}  and L2 = {bn | n 0}
L3 = L1 + L2 ;
= {an U bn  | 0} is also regular expression .

Intersection
If L1 and L2 are two regular languages,their union  L1 L2 will also be regular . for example ,

L1 = {an bm  |  n≥ 0 and m ≥0}
L1 = {an bm  U  bman |  n0 and m 0}

L3 = L1 intersection L2
   = {an bm  | n0 and m 0}

Concatenation
If L1 and L2 are two regular languages,their union  L1 L2 will also be regular . for example ,
L1 = {an | 0}  and L2 = {bm | n 0}
L3 = L1.L2 = {an bm   |  n0 and m 0} is also regular

Complement 
 If L(G) is regular language ,its complement will also be regular expression.complement of a language can be found by substracting string which are in l(G) from all possible strings for example.


Note : 
1) r1r2 = r1 followed by an r2
R1 | r2 = r1 or r2 /either r1 or r2
R? =means an R or nothing

Precedence between them :

1) unary operator *
2) Concatenation
3) |

 Important and Related post :
>> What is application software and system software
>> incremental model with details.
>> Software Engineering | Classification of Software Requirements
>>What is operating system 
>>What is traffic monitoring system 
>> what is computer virus and names of virus.
>>What is embedded control system  
>> What is compiler .
>> What is linker.
>> What is Interpreter
>> Modern Principles Of Software Development
>> Types of Software Testing
>> Software Testing | Basics
>> Software Engineering | Debugging Approaches

Post a Comment

0 Comments