×
Study for the day when you don't have to worry about price tags.
--Your friends at LectureNotes
Close

Lab Manuals for Compiler Design - CD By ANNA SUPERKINGS

  • Compiler Design - CD
  • Practical
  • ANNA UNIVERISTY - HITECH
  • Computer Science Engineering
  • 146 Views
  • 6 Offline Downloads
  • Uploaded 7 months ago
Anna Superkings
Anna Superkings
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

Ex.No : 1 CONSTRUCTION OF NFA AIM: To write a program for constructing an NFA from given regular expression using C++. ALGORITHM: 1. Create a menu for getting four regular expressions input as choice. 2. To draw NFA for a, a/b ,ab ,a* create a routine for each regular om expression. .c 3. For converting from regular expression to NFA, certain transition us had been made based on choice of input at the rumtime. w w w .a nn au ni ve rs ity pl 4. Each of the NFA will be displayed is sequential order. 1

Text from page-2

PROGRAM: #include<iostream.h> #include<conio.h> #include<process.h> struct node { char start; char alp; node *nstate; }*p,*p1,*p2,*p3,*p4,*p5,*p6,*p7,*p8; char e='e'; void disp(); om void re1() .c { pl us p1=new(node); ity p2=new(node); rs p1->start='0'; ve p1->alp='e'; au .a p2->alp='a'; nn p2->start='1'; ni p1->nstate=p2; w disp(); w w p2->nstate=NULL; getch(); } void re2() { p1=new(node); p2=new(node); p3=new(node); p4=new(node); p5=new(node); p6=new(node); p7=new(node); p8=new(node); 2

Text from page-3

p1->start='0'; p1->alp='e'; p1->nstate=p2; p2->start='1'; p2->alp='a'; p2->nstate=p3; p3->start='2'; p3->alp='e'; p3->nstate=p4; p4->start='5'; p4->alp=' '; p4->nstate=p5; om p5->start='0'; .c p5->alp='e'; us p5->nstate=p6; ity pl p6->start='3'; rs p6->alp='b'; ve p6->nstate=p7; au ni p7->start='4'; nn p7->alp='e'; .a p7->nstate=p8; w w p8->start='5'; w p8->alp=' '; p8->nstate=NULL; disp(); getch(); } void re3() { p1=new(node); p2=new(node); p3=new(node); p1->start='0'; p1->alp='a'; p1->nstate=p2; 3

Text from page-4

p2->start='1'; p2->alp='b'; p2->nstate=p3; p3->start='2'; p3->alp=' '; p3->nstate=NULL; disp(); getch(); } void re4() { p1=new(node); om p2=new(node); .c p3=new(node); us p4=new(node); ity pl p5=new(node); rs p6=new(node); ve p7=new(node); au .a nn p1->start='0'; p1->alp='e'; ni p8=new(node); w w p1->nstate=p2; w p2->start='1'; p2->alp='a'; p2->nstate=p3; p3->start='2'; p3->alp='e'; p3->nstate=p4; p4->start='3'; p4->alp=' '; p4->nstate=p5; p5->start='0'; p5->alp='e'; p5->nstate=p6; p6->start='3'; 4

Lecture Notes