BISON(1)

๐Ÿ’– NAME ๐Ÿ’–

bison โ€” the GNU Project parser generator, aka the yacc replacement that ate and left no crumbs ๐Ÿ‘‘


โœจ SYNOPSIS โœจ

bison [OPTION]... FILE

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so bestie, bison is a parser generator in the style of yacc(1). It's designed to be upwardly compatible with input files made for yacc, so if you're migrating, you're fine, you're safe, you're thriving. ๐Ÿ’…

Your input files should follow the yacc convention of ending in .y. But here's the glow-up: unlike yacc, the generated files don't have fixed names โ€” they use the prefix of the input file instead. And if you need to put C++ code in the input file, you can end his name with a C++-like extension (.ypp or .y++), and then bison will follow your extension to name the output file (.cpp or .c++). For example, a grammar description file named parse.yxx would produce the generated parser in a file named parse.tab.cxx, instead of yacc's y.tab.c or old Bison version's parse.tab.c. Iconic behavior honestly. ๐ŸŒˆ

This description of the options you can give to bison is adapted from the node Invocation in the bison.texi manual, and that manual should be taken as authoritative. No cap. ๐Ÿ“–

Bison supports both the traditional single-letter options and the mnemonic long option names. Long option names are indicated with -- instead of -. Abbreviations for option names are allowed as long as they're unique. When a long option takes an argument, like --file-prefix, you connect the option name and the argument with =. Simple as. ๐ŸŽ€

It generates a deterministic LR or generalized LR (GLR) parser employing LALR(1), IELR(1), or canonical LR(1) parser tables. Chef's kiss. ๐Ÿ˜˜

Mandatory arguments to long options are mandatory for short options too. The same is true for optional arguments. Periodt.


๐Ÿ› ๏ธ Operation Modes ๐Ÿ› ๏ธ

  • -h, --help โ€” display this help and exit (the classic "help meee" button ๐Ÿ†˜)
  • -V, --version โ€” output version information and exit
  • --print-localedir โ€” output the directory containing locale-dependent data and exit
  • --print-datadir โ€” output the directory containing skeletons and XSLT and exit
  • -u, --update โ€” apply fixes to the source grammar file and exit โœจ
  • -f, --feature[=FEATURES] โ€” activate miscellaneous features

๐ŸŒธ FEATURES ๐ŸŒธ

FEATURES is a list of comma separated words that can include:

  • caret, diagnostics-show-caret โ€” show errors with carets
  • fixit, diagnostics-parseable-fixits โ€” show machine-readable fixes
  • syntax-only โ€” do not generate any file
  • all โ€” all of the above
  • none โ€” disable all of the above

๐Ÿฉบ Diagnostics ๐Ÿฉบ

  • -W, --warnings[=CATEGORY] โ€” report the warnings falling in CATEGORY
  • --color[=WHEN] โ€” whether to colorize the diagnostics
  • --style=FILE โ€” specify the CSS FILE for colorizer diagnostics

๐Ÿ’€ Warning categories include: ๐Ÿ’€

  • conflicts-sr โ€” S/R conflicts (enabled by default)
  • conflicts-rr โ€” R/R conflicts (enabled by default)
  • counterexamples, cex โ€” generate conflict counterexamples
  • dangling-alias โ€” string aliases not attached to a symbol
  • deprecated โ€” obsolete constructs
  • empty-rule โ€” empty rules without %empty
  • midrule-values โ€” unset or unused midrule values
  • precedence โ€” useless precedence and associativity
  • yacc โ€” incompatibilities with POSIX Yacc
  • other โ€” all other warnings (enabled by default)
  • all โ€” all the warnings except 'counterexamples', 'dangling-alias' and 'yacc'
  • no-CATEGORY โ€” turn off warnings in CATEGORY
  • none โ€” turn off all the warnings
  • error[=CATEGORY] โ€” treat warnings as errors ๐Ÿ˜ค

๐ŸŽจ WHEN can be one of the following: ๐ŸŽจ

  • always, yes โ€” colorize the output
  • never, no โ€” don't colorize the output
  • auto, tty โ€” colorize if the output device is a tty

๐Ÿ‘‘ Tuning the Parser ๐Ÿ‘‘

  • -L, --language=LANGUAGE โ€” specify the output programming language
  • -S, --skeleton=FILE โ€” specify the skeleton to use
  • -t, --debug โ€” instrument the parser for tracing, same as '-Dparse.trace'
  • --locations โ€” enable location support ๐Ÿ“
  • -D, --define=NAME[=VALUE] โ€” similar to '%define NAME VALUE'
  • -F, --force-define=NAME[=VALUE] โ€” override '%define NAME VALUE'
  • -p, --name-prefix=PREFIX โ€” prepend PREFIX to the external symbols, deprecated by '-Dapi.prefix={PREFIX}'
  • -l, --no-lines โ€” don't generate '#line' directives
  • -k, --token-table โ€” include a table of token names
  • -y, --yacc โ€” emulate POSIX Yacc

๐Ÿ“ Output Files ๐Ÿ“

  • -H, --header=[FILE] โ€” also produce a header file
  • -d โ€” likewise but cannot specify FILE (for POSIX Yacc)
  • -r, --report=THINGS โ€” also produce details on the automaton
  • --report-file=FILE โ€” write report to FILE
  • -v, --verbose โ€” same as '--report=state'
  • -b, --file-prefix=PREFIX โ€” specify a PREFIX for output files
  • -o, --output=FILE โ€” leave output to FILE
  • -g, --graph[=FILE] โ€” also output a graph of the automaton
  • --html[=FILE] โ€” also output an HTML report of the automaton
  • -x, --xml[=FILE] โ€” also output an XML report of the automaton
  • -M, --file-prefix-map=OLD=NEW โ€” replace prefix OLD with NEW when writing file paths in output files

๐Ÿงš THINGS ๐Ÿงš

THINGS is a list of comma separated words that can include:

  • states โ€” describe the states
  • itemsets โ€” complete the core item sets with their closure
  • lookaheads โ€” explicitly associate lookahead tokens to items
  • solved โ€” describe shift/reduce conflicts solving
  • counterexamples, cex โ€” generate conflict counterexamples
  • all โ€” include all the above information
  • none โ€” disable the report

๐Ÿซถ AUTHOR ๐Ÿซถ

Written by Robert Corbett and Richard Stallman. Legends, honestly. ๐Ÿ’œ


๐Ÿ› REPORTING BUGS ๐Ÿ›

Report bugs to <bug-bison@gnu.org>.

GNU Bison home page: <https://www.gnu.org/software/bison/>.

General help using GNU software: <https://www.gnu.org/gethelp/>.

For complete documentation, run: info bison.


Copyright ยฉ 2021 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. (Yes bestie, that's the legal way of saying "no promises, good luck" ๐Ÿ˜ญ)


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

lex(1), flex(1), yacc(1).

The full documentation for bison is maintained as a Texinfo manual. If the info and bison programs are properly installed at your site, the command

info bison

should give you access to the complete manual.


And that's the whole vibe check, bestie โ€” this was GNU Bison 3.8.2, from September 2021. Go generate some parsers, you absolute icon. Slay. ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from