- 论坛徽章:
- 0
|
请问哪位经验丰富的编程者parse error是什么东西?
/* below are the data type */
#define STACK_INIT_SIZE 100
#define INCREMENT 10
typedef struct{
char *base;
char *top;
int stacksize;
}stack_chr;
typedef int status;
status initstack(stack_chr &stack) /* 这一行说是parse error before & token*/
{
stack.base=(char*)malloc(STACK_INIT_SIZE*sizeof(char));
if(!stack.base) { printf("malloc error" ,exit(0);}
stack.top=stack.base;
stack.stacksize=STACK_INIT_SIZE;
return(0);
}
status push(stack_chr &stack,char element)/* 这一行说是parse error before & token*/
{
if(stack.top-stack.base==stack.stacksize)
stack.base=(char*)realloc(stack.base,(INCREMENT+stack.stacksize)*sizeof(char));
if(!stack.base) { printf("realloc error" ; exit(0);}
*(stack.top++)=element;
stack.stacksize+=INCREMENT;
return(0);
}
status pop(stack_chr &stack,char &element)/* 这一行说是parse error before & token*/
{
if(stack.top==stack.base) { printf("It's an empty stack" ; return (1);}
element=*(--stack.top);
return(0);
}
int ischars(stack_chr &stack)
{
stack_chr temp;
char unit_1,unit_2;
if(initstack(temp)==0) printf("init suceed" ;
pop(stack,unit_1);
while(unit_1!='&') { push(temp,unit_1); pop(stack,unit_1);}
pop(stack,unit_1);
pop(temp,unit_2);
while(unit_1==unit_2)
{
if(pop(stack,unit_1)==1)
break;
if(pop(temp,unit_2)==1)
break;
}
if(unit_1==unit_2)
if((stack.base==stack.top)&&(temp.base==temp.top))
return (1);
else
return (0);
}
main()
{
stack_chr stack;
char temp;
printf(" lease input a sting" ;
while(temp!='@'){
temp=getchar();
push(stack,temp);
}
if(ischars(stack)==1)
printf("This is you want" ;
else
printf("This isn't you want" ;
}
编译时出现parse error的问题. |
|