Re: [Flex-devel] yytext and similar in -P scanners
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Will E. <wl...@us...> - 2007-03-30 13:38:32
|
Thanks for the patch. We'll evaluate it for inclusion in the cvs tree. As a point of clarification, though, there is no such thing as "GNU flex", nor has there ever been. The flex program has never been a part of the GNU project, although they did provide some hosting resources for a long time, back in the day. It's just "flex". Thanks, On Friday, 30 March 2007,15:10 +0200, Petr Machata wrote: > Hi list, > > the editor `vile' (aka "vi like emacs") currently fails to build with > new flex, i.e. flex post 2.5.4a. The problem is that in scanners > generated with -P, symbols yytext, yyleng, yylineno and others are not > available. Documentation states that they should be: > > > Within your scanner itself, you can still refer to the global > > variables and functions using either version of their name; but > > externally, they have the modified name. > > I'm sending the patch that should fix this problem. It does the same > thing old flex does, namely it introduces #defines for yy symbols. > > Comments welcome. > > Thanks, > PM > > diff -urp flex-2.5.33/flex.skl flex-2.5.33-pm/flex.skl > --- flex-2.5.33/flex.skl 2006-02-16 23:20:43.000000000 +0100 > +++ flex-2.5.33-pm/flex.skl 2007-03-30 14:04:42.000000000 +0200 > @@ -54,6 +54,32 @@ m4_changequote([[, ]]) > %# the generated scanner as a C-style comment. This is to aid those who > %# edit the skeleton. > %# > + > +%not-for-header > +%if-not-reentrant > +m4_ifelse(M4_YY_PREFIX,yy,, > +#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]] > +#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]] > +#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]] > +#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]] > +#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]] > +#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]] > +#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]] > +#define yyin M4_YY_PREFIX[[in]] > +#define yyleng M4_YY_PREFIX[[leng]] > +#define yylex M4_YY_PREFIX[[lex]] > +#define yylineno M4_YY_PREFIX[[lineno]] > +#define yyout M4_YY_PREFIX[[out]] > +#define yyrestart M4_YY_PREFIX[[restart]] > +#define yytext M4_YY_PREFIX[[text]] > +#define yywrap M4_YY_PREFIX[[wrap]] > +#define yyalloc M4_YY_PREFIX[[alloc]] > +#define yyrealloc M4_YY_PREFIX[[realloc]] > +#define yyfree M4_YY_PREFIX[[free]] > +) > +%endif > +%ok-for-header > + > #define FLEX_SCANNER > #define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION > #define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION > diff -urp flex-2.5.33/skel.c flex-2.5.33-pm/skel.c > --- flex-2.5.33/skel.c 2006-02-21 03:45:41.000000000 +0100 > +++ flex-2.5.33-pm/skel.c 2007-03-30 14:04:43.000000000 +0200 > @@ -59,6 +59,32 @@ const char *skel[] = { > "%# the generated scanner as a C-style comment. This is to aid those who", > "%# edit the skeleton.", > "%#", > + "", > + "%not-for-header", > + "%if-not-reentrant", > + "m4_ifelse(M4_YY_PREFIX,yy,,", > + "#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]]", > + "#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]]", > + "#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]]", > + "#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]]", > + "#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]]", > + "#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]]", > + "#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]]", > + "#define yyin M4_YY_PREFIX[[in]]", > + "#define yyleng M4_YY_PREFIX[[leng]]", > + "#define yylex M4_YY_PREFIX[[lex]]", > + "#define yylineno M4_YY_PREFIX[[lineno]]", > + "#define yyout M4_YY_PREFIX[[out]]", > + "#define yyrestart M4_YY_PREFIX[[restart]]", > + "#define yytext M4_YY_PREFIX[[text]]", > + "#define yywrap M4_YY_PREFIX[[wrap]]", > + "#define yyalloc M4_YY_PREFIX[[alloc]]", > + "#define yyrealloc M4_YY_PREFIX[[realloc]]", > + "#define yyfree M4_YY_PREFIX[[free]]", > + ")", > + "%endif", > + "%ok-for-header", > + "", > "#define FLEX_SCANNER", > "#define YY_FLEX_MAJOR_VERSION 2", > "#define YY_FLEX_MINOR_VERSION 5", > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Flex-devel mailing list > Fle...@li... > https://lists.sourceforge.net/lists/listinfo/flex-devel |