LATEST UPDATE

CIMA study stuff added

BOX

Wednesday, September 15, 2010

15-09-2010 COMPILER LAB WORK

#include
#include
int lookahead;
void main(){
lookahead = getchar();
do {expr();}
while(lookahea!=0);}
void term(){
if(isdigit(lookahead)){
putchar(lookahead);
match(lookahead);}
elseerror();}
void error(){
printf("syntexerror\n");
exity(1);}
void expr(){
term();
while(1){
if(lookahead=='+')
{match('+');
term();
putchar('+');
}
else if (lookahead=='-')
{
match('-');
term();
putchar('-');
}
else break;
}
}
void match(int t)
{
if(lookahead == t )
lookahead =getchar();
elseerror();
}

No comments:

Post a Comment

UBIT

SMS AT ANY NETWORK

STAND UP 4 THE CHAMPION

Search This Blog