YACC(1)

πŸ’– YACC(1) β€” bestie edition πŸ’–

okay so real talk: this is a page from the General Commands Manual, and it's about a whole parser generator. yes, the yacc energy. grab a boba, we're doing this πŸ§‹βœ¨


🌸 NAME 🌸

Yacc β€” an LALR(1) parser generator for Java. that's it, that's the whole vibe. iconic. πŸ‘‘


✨ SYNOPSIS ✨

byaccj [ -dlrtvJ ] [ -b prefix ] [-Jclass= classname ] [-Jpackage=
package_name ] [-Jextends= extends_name ] [-Jimplements= implements_name
] [-Jsemantic= semantic_type ] [-Jnorun] [-Jnocontruct] [-Jstack= NNN ]
[-Jnodebug] [-Jfinal] [-Jthrows= exception_list ] filename

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie: Yacc reads the grammar specification sitting in the file filename and generates an LR(1) parser for it. yes, from a grammar. it's giving ✨alchemy✨ but make it computer science.

the parsers it spits out are made of two things: a set of LALR(1) parsing tables, plus a driver routine written in the C programming language. (yes babe, C, we love a crossover episode.)

normally Yacc writes the parse tables and the driver routine into the file y.tab.c. main character file name, honestly.

The following options are available:

πŸ’… OPTIONS πŸ’…

  • -b prefix β€” this one changes the prefix that gets prepended to the output file names, and it becomes the string you put in prefix. the default prefix is the character y. so if you want your files to have a different little nickname, this is your moment πŸŽ€
  • -d β€” makes the header file y.tab.h get written. cute, we love a header. πŸ’–
  • -l β€” okay so if -l is not specified, yacc will insert The generated code to the user's original code. if the -l option is specified, yacc will not insert the
ngl bestie, the original manpage text right here is genuinely glitched/cut off mid-sentence β€” I'm not about to make up the rest of it, so you get exactly what the page says. no cap. 😭
  • -r β€” the -r option causes yacc to produce separate files for code and tables. the code file is named y.code.c, and the tables file is named y.tab.c. splitting the besties up, but for a reason. 🫢
  • -t β€” changes the preprocessor directives generated by yacc so that debugging statements will be incorporated in the compiled code. debug baddie era. πŸ”₯
  • -v β€” causes a human-readable description of the generated parser to be written to the file y.output. it's like a lil diary of your parser, so slay. πŸ““
  • -J β€” switches from C/C++ to Java output. not necessary if other -J flags are used. (it's giving "optional but iconic") β˜•
  • -Jclass=<classname> β€” changes the name of the Java class (and the .java file) to classname. name your baby. πŸ‘Ά
  • -Jpackage=<packagename> β€” changes the package in which the parser resides, from the default <nothing> to packagename. moving out, getting your own place. πŸ“¦
  • -Jextends=<extend_name> β€” changes the class the parser extends, from the default <nothing> to extend_name. family tree update 🌳
  • -Jimplements=<implement_name> β€” changes the interface the parser implements, from the default <nothing> to implement_name. commit to the interface, periodt. πŸ’
  • -Jsemantic=<semantic_type> β€” changes the semantic (value of the rules' variables) type to semantic_type. no extra class will be generated. 🧠
  • -Jnorun β€” informs Byacc to not generate a run() method. useful when working with threads. multitasking queen energy 🧡
  • -Jnoconstruct β€” informs Byacc to not generate constructors. useful when extending classes. πŸ—οΈ
  • -Jstack=<NNN> β€” changes the stack size from the default 500 to NNN. go bigger, go smaller, go feral. πŸ“
  • -Jnodebug β€” informs Byacc to omit debugging code for further better performance. speed demon arc 🏎️
  • -Jfinal β€” makes the generated class final. no more subclasses, sorry not sorry. πŸ”’
  • -Jthrows=<exception_list> β€” informs Byacc to declare thrown exceptions for the yyparse() method. throw it, bestie, throw it. 🎾

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. so if your temp files need to live somewhere specific, that's the move. 🏠


πŸŽ€ FILES πŸŽ€

the whole friend group:

  • y.code.c
  • y.tab.c
  • y.tab.h
  • y.output
  • /tmp/yacc.aXXXXXX
  • /tmp/yacc.tXXXXXX
  • /tmp/yacc.uXXXXXX

πŸ’€ DIAGNOSTICS πŸ’€

if there are rules that are never reduced, the number of such rules is reported on standard error. and if there are any LALR(1) conflicts, the number of conflicts is reported on standard error. so yeah, stderr is where the drama lives β€” check it, don't ignore it. πŸ™ˆ


and that's the whole page, bestie 🫢 this lil legend comes to you from the 4.3 Berkeley Distribution, dated July 15, 1990 β€” yeah, she's vintage, she's a classic, she's still serving. πŸ’œβœ¨ mwah, go build a parser.

πŸ“¦ where this page comes from