help-bison
[Top][All Lists]
Advanced

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

Re: Question about Lexx & Yacc


From: Akim Demaille
Subject: Re: Question about Lexx & Yacc
Date: 12 Jan 2001 15:01:48 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Crater Lake)

| >   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.

Probably.

| -- 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; }

I believe Flex does the proper thing without this rule too.

| Then enter a grammar into Bison that allows reading multiple lines (and
| forget about the "while" loop above).

To make it even clearer, the user should never call yylex, that's the
job of the parser produced by Bison (which will call yylex as many
times as there are tokens), and yyparse shall be call once: it
swallows the whole input by itself.



reply via email to

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