PTC MKS Toolkit Knowledge Base

Section:IO
Product:MKS Lex and Yacc (All)
Version:
OS:All
Keywords:-p, prefix, yacc
Category:General/Knowledge Base


Why does -p not replace all the yy prefixes in my source?


The -p flag for yacc was fixed in v3.4 to conform to POSIX behaviour.

    -p prefix
    uses prefix instead of the default yy as the prefix for all external names generated by yacc. The names affected include the yyparse(), yylex(), and yyerror() functions and the yylval, yychar, and yydebug variables. Local names are also affected, but yacc-generated #define symbols are not. prefix should be entirely in lowercase because yacc uses an uppercase version of it to replace YY in YYSTYPE. You can also set the prefix with a %prefix directive in the grammar file.

Recognizing that there could be some backwards compatibility issues, we also added the -A flag. This option will replace the yy prefix of ALL identifiers (Note that this does not cover identifiers, such as old_yydef or saved_yydef, because yy is not a prefix in these cases.)