Professional Documents
Culture Documents
h>
#include<ctype.h>
void expr();
void rest();
void match(int);
void error();
void term();
int lexan();
int linenumber=0;
int lookahed;
int main(void){
lookahed = getchar();
expr();
putchar('\n');
}
void error(){
printf("Syntax error...line: %d\n",linenumber);
}
void expr(){
term();
rest();
}
void rest(){
while(1){
if(lookahed=='+'){
match('+');
term();
putchar('+');
// rest();
}
else if(lookahed=='-'){
match('-');
term();
putchar('-');
// rest();
}
else
break;
}
}
}
int lexan(){
int toxen;
while(1){
toxen=getchar();
if(toxen==' '||toxen=='\t'){
}
else if(toxen=='\n')
linenumber++;
else
return toxen;
}
}