This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

eg bison errors


Hello,

Please point me to the appropriate group or forum for asking this question. 
Thank you.

I'm using bison 1.28 and flex 2.5.4 for compilation.

To better my understanding of Bison, I would like to see  some good bison
grammars that compile  successfully.  I particularly need help understanding
yyparse, yylex, and other pertinent yy commands to successfully build a
pascal-like compiler.  The lexer is for  the most part written.  The scanner
(parser) is what remains.  If I can get some working examples on bison, that
would help me see that my bison application is working and  help me to use
bison well enough to allow command line reading and writing. 

I have used the examples for arithmetic & leo from this university course site.


The main course site:
http://www.cs.colorado.edu/~main/proglang/programs/prog01.html

The example files for lexer and parser:
http://www.cs.colorado.edu/~main/proglang/
http://www.cs.colorado.edu/~main/proglang/examples/

By compiling downloaded the O'Reilly examples, the 'implicit declaration' error
resulted.  I think that the error means that the function needs to be
prototyped in the bison or flex file _or_ a library file such as #include
<stdlib.h> needs to be included.   

Here is an error that I received when I compiled ch1-05.l & ch1-05.y using
Bison 1.28 under cygwin.

/bfeg/egoreilly/c15>  $ g++ -Wall -c -gstabs ch1-05.tab.c
/usr/share/bison.simple: In function `int yyparse()':
/usr/share/bison.simple:361: implicit declaration of function `int free(...)'
/usr/share/bison.simple:432: implicit declaration of function `int yylex(...)'

Error: /usr/share/bison.simple:361: implicit declaration of function `int
free(...)'
To get rid of this error, I included #include <stdlib.h> inside of the bison
file.

Error: /usr/share/bison.simple:432: implicit declaration of function `int
yylex(...)'
To get rid of this error, I think that I can prototype int yylex(); inside of
the bison file.  That seems to work.  

Error:
/usr/share/bison.simple:643: warning: previous implicit declaration of
`yyerror'
ch1-05.y:38: warning: `yyerror' was previously implicitly declared to return
`int'

This one about yyerror is perplexing indeed.  :)  I don't understand why
yyerror is having a problem right now.  Do you think that I might need to
include other header files or prototypes to get rid of the yyerror?

I wasn't getting this error message before, but now I am.  How might I fix this
error?

ch1-05.l:454: warning: `void yyunput(int, char *)' defined but not used
/usr/lib/libfl.a(libmain.o)(.text+0xd):libmain.c: undefined reference to
`yylex'
collect2: ld returned 1 exit status


Below is what I see at the cygwin prompt when I compile.

$ flex -t ch1-05.l > ch1-05.cxx
$ bison -d ch1-05.y

$ gcc -Wall -gstabs -DFLEX_DEBUG ch1-05.cxx -lfl -o c1
ch1-05.l:454: warning: `void yyunput(int, char *)' defined but not used
/usr/lib/libfl.a(libmain.o)(.text+0xd):libmain.c: undefined reference to
`yylex'
collect2: ld returned 1 exit status

$ gcc -Wall -c -gstabs ch1-05.cxx
ch1-05.l:454: warning: `void yyunput(int, char *)' defined but not used

$ gcc -Wall -c -gstabs ch1-05.tab.c
/usr/share/bison.simple: In function `yyparse':
/usr/share/bison.simple:358: warning: implicit declaration of function
`yyerror'
ch1-05.y: At top level:
ch1-05.y:31: warning: return type of `main' is not `int'
ch1-05.y:38: warning: type mismatch with previous implicit declaration
/usr/share/bison.simple:643: warning: previous implicit declaration of
`yyerror'
ch1-05.y:38: warning: `yyerror' was previously implicitly declared to return
`int'

$ gcc -Wall -gstabs ch1-05.tab.o ch1-05.lex.o -lfl -o c15
gcc: ch1-05.lex.o: No such file or directory

=====
Fractal A.                    fractala@yahoo.com

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]