Re: [Flex-help] FW: Question regarding yyunput
flex is a tool for generating scanners
Brought to you by:
wlestes
From: <thu...@ag...> - 2007-02-14 21:42:06
|
Hi Aaron, Many many thanks for your help. I made it works finally! Beside = adding=20 void egs_unput(int c) { unput(c); } I also add: int egs_input() { input (); }=20 You don't know how much I appreciate your suggestions and helps. This = is my first attempt to port something from the UX to the PC, and I had = stucked at this point for a loooooooooong looooooooong time. I wanted = to port it over at the minimal effort, I did not want to rewrite the = code (left from someone, anyway). I alse have many more like this to = port over. Thanks again, Thuyen Vu >=20 > > Anyway, I did what you suggest and run into more problem. =20 > Here is the > > process: > >=20 > > - Modified my egslex.l and egssubs.c file to replace all=20 > yyinput and > > yyunput to input and unput. >=20 > Ok, I'm not sure about yyinput vs. input, but if it works that's good. >=20 > > - Recompiled and got the following errors: > >=20 > > cc -O egsarc.o egslex.o egssubs.o egs2pig.o egs_dflt.o -lm=20 > -o egs2pig > > egssubs.o:egssubs.c:(.text+0xfb): undefined reference to `_input' > > egssubs.o:egssubs.c:(.text+0x148): undefined reference to `_input' > > egssubs.o:egssubs.c:(.text+0x1a6): undefined reference to `_input' > > egssubs.o:egssubs.c:(.text+0x1e3): undefined reference to `_unput' > > egssubs.o:egssubs.c:(.text+0x221): undefined reference to `_unput' > > egssubs.o:egssubs.c:(.text+0x27b): undefined reference to `_input' > > egssubs.o:egssubs.c:(.text+0x4ba): undefined reference to `_input' > > egssubs.o:egssubs.c:(.text+0x4ec): undefined reference to `_input' > > collect2: ld returned 1 exit status > >=20 > > Is this because in the 'lex.yy.c' file created by the flex from my=20 > > egslex.l file, the yyunput is and yyinput are defined static? >=20 > If you're calling those functions from outside of lex.yy.c,=20 > then yes, being static is a slight problem. The most=20 > quick-and-dirty way to handle this is to write a wrapper=20 > function inside egslex.l: >=20 > void egs_unput(int c) { unput(c); } >=20 > And call egs_unput from your other source files. Typically=20 > you'd want to have the actions that are called from the lexer=20 > actions to be in the lexer file so that they have access to=20 > these static functions. But if you've set up your code some=20 > other way, wrapper functions will do the trick. >=20 > Aaron >=20 |