Compilers

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Cygwin 'byacc' question

    5 answers - 1531 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hello
    I'm using Berkley Yacc (byacc) generator from Cygwin package in my
    project and now I'm in the process of switching to the newer version
    of Cygwin. While doing this I ran into the following problem. The old
    version of byacc (identifies itself as 'Berkley Yacc (+28-B19)' and
    appears to be pretty ancient) declared file-scope data in the
    following manner (using 'yycheck' as an example):
    static YYCNST short yycheck[] = { <whatever};
    The new version (identifies itself as 'Berkley Yacc 1.9') taking the
    same input generates a .c file, which declares the same data as
    follows:
    const short yycheck[] = { <whatever};
    Note that the new version no longer declares the data as 'static'. In
    a project that contains several parsers this will normally result in a
    "multiple definition" error for 'yycheck' array (assuming that it is
    compiled with a C complier). That's the problem I ran into. Could
    anyone please shed some light on this issue? Why is the new byacc
    declaring such objects as having external linkage? Is this just a
    matter of configuring byacc properly?
    As a workaround, I can probably use a different prefix for each
    parser, instead of the default 'yy', thus eliminating the name
    conflict, but it is still strange to have the global namespace
    polluted with essentially local names. Any ideas?
    Best regards,
    Andrey Tarasevich
  • No.1 | | 445 bytes | |

    Andrey Tarasevich <andreytarasevich@hotmail.comwrites:
    I'm using Berkley Yacc (byacc) generator from Cygwin package in my
    project and now I'm in the process of switching to the newer version
    of Cygwin. While doing this I ran into the following problem.
    [snip]

    Cygwin also has bison (currently version 1.875b). I don't know
    whether it would solve your problem *or* how much effort it would be
    to switch.
  • No.2 | | 661 bytes | |

    Andrey Tarasevich wrote:

    As a workaround, I can probably use a different prefix for each
    parser, instead of the default 'yy', thus eliminating the name
    conflict, but it is still strange to have the global namespace
    polluted with essentially local names. Any ideas?

    The current bison version has a <prefixoption,
    and it's probably not much trouble to switch from byacc to bison.
    I've switched grammars both ways in the past.

    And the latest Linux byacc that Google shows me has a very similar
    "-p <prefix>" option.
    [The -p option has been available for a very long time. -John]
  • No.3 | | 707 bytes | |

    Keith Thompson wrote:
    Andrey Tarasevich <andreytarasevich@hotmail.comwrites:
    I'm using Berkley Yacc (byacc) generator from Cygwin package in my
    project and now I'm in the process of switching to the newer version
    of Cygwin. While doing this I ran into the following problem.
    [snip]

    Cygwin also has bison (currently version 1.875b). I don't know
    whether it would solve your problem *or* how much effort it would be
    to switch.

    Bison's -p option is designed to solve just this problem: you get to
    choose alternative prefixes for external symbols yyparse, yylex,
    yyerror, yylval, yychar and yydebug (see 'info bison').

  • No.4 | | 1004 bytes | |

    Bill Cox wrote:

    >As a workaround, I can probably use a different prefix for each
    >parser, instead of the default 'yy', thus eliminating the name
    >conflict, but it is still strange to have the global namespace
    >polluted with essentially local names. Any ideas?
    >

    The current bison version has a <prefixoption,
    and it's probably not much trouble to switch from byacc to bison.
    I've switched grammars both ways in the past.

    And the latest Linux byacc that Google shows me has a very similar
    "-p <prefix>" option.
    [The -p option has been available for a very long time. -John]

    I have no problem changing the prefix in byacc. But that's not the
    issue. I just want to know the rationale behind that strange change in
    the declaration format, if there's any. The old one made sense. The
    new one doesn't. Am I missing something? Does anyone actually use
    byacc anymore?
  • No.5 | | 1221 bytes | |

    Andrey Tarasevich <andreytarasevich@hotmail.comwrote:
    Hello

    I'm using Berkley Yacc (byacc) generator from Cygwin package in my
    project and now I'm in the process of switching to the newer version
    of Cygwin. While doing this I ran into the following problem. The old
    version of byacc (identifies itself as 'Berkley Yacc (+28-B19)' and
    appears to be pretty ancient) declared file-scope data in the

    "+28-B19" sounds like a Cygwin version.

    Cygwin has a CVS for this program, which covers part of the changes
    they made. (I don't recall the url - just that I came across it a few
    years ago, and decided that most of the changes I didn't want).

    following manner (using 'yycheck' as an example):

    static YYCNST short yycheck[] = { <whatever};

    The new version (identifies itself as 'Berkley Yacc 1.9') taking the
    same input generates a .c file, which declares the same data as
    follows:

    const short yycheck[] = { <whatever};

    And the original version is written in K&R C and doesn't use const.
    (It didn't use "static" either - which seems the be the impetus for this
    thread).

Re: Cygwin 'byacc' question


max 4000 letters.
Your nickname that display:
In order to stop the spam: 0 + 9 =
QUESTION ON "Compilers"

EMSDN.COM