#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