dStack("operandStack ");
ArrayStack operatorStack("operatorStack");
int streamLen = strlen(buffer);
char c;
/*
* 需要归约的情况:
* 1. 当前的token是整数, 且操作符栈顶元素为''*''或''/'';
* 2. 当前的token是'')'';
* 3. 当前的token是''+''或''-'', 且操作符栈顶元素为''+''或''-'';
*/
for(int index=0; index<streamLen; index++){
c = buffer[index];
Token t;
if(c >= ''0'' && c <= ''9''){
t.type = Token_Int;
t.value = c - ''0'';
operandStack.push(t);
if(!operatorStack.isEmpty()){
if(operatorStack.peek()->type == ''*''
|| operatorStack.peek()->type == ''/''){
calculate(operandStack, operatorStack);
}
}
}else{
t.type = c;
Token *temp;
switch(c){
case '')'':
if(operatorStack.isEmpty()){
printf("*********Syntax Error!*********\n");
exit(0);
}
temp = operatorStack.peek();
if(temp->type == ''