compiler file
compiler file
LABORATORY FILE
COMPILER DESIGN LAB
(BCS-652)
2201430100073
Roll No.
Section-Batch 3CSE-1 – B3
2
PROGRAM OUTCOMES (POS) AND PROGRAM SPECIFIC
OUTCOMES (PSOs)
S. No. Program Outcomes / Program Specific Outcomes
3
CSE DEPARTMENT PROGRAM EDUCATIONAL OBJECTIVES (PEOs)
B. Tech Computer Science & Engineering Department has the following Program Educational
Objectives:
PEO1: Possess core theoretical and practical knowledge in Computer Science and Engineering for
successful career development in industry, pursuing higher studies or entrepreneurship.
PEO2: Ability to imbibe lifelong learning for global challenges to impact society and the
environment.
PEO3: To demonstrate work productivity, leadership and managerial skills, ethics, and human
value in progressive career path.
PEO4: To exhibit communication skill and collaborative skill plan and participate in multidisciplinary
Computer Science & Engineering fields.
B.Tech Computer Science & Engineering Department has the following Program Specific Outcomes:
PSO1: To analyze and demonstrate, the recent engineering practices, ethical values and strategies in
real-time world problems to meet the challenges for the future.
PSO2: To develop adaptive computing system using computational intelligence strategies and
algorithmic design to address diverse data analysis and machine learning challenges.
4
PROGRM OUTCOMES
Engineering Graduates will be able to:
5
GENERAL LABORATORY INSTRUCTIONS
1. Students are advised to come to the laboratory at least 5 minutes before (to the starting
time), those who come after 5 minutes will not be allowed into the lab.
2. Plan your task properly much before to the commencement, come prepared to the lab with
the synopsis / program / experiment details.
• Laboratory observation notes with all the details (Problem statement, Aim, Algorithm,
Procedure, Program, Expected Output, etc.,) filled in for the lab session.
• Laboratory Record updated up to the last session experiments and other utensils (if
any) needed in the lab.
4. Sign in the laboratory login register, write the TIME-IN, and occupy the computer system
allotted to you by the faculty.
5. Execute your task in the laboratory, and record the results / output in the lab observation
note book, and get certified by the concerned faculty.
6. All the students should be polite and cooperative with the laboratory staff, must maintain
the discipline and decency in the laboratory.
7. Computer labs are established with sophisticated and high end branded systems, which
should be utilized properly.
8. Students / Faculty must keep their mobile phones in SWITCHED OFF mode during the lab
sessions. Misuse of the equipment, misbehaviors with the staff and systems etc., will attract
severe punishment.
9. Students must take the permission of the faculty in case of any urgency to go out; if
anybody found loitering outside the lab / class without permission during working hours will
be treated seriously and punished appropriately.
10. Students should LOG OFF/ SHUT DOWN the computer system before he/she leaves the
lab after completing the task (experiment) in all aspects. He/she must ensure the system / seat
is kept properly.
4
DETAILS OF THE EXPERIMENTS CONDUCTED
(TO BE USED BY THE STUDENTS IN THEIR RECORDS)
INDEX
5
STUDY AND EVALUATION SCHEME
Course Course
Teaching Scheme Credits Assigned
Code Name
Compiler Theory Practical Tutorial Theory Practical Tutorial Total
BCS-652 (P) Design Lab
00 02 00 00 01 00 01
(50
Marks)
6
IMS Engineering College
NH-09, Adhyatmik Nagar, Near Dasna, Distt. Ghaziabad, U.P.
Tel: (0120) 4940000
Department of Computer Science and Engineering
Bloom’s
COURSE OUTCOMES Level
Identify patterns, tokens & regular expressions for lexical analysis. K2,K4
C308.1
Design Lexical analyser for given language using C and LEX /YACC tools’ K3,K5
C308.2
K4, K5
C308.4 Generate the intermediate code.
CO-PO Matrix
Course
PO 1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
Outcome
C308.1 2 2 2 1 2 1 1 1 2 1 2 2 2 1
C308.2 2 2 2 2 2 1 1 1 2 1 1 1 1 2
C308.3 2 2 2 2 1 1 1 1 2 1 1 1 2 1
C308.4 2 2 1 1 1 1 1 1 2 1 1 1 1 2
C308.5 2 2 1 2 1 1 1 1 2 1 1 2 2 2
C308 2.0 2.0 1.6 1.6 1.4 1.0 1.0 1.0 2.0 1.0 1.2 1.4 1.6 1.6
7
LIST OF PROGRAMS
3. Write a program of a grammar, which accepts the odd no. of zero. C308.1
4. Write a program of a grammar, which accepts the even no. of zero. C308.1
6. Write a program to identify that the given grammar is Left recursive or not. C308.3
9. Write program to find Simulate First and Follow of any given grammar. C308.3
14. Implement the back end of the compiler which takes the three-address code C308.5
and produces the 8086 assembly language instructions that can be assembled
and run using an 8086 assembler. The target assembly instructions can be
simple move, add, sub, jump etc.
8
EXPERIMENT NO. - 1
Code:
#include <stdio.h>
#include <string.h>
void main() {
char a[10];
int i, l, flag = 0;
printf("Name : Ayush Pratap singh , Roll no : 2201430100073\n");
printf("Enter the string to be matched: ");
fgets(a, sizeof(a), stdin);
a[strcspn(a, "\n")] = 0;
l = strlen(a);
if ((a[0] >= 'a' && a[0] <= 'z') ||
(a[0] >= 'A' && a[0] <= 'Z') ||
a[0] == '_')
{
if (flag == 1) {
puts("This is an invalid identifier.");
} else {
puts("Valid identifier.");
}
} else {
puts("This is an invalid identifier.");
}
}
9
Output:
10
EXPERIMENT NO. - 2
Code:
#include <stdio.h>
#include <string.h>
void main() {
char a[32][10] = {
"auto", "break", "case", "char", "const", "continue", "default",
"do", "double", "else", "enum", "extern", "float", "for", "goto",
"if", "int", "long", "register", "return", "short", "signed",
"sizeof", "static", "struct", "switch", "typedef", "union",
"unsigned", "void", "volatile", "while"
};
char b[30];
int i, c;
b[strcspn(b, "\n")] = 0;
11
Output:
12
EXPERIMENT NO. - 3
AIM: Write a program of a grammar which accepts the odd no. of zero
Code:
#include <stdio.h>
#include <string.h>
#define q0 0
#define q1 1
void main() {
char a[10];
int s, i;
printf("Enter a binary string: ");
printf("Name: Ayush Pratap Singh
, Roll No.: 2201430100073\n");
fgets(a, sizeof(a), stdin);
a[strcspn(a, "\n")] = 0;
s = q0;
for (i = 0; a[i] != '\0'; i++) {
if (a[i] == '0' && s == q0)
s = q1;
else if (a[i] == '0' && s == q1)
s = q0;
else if (a[i] == '1')
continue;
else { printf("Invalid binary string.\n");
return; }}
if (s == q1)
printf("Grammar is accepted.\n");
else printf("Grammar is not accepted.\n"); }
Output:
13
EXPERIMENT NO. - 4
AIM: Write a program of a grammar which accepts the even no. of zero
Code:
#include <stdio.h>
#include <string.h>
#define q0 0
#define q1 1
void main() {
char a[20];
int s, i;
printf("Enter a binary string: ");
printf("Name: Ayush Pratap
Singh , Roll No.:
2201430100073\n");
fgets(a, sizeof(a), stdin);
a[strcspn(a, "\n")] = 0;
s = q0;
for (i = 0; a[i] != '\0'; i++) {
if (a[i] == '0' && s == q0)
s = q1;
else if (a[i] == '0' && s == q1)
s = q0;
else if (a[i] == '1')
continue;
else {
printf("Invalid binary string.\n");
return; }}
if (s == q0)
printf("Grammar is accepted.\n");
else
printf("Grammar is not accepted.\n");
}
Output:
14