-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFU.CPP
More file actions
58 lines (50 loc) · 951 Bytes
/
FU.CPP
File metadata and controls
58 lines (50 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<fstream.h>
char lookup[32][10]={"struct","int","float","double","long","char"};
char *symtab=new char[10000];
int pass1(char p[]);
main()
{
char *p,ch;
p=new char[1000];
clrscr();
cout<<"Enter the structure `DELIM\n\n";
scanf("%[^`]s",p);
pass1(p);
for(int i=0;p[i]!='\0';)
cout<<p[i++];
getch();
}
int pass1(char p[])
{
int flag=1,flb=0;
for(int i=0;i<strlen(p);i++)
{
if(isalnum(p[i])||p[i]=='{'||p[i]=='}'||p[i]==';'||p[i]=='_'||p[i]==' '||p[i]=='\n'||p[i]=='*')
{
if(p[i]=='{')
flb++;
if(p[i]=='}')
flb--;
flag=1;
continue;
}
else
{
cout<<"\nUnidentified symbol '"<<p[i]<<"'"<<"\n";
flag=0;
break;
}
}
if(flb>0)
cout<<"\n"<<flb<<" extra '{' \n";
else if(flb)
cout<<flb<<" extra '}' \n";
else if(!flag) return 0;
else return 1;
}