On Mon, 8 Feb 2010, Supervisor Root wrote:

> I used bison2.4.1,

Okay.

> yacc1.9.1

We only support Bison here.

> and flex2.5.4

Flex 2.5.4 is very old.  I'm using Flex 2.5.34 at the moment.  However, 
off the top of my head, I don't see how updating would address your 
problem.

> to create a simple parser 
> under windows XP platform, but I found that yyparse return zero when 
> syntax is error, this is or not a bug?

> condition: TRUE
>  |  FALSE
>  |  error {}
>  ;

The last production here allows the parser to enter error recovery mode.  
If it recovers and then completes the parse successfully, then it returns 
0.

>  if (nRet == 0)
>  {
>   printf("This is a corrent program!\n");
>  }
>  else
>  {
>   printf("This is a incorrent program!\n");
>  }

It sounds like you want to check nRet == 0 && yynerrs == 0.

> In addition, the parser runs normal under linux platform. (yyparse 
> returns non-zero under linux platform

I just tried your original code and example input on linux (Ubuntu 8.04), 
and yyparse returned zero.


_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to