|
Wednesday, 14 April 2010 04:00 |
// description of your code here
#include
#include
#include
#include
#include
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 {
if(c==T[i])
return i;
}
return -1;
}
void print(int ser)
{
cout<";
for(int i=1;icout<cout<}
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 {
s.pop();
s.popb();
}
s.push(prod[ser][0]);
s.pushb(S[s.tos()][search(prod[ser][0])]);
print(ser);
}
printf("Error!!!");
getch();
}
 Read more: |
|
|
Tuesday, 23 March 2010 20:07 |
|
Submit your iPad app now for an initial review by the App Review Team and receive feedback on its readiness for the grand opening of the iPad App Store. Visit the App Store Resource Center for important details including screen shot dimensions, how to target universal applications, and what to expect during the initial review. 
Read more: |
|
Wednesday, 17 March 2010 07:00 |
 | About Quiet Read
Sometimes, when I am browsing the web, I want to store a link for later. There are note taking applications and everything-buckets to do that, but I wanted something light and simple. Simple as dragging a link onto a menu bar item to store it.
Quiet Read is available in Traditional Chinese, Polish, Helenic, French, German, Italian, Japanese, Korean, Dutch and Spanish. |
Read more: |
|
|
Tuesday, 15 December 2009 06:00 |
 | About Quiet Read
Sometimes, when I am browsing the web, I want to store a link for later. There are note taking applications and everything-buckets to do that, but I wanted something light and simple. Simple as dragging a link onto a menu bar item to store it. |
Read more: |
|
Written by
|
|
Friday, 06 November 2009 06:00 |
 | About Quiet Read
Sometimes, when I am browsing the web, I want to store a link for later. There are note taking applications and everything-buckets to do that, but I wanted something light and simple. Simple as dragging a link onto a menu bar item to store it. |
Read more: |
|
|