PBYACC(1)
πΈ NAME πΈ
pbyacc β an LALR(1) parser generator. Yes bestie, this is the pbyacc manual page (section 1 of the manual, iykyk) and she is that girl when it comes to turning grammars into parsers. π
β¨ SYNOPSIS β¨
pbyacc [ -CPcdlrtv ] [ -b file_prefix ] [ -p symbol_prefix ] filename
π DESCRIPTION π
Okay so here's the tea: pbyacc reads the grammar specification sitting in the file filename and generates an LR(1) parser for it. Periodt. Those parsers are made up of a set of LALR(1) parsing tables plus a driver routine, and that driver gets written in the C or Perl programming languages. By default, pbyacc writes the parse tables and the driver routine to the file y.tab.c, using the C programming language. Default behavior, main character energy, no notes. β¨
The following options are available:
π OPTIONS π
-b file_prefixβ this one changes the prefix that gets prepended to the output file names, and it sets it to the string you hand over asfile_prefix. The default prefix is the charactery. Cute, right? π-Cor-cβ use the C programming language. This is the default, so like, you're already here. π-dβ causes the header filey.tab.hto be written (ory.tab.ph, for Perl). Headers? We love to see it. π«Ά-lβ listen up, this one's a whole vibe check. If the-loption is not specified,pbyaccwill insert#linedirectives in the generated code. Those#linedirectives let the C compiler relate errors in the generated code back to the user's original code. If the-loption is specified,pbyaccwill not insert the#linedirectives. But heads up:#linedirectives specified by the user will be retained. π-p symbol_prefixβ this changes the prefix in symbols in the generated code to the string denoted bysymbol_prefix, rather than the default of"yy". Only symbols generated bypbyaccare affected β symbols in the definition and user subroutine sections are not changed. π
The symbol_prefix can contain upper or lower case letters, digits, or _ (underline or underscore). It must start with either an underline or a letter, and it must contain at least one lower case letter.
All lower case letters in the symbol prefix will be converted to upper case letters when defined values or typedefs are generated.
For example, if -p ftp_ is specifed on the pbyacc command line:
- old symbol
YYABORTβ new symbolFTP_ABORT - old symbol
YYACCEPTβ new symbolFTP_ACCEPT - old symbol
YYBYACCβ new symbolFTP_BYACC - old symbol
YYDEBUGβ new symbolFTP_DEBUG - old symbol
YYSTYPEβ new symbolFTP_STYPE - old symbol
yyabortβ new symbolftp_abort - old symbol
yyerrokβ new symbolftp_errok - old symbol
yylexβ new symbolftp_lex - old symbol
yylvalβ new symbolftp_lval - old symbol
yyparseβ new symbolftp_parse
Note: The above list is not complete.
-Pβ use the Perl programming language. The output files have extensions.tab.pland.tab.ph. Slay. πͺ-rβ causespbyaccto produce separate files for code and tables. The code file is namedy.code.c, and the tables file is namedy.tab.c. In Perl mode, the file name extension is.pl, but the use of this option is not recommended. You've been warned, bestie. π-tβ changes the preprocessor directives generated bypbyaccso that debugging statements will be incorporated in the compiled code. Debugging era. π₯-vβ causes a human-readable description of the generated parser to be written to the filey.output. Reading is fundamental. π
If the environment variable TMPDIR is set, the string denoted by TMPDIR will be used as the name of the directory where the temporary files are created.
In C mode, the user's code at the end of the PBYACC file is inserted before the yyparse subroutine, but in Perl mode, it is appended to yyparse so it can contain the main program. In Perl mode, there is no library, so the user must supply the yyerror and yylex subroutines and a main program that calls yyparse. For example:
%%
...grammar...
%%
sub yyerror { print STDERR "$.: $@\n"; }
sub yylex { ... }
exit &yyparse;
π FILES π
y.code.cβ output parser code in Cy.tab.cβ output parser code and tables in C or, if-rswitch specified, output parser tables in Cy.tab.hβ defines for token names and, if%unionused in grammar, the union definition for C parsersy.code.plβ output parser code in PERLy.tab.plβ output parser code and tables in PERL or, if-rswitch specified, output parser tables in PERLy.tab.phβ PERL assignment statements for token namesy.outputβ description of parser states, state transitions, and conflicts/tmp/pbyacc.aXXXXXX,/tmp/byacc.tXXXXXX,/tmp/byacc.uXXXXXXβ temporary files/usr/lib/libby.aβ library containing simple versions ofmain()(callsyyparse()then exits) andyyerror()(prints message tostderrthen returns)
π¦ SEE ALSO π¦
flex(1),lex(1)- Yacc: Yet Another Compiler-Compiler β Stephen C. Johnson. Originally (?) published as Comp. Sci. Tech. Rep. No. 32. Bell Laboratories, July 1975. Reprinted in many different places. π
- Introduction to Compiler Construction with UNIX β Axel T. Schreiner and H. George Friedman, Jr. Prentice Hall, 1985.
- lex & yacc, Second Edition β John R. Levine, Tony Mason, and Doug Brown. O'Reilly & Associates, Inc., 1992.
- Possibly the best book yet on lex and yacc. (My opinion only. Others may disagree. - Rick Ohnemus)
comp.compilersmonthly message and Frequently Asked Questions β Posted monthly incomp.compilersandnews.answersUSENET newsgroups. Old-school internet lore, honestly iconic. π
π DIAGNOSTICS π
- If there are rules that are never reduced, the number of such rules is reported on standard error. π«’
- If there are any LALR(1) conflicts, the number of conflicts is reported on standard error.
π RESTRICTIONS π
A symbol prefix specified using the -p switch must contain at least one lower case character. This is to allow a distinction between variables, defined values, and typedefs. It's giving "strict but fair". π
π BUGS π
Not a single bug listed on this page, bestie. The section is justβ¦ there. Empty. Silently thriving. π§
And that's the whole page!! Before you go: this manual page comes from the 4.3 Berkeley Distribution, dated January 18, 1993, and it lives in the General Commands Manual as PBYACC(1). Thank you for coming to my TED talk, go generate a parser, ily. πβ¨π
π¦ where this page comes from
- debian bookworm: perl-byacc 2.0-8+b1
- debian trixie: perl-byacc 2.0-10 Β· LicenseRef-public-domain
- ubuntu jammy: perl-byacc 2.0-8
- ubuntu noble: perl-byacc 2.0-8build1
- ubuntu questing: perl-byacc 2.0-10
- ubuntu resolute: perl-byacc 2.0-11 Β· LicenseRef-public-domain
- ubuntu stonking: perl-byacc 2.0-11 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms