Re: [Flex-help] FW: Question regarding yyunput
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Aaron S. <aa...@se...> - 2007-02-13 22:55:48
|
On Tue, Feb 13, 2007, thu...@ag... said: > > Hi Aaron, > > Thank you for getting back to me. I have tried to submit this SEVERAL > times! And nobody had time to respond yet, it's a free help list, after all :-) > Anyway, I did what you suggest and run into more problem. Here is the > process: > > - Modified my egslex.l and egssubs.c file to replace all yyinput and > yyunput to input and unput. Ok, I'm not sure about yyinput vs. input, but if it works that's good. > - Recompiled and got the following errors: > > cc -O egsarc.o egslex.o egssubs.o egs2pig.o egs_dflt.o -lm -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 > > Is this because in the 'lex.yy.c' file created by the flex from my egslex.l > file, the yyunput is and yyinput are defined static? If you're calling those functions from outside of lex.yy.c, then yes, being static is a slight problem. The most quick-and-dirty way to handle this is to write a wrapper function inside egslex.l: void egs_unput(int c) { unput(c); } And call egs_unput from your other source files. Typically you'd want to have the actions that are called from the lexer actions to be in the lexer file so that they have access to these static functions. But if you've set up your code some other way, wrapper functions will do the trick. Aaron |