10

Since history questions are considered on topic, I figured I'd ask one that's been bugging me for quite some time and no one I know seems to know the answer. Does anyone know what the historical significance is of the prefix yy? Most of the variables and functions generated by lex start with it, such as yylval, and yylex(). I also remember seeing a utility named yyrsa somewhere, but can't find references to it anywhere now. Inquiring minds want to know!

  • 5
    and I thought this was a vim question :P – xenoterracide Nov 16 '10 at 11:07
10

I think it has something to do with yacc, which has files ending in .y, and requires a function called yylex.

  • 6
    This SO question seems to agree – Michael Mrozek Sep 7 '10 at 15:44
  • 6
    Quoting @peterb's response in the SO post linked by Michael, "there's no apparent meaning discussed beyond simply desiring a namespace. The "yy" in lex.yy.c indicates that the lex output is intended for a yacc parser." Thanks guys! – Timothy Sep 7 '10 at 15:55
2

As others have pointed out here and on StackOverflow, it may simply be a doubling of the y from the name of the yacc utility, used for generating a unique name space.

The POSIX standard reserves the namespaces starting with both yy and YY for yacc with the following paragraph:

Names are of arbitrary length, made up of letters, periods (.), underscores (_), and non-initial digits. Uppercase and lowercase letters are distinct. Conforming applications shall not use names beginning in yy or YY since the yacc parser uses such names. Many of the names appear in the final output of yacc, and thus they should be chosen to conform with any additional rules created by the C compiler to be used. In particular they appear in #define statements.

Unfortunately, the POSIX docs are very bad at relating any form of history as to why things came to be the way that they currently are.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.