Errors after compiling

hi all,

the following code is for a SLR parser... after compiling i got some strange errors - could someone pls take a look, or try compiling it... tnx alot

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include<iostream>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<stdio.h>

char in[30];
char T[]={"i+*()$E"};
char prod[4][5]={"EE+E","EE*E","E(E)","Ei"};

char M[10][8]={"sbbsbbg","bssbbab","sbbsbbg",              //matrix to store shift,
	       "brrbrrb","sbbsbbg","sbbsbbg",              //reduce,error and accept states
	       "bssbsbb","brsbrrb","brrbrrb",
	       "brrbrrb"};
int S[10][7]={{3,0,0,2,0,0,1},{0,4,5,0,0,0,0},{3,0,0,2,0,0,6}, //matrix to store goto and action states
	      {0,4,4,0,4,4,0},{3,0,0,2,0,0,7},{3,0,0,2,0,0,8},
	      {0,4,5,0,9,0,0},{0,1,5,0,1,1,0},{0,2,2,0,2,2,0},
	      {0,3,3,0,3,3,0}};



class stack
{
char a[20]; //stores the terminals and states
int b[20];  //stores the states
int top;
int topb;
public:
stack()
{
top=topb=0;
}

void push(char n)
{
a[top]=n;
top++;
}
void pushb(int n)
{
b[topb]=n;
topb++;
}
char pop()
{
if(top>0)
return a[--top];
else return -1;
}
int popb()
{
if(topb>0)
return b[--topb];
else return -1;
}

int tos()
{
return b[topb-1];
}
};

int search(char c)
{
 for(int i=0;i<strlen(T);i++)
 {
 if(c==T[i])
 return i;
 }
 return -1;
}

void print(int ser)
{
cout<<prod[ser][0]<<"->";
for(int i=1;i<strlen(prod[ser]);i++)
cout<<prod[ser][i];
cout<<endl;
}

void main()
{
clrscr();
stack s;
int i=0,x,ser;
char c;

gets(in);
s.pushb(0);
int k=0;
while(k<20)
{k++;
 x=search(in[i]);
 if(x==-1)
 break;
 c=M[s.tos()][x];
 if(c=='b')
 break;
 if(c=='a')
 {
 printf("\naccepted!!!");
 getch();
 exit(0);
 }
 if(c=='s')
 {
 s.push(in[i]);
 i++;
 s.pushb(S[s.tos()][x]);
 continue;
 }
 ser=S[s.tos()][x];
 ser--;
 for(int j=0;j<strlen(prod[ser])-1;j++)
 {
 s.pop();
 s.popb();
 }
 s.push(prod[ser][0]);
 s.pushb(S[s.tos()][search(prod[ser][0])]);
 print(ser);
 }
 printf("Error!!!");
 getch();
}


ERROR log:
http://img441.imageshack.us/img441/9344/62954061.png
These errors are really pretty trivial. First you need std::cout not cout. My compiler tells me exactly what the problem is and shows the line of code. You can figure most of these out on your own. By the way tags don't add much value if you aren't going to bother formatting the code blocks. Auto indent within your IDE and then copy and paste the code within tags so that the formatting is preserved.
CrossBosster already posted this on another forum where it was answered. He's just too lazy to mark the threads as solved on either forum.
Topic archived. No new replies allowed.