Compiler LAB
Compiler LAB
Tribhuvan University
Lab Report
On
Compiler Design and Construction (CSC-365)
Submitted to:
Mr. Prithvi Raj Paneru
Submitted by:
Kushal Aryal
25013/076
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
3. IMPLEMENTATION:
Source code:
#include <stdio.h>
#include <ctype.h>
int main()
{
char a[10];
int flag, i = 1;
printf("\n Enter the identifier\t");
gets(a);
5. CONCLUSION:
Hence, we can conclude that validity of identifiers was checked and implemented using
C-program.
3. IMPLEMENTATION:
Source code:
#include<stdio.h>
int main()
{
char com [30];
int i=2,a=0;
printf("\n Enter Text : ");
gets(com);
if(com[0]=='/')
{
if(com[1]=='/')
printf("\n It is a Comment.");
else if(com [1]=='*')
{
for(i=2;i<=30;i++)
{
if(com[i]=='*'&&com[i+1]=='/')
{
5. CONCLUSION:
Hence, we can conclude that validity of comment was checked and implemented using C-
program.
3. IMPLEMENTATION:
Text File:
Source code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <process.h>
int iskeyword(char b[])
{
5. CONCLUSION:
Hence, we can conclude that the tokenization of given code was done and implemented
using C-program.
3. IMPLEMENTATION:
Source code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char s[10], c;
int state = 0, i = 0;
printf("\n Enter a string: ");
gets(s);
while(s[i] != '\0')
{
switch(state)
{
case 0:
c = s[i++];
if (c == 'a')
state = 1;
else if (c == 'b')
state = 2;
else
state = 6;
break;
5. CONCLUSION:
Hence, we can conclude that the given string was recognized and implemented using C-
program.