help-bison
[Top][All Lists]
Advanced

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

Re: flex+bison and C++, second part (Solved)


From: Tamas Nagy
Subject: Re: flex+bison and C++, second part (Solved)
Date: Thu, 12 Apr 2007 15:10:58 -0700 (PDT)

Hi!

All problem solved by reading and applying:

http://tldp.org/HOWTO/Lex-YACC-HOWTO-5.html

Tamas

> Hi!
> 
> With no parser.c. Main() is in the .y file, the
> following error occured:
> 
> alfa.tab.cpp: In function `int yyparse()':
> alfa.tab.cpp:1097: error: `yylex' undeclared (first
> use this function)
> alfa.tab.cpp:1097: error: (Each undeclared
> identifier
> is reported only once
>    for each function it appears in.)
> alfa.tab.cpp:1315: error: `yyerror' undeclared
> (first
> use this function)
> alfa.ypp: In function `int yyerror(char*)':
> alfa.ypp:323: error: `int yyerror(char*)' used prior
> to declaration
> alfa.ypp:328: error: `vrml_filel_linenum' undeclared
> (first use this function
> 
> --------------------------
> %%
> 
> int yyerror(char * s)
> {
>     extern char yytext[];
>     int linenum;
>     char * ff;
> 
>     linenum = vrml_filel_linenum(&ff);
>     fprintf(stderr, "%s:%d: Error:\n%s  before
> '%s'\n\n\n",
>             ff, linenum, (char *)s, *yytext=='\n'?
> "\\n": yytext);
> 
>     return 0;
> }
> 
> 
> int main()
> {
> 
>     return 0;
> }
> 
> -----------------------
> 
> What should i modify to get it work?
> 
> > Hi!
> > 
> > I also have a parser.c file. (sourcehandler)
> > Should i have to rewrite it to c++ or just link
> it?
> > 
> > Because of this, which is in the .y file:
> >   vrml_filel_init(f, argv[1]);
> > 
> > it cannot compile to c++. Even if #include
> > "prog.tab.h"
> > it cannot see the above function.
> > 
> > I have the bottom files too:
> > > Got link problem (i suppose)
> > > so the general way to compile a lex & yacc
> program
> > > is:
> > > 1. Generate the lexer
> > >      lex my_file.l
> > > 2. Generate the parser
> > >     yacc -d my_file.y
> > > 3. Compile the sources
> > >     cc -c lex.yy.c y.tab.cc
> > > 4. Link the object files (this is what i think
> > your
> > > problem is)
> > >     cc -o my_application lex.yy.o y.tab.ob -ll
> -ly
> > > If you're using flex change the link library
> like
> > > this:
> > >     cc -o my_application lex.yy.o y.tab.ob -lfl
> > -ly
> > > 5. Eat cake
> > > 
> > > it depends on which platform you are developing.
> > > If you're developing on windows use a batch
> file.
> > > -- 
> > > View this message in context:
> > >
> >
>
http://www.nabble.com/flex%2Bbison-and-C%2B%2B%2C-second-part-tf1959860.html#a9905584
> > > Sent from the Gnu - Bison - Help mailing list
> > > archive at Nabble.com.
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > address@hidden
> > > http://lists.gnu.org/mailman/listinfo/help-bison
> > > 
> > 
> > 
> > 
> >        
> >
>
____________________________________________________________________________________
> > It's here! Your new message!  
> > Get new email alerts with the free Yahoo! Toolbar.
> >
> http://tools.search.yahoo.com/toolbar/features/mail/
> > 
> > 
> > _______________________________________________
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/help-bison
> > 
> 
> 
> 
>        
>
____________________________________________________________________________________
> Finding fabulous fares is fun.  
> Let Yahoo! FareChase search your favorite travel
> sites to find flight and hotel bargains.
> http://farechase.yahoo.com/promo-generic-14795097
> 
> 
> _______________________________________________
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-bison
> 



      Don't be flakey.  Get Yahoo! Mail for Mobile and always stay connected to 
friends.    http://mobile.yahoo.com/mail




reply via email to

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