help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about Lexx & Yacc


From: Hans Aberg
Subject: Re: Question about Lexx & Yacc
Date: Fri, 12 Jan 2001 12:42:57 +0100

At 15:20 -0700 1-01-11, Nattapong wrote:
>I hope I send my question to the right place. If not, I apologize for that.
>
>The question is about my simple program on Lex & Yac ... (well actually
>flex and yacc).

Nope, this is the Bison list, not the Flex or Yacc list. Have you thought
of using Bison (latest development) version available at
  ftp://alpha.gnu.org/gnu/cvs/
instead of Yacc?

>please take a look at my "ch1-05.y". I compiled the code without any
>problem. But
>the error hit me when I tried to run it. "Segmentation Fault"
...
>%%
>
>extern FILE *yyin;
>
>main ()
>{
>   while (!feof(yyin)) {
>           yyparse ();
>   }
>}
...
>The program terminated when it hit "feof ()".
>This problem only occur when running on linux but not solaris.
>I guess that is because the lex and yacc program on the two systems are
>different.

Well, Flex only defines yyin to point at the standard stream after yylex
has been run at least once, which is not the case the when you run main()
and enter the "while" loop. So you try to address something that doesn't
exist, a "segmentation fault".

So this could be your problem.

-- Note: Your hookup is somewhat unusual: Bison stops reading yylex when it
returns a value <= 0, so you could let Flex have a line
<<EOF>>  { return EOF; }
Then enter a grammar into Bison that allows reading multiple lines (and
forget about the "while" loop above).

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]