flex
flex copied to clipboard
String scanning examples in manual not working
flex 2.6.4 gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
command I used for compiling:
flex string1.lex
gcc yy.lex.c -lfl
error message:
string1.lex: In function ‘yylex’:
string1.lex:30:17: warning: implicit declaration of function ‘yyinput’; did you mean ‘yyunput’? [-Wimplicit-function-declaration]
inch = yyinput();
^~~~~~~
yyunput
/home/xguo/tmp/ccZsMNq1.o: In function `yylex':
lex.yy.c:(.text+0x31c): undefined reference to `yyinput'
lex.yy.c:(.text+0x33f): undefined reference to `yyinput'
lex.yy.c:(.text+0x3a3): undefined reference to `yyinput'
lex.yy.c:(.text+0x3fd): undefined reference to `yyinput'
lex.yy.c:(.text+0x479): undefined reference to `yyinput'
For string2.lex:
flex string2.lex
gcc yy.lex.c -lfl
and got error:
string2.lex: In function ‘yylex’:
string2.lex:33:22: warning: implicit declaration of function ‘yybegin’; did you mean ‘yyset_in’? [-Wimplicit-function-declaration]
yybegin(STRING);
^~~~~~~
yyset_in
/home/xguo/tmp/ccGyK9lC.o: In function `yylex':
lex.yy.c:(.text+0x32f): undefined reference to `yybegin'
lex.yy.c:(.text+0x35e): undefined reference to `yybegin'
lex.yy.c:(.text+0x38d): undefined reference to `yybegin'
lex.yy.c:(.text+0x788): undefined reference to `yybegin'
For string1.lex, a workaround I found is adding #define yyinput input
.
For string2.lex, I have to use %option stack
and yy_push_state
to workaround the issue.
I just started to learn using using flex to do lexical analyzing, so not sure this is the correct way to use flex. Also I found quite some typos in the latest manual.
after I compiled flex from latest repo, the issue is gone.
But I found the same issue also happens on centos8
The manual definitely needs attention. Were you working with the example scanners from section 4 of the manual when you encountered these errors? Can you share one of your source .lex files?
It sounds like a default option changed between 2.6.4 and the repo HEAD. Should be easy enough to fix up in you options block.
Bravo for building from source!
On Fri, Dec 10, 2021, 02:05 Xiaoyong Guo @.***> wrote:
after I compiled flex from latest repo, the issue is gone.
But I found the same issue also happens on centos8
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/westes/flex/issues/510#issuecomment-990669414, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVJXIO7C3KDACIMPE2CBGTUQGRCHANCNFSM5JX3WUGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.