View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001971 | 1003.1(2024)/Issue8 | Shell and Utilities | public | 2026-01-24 11:54 | 2026-03-06 08:12 |
| Reporter | Love4Boobies | Assigned To | |||
| Priority | normal | Severity | Editorial | Type | Enhancement Request |
| Status | New | Resolution | Open | ||
| Name | Bogdan Barbu | ||||
| Organization | |||||
| User Reference | |||||
| Section | lex | ||||
| Page Number | https://pubs.opengroup.org/onlinepubs/9799919799/utilities/lex.html | ||||
| Line Number | N/A | ||||
| Interp Status | |||||
| Final Accepted Text | |||||
| Summary | 0001971: Changing lex prefixes | ||||
| Description | The yacc utility has a -p option that allows the use of a prefix other than the default "yy" - which is useful when linking multiple parsers in the same program/library. Alas, lex does not have a similar option even though they are supposed to be used together. This is an interface mismatch. | ||||
| Desired Action | flex has a -P option that does exactly this, we might want to standardize it. I'm not sure whether implementations other than flex are realistically still in use today but I did look at the historical lex implementation, at IBM's and Heirloom's documentation for lex and a -P option would not be in conflict with these implementations. As a side note, we should ideally also standardize the re-entrancy support found in flex/bison. This would allow programs to instantiate as many concurrent lexers and parsers as they want. The only standard way to do this today is to use arcane locking hacks. | ||||
| Tags | No tags attached. | ||||
|
|
Would you please propose some wording for this option, that we can use as a starting place? Or, if you prefer, point us to a specific wording that you would like to see adopted by the committee? |
|
|
The FreeBSD manual page at https://man.freebsd.org/cgi/man.cgi?query=flex&apropos=0&sektion=0&manpath=FreeBSD+15.0-RELEASE+and+Ports&format=html says: -Pprefix, --prefix=STRING changes the default yy prefix used by flex for all globally-vis- ible variable and function names to instead be prefix. For ex- ample, -Pfoo changes the name of yytext to footext. It also changes the name of the default output file from lex.yy.c to lex.foo.c. ... That's taken from the Flex Texinfo documentation at https://github.com/westes/flex/blob/master/doc/flex.texi. |
|
|
> As a side note, we should ideally also standardize the re-entrancy support found in flex/bison. This would allow programs to instantiate as many concurrent lexers and parsers as they want. Yes - flex and both bison and Berkeley YACC. > The only standard way to do this today is to use arcane locking hacks. Yes, so libpcap, for example, now *requires* both Flex and either Bison or Berkeley YACC to build. |
|
|
Change SYNOPSIS to: lex [-t] [-n|-v] [-P sym_prefix] [file...] --- Add to OPTIONS: -P sym_prefix Use sym_prefix instead of yy as the prefix for all external names produced by lex. The names affected shall include yylex(), yymore(), yyless(), and yywrap(), and the variables yytext, yyleng, and yyin. (In the remainder of this section, the six symbols cited are referenced using their default names only as a notation convenience.) Local names may also be affected by the -P option. --- Change last paragraph in EXTENDED DESCRIPTION from: Except for input(), unput(), and main(), all external and static names generated by lex shall begin with the prefix yy or YY. to: The lex library interfaces need not support interfaces with other than the default yy symbol prefix. Except for input(), unput(), and main(), all external and static names generated by lex shall begin with the prefix yy or YY. If the -P option is used, external names that would otherwise beign with yy shall instead begin with sym_prefix. --- Add to APPLICATION USAGE: When the -P option is used with a prefix other than yy, applications should not rely on the default versions of yywrap() and main() from the lex library, because those interfaces need only support scanners generated with the default symbol prefix. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-01-24 11:54 | Love4Boobies | New Issue | |
| 2026-03-05 16:38 | msbrown | Note Added: 0007385 | |
| 2026-03-05 17:49 | Guy Harris | Note Added: 0007387 | |
| 2026-03-05 17:51 | Guy Harris | Note Added: 0007388 | |
| 2026-03-06 08:12 | Love4Boobies | Note Added: 0007390 |