[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bison/flex compatibility revisited

From: John
Subject: Re: Bison/flex compatibility revisited
Date: Wed, 26 Feb 2003 20:25:34 -0500 (EST)

> $ egrep 'yylex([^_.]|$)' mailflex.h
> #define yylex maillex
> extern int yylex YY_LEX_PROTO;
> #define YY_DECL int yylex YY_LEX_DECLARATION
> #undef yylex
> $ cat foo.c
> #define YYSTYPE void
> #include "mailflex.h"
> int foo(void) {
>      YYSTYPE *x;
>      return yylex(x);

You're calling yylex() here, but you should be calling maillex().

> If a prefix is used to rename yylex to foolex or something
> similar, it would be nice if the caller need only specify
> "yylex", as bison does, and still have that work with the
> flex header to get the correct foolex() call without having
> to expose everything. See the foo.c example above.

That would defeat the purpose of the namespace. If you set the prefix
to "foo", then you are asking for flex code to exist in the "foo"
namespace, not the "yy" namespace. If we removed "#undef yylex" from
the header, then flex would be invading BOTH the "foo" namespace and
the "yy" namespace.

> If I put C code called by lexical analyzer pattern actions
> in a separate module (a.k.a. file) and need to refer to
> yyin, yyout, etc. I need that to be able to work,
> whether the lexical analyzer is reentrant or not and whether
> a prefix other than yy is specified or not.

Watchoo talkin' bout, Bruce? That's just not what flex does.  Give me
a scenario where this is desirable.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]