Re: [Flex-help] Error changing yylex return.
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Chris v. <che...@gm...> - 2016-03-01 01:37:57
|
Hey Fabricio, To first order, your code all looks fine to me. It seems like your redeclaration is not making it into main.c -- I'd suggest maybe next looking at the generated flex.h and seeing what it's doing with YY_DECL and yylex. Maybe your %{..%} block has to be moved earlier or later in the first section? -Chris On Mon, Feb 29, 2016 at 2:06 PM, Fabricio S. Paranhos < fab...@gm...> wrote: > Hello, > > I'm trying to change the default return value (int) from yylex to a > structure. According to FLEX manual it's possible to change how yylex is > declared[1]: > > >This definition may be changed by defining the YY_DECL macro. For > >example, you could use: > > > > #define YY_DECL float lexscan( a, b ) float a, b; > > > > In my flex file I declared this way: > > >#define YY_DECL struct token yylex(yyscan_t yyscanner) > > But after using this macro and compiling the final main program I got > the following GCC error: > > >main.c: In function ‘main’: > >main.c:14:7: error: incompatible types when assigning to type ‘struct > >token’ from type ‘int’ > > lol = yylex(scanner); > > > Even after changing how yylex is declared the final result didn't > change. After some search on the web I found this[2] stack overflow > question, but I got the same error from GCC... > > Anybody can help? > > Here are some additional info: > OS: Debian 8 64bit > GCC: Debian 4.9.2-10 4.9.2 > Flex: 2.5.39 > > And here are my source files: > https://gist.github.com/anonymous/49beeae0d85b4a7f91d6 > > Thanks in advance. > > [1] > http://flex.sourceforge.net/manual/Generated-Scanner.html#Generated-Scanner > [2] > https://stackoverflow.com/questions/3796598/returning-non-ints-from-yylex > -- > Fabrício S. Paranhos > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > -- > Flex-help mailing list > Fle...@li... > https://lists.sourceforge.net/lists/listinfo/flex-help > |