HAPPY(1)

πŸ“¦
version 1.20.1.1 Β· 4 versions
, in opensuse-leap 16.0

πŸ’– HAPPY(1) β€” the Happy Parser Generator, explained by your resident Unix bestie πŸŽ€

Okay so happy… it's the parser generator for Haskell, and it lives in the manual section 1 of the Happy Parser Generator pages. Buckle up bestie, we're getting into grammars ✨


πŸ¦‹ SYNOPSIS

happy [OPTION]... file [OPTION]...

🌸 DESCRIPTION

This page is the quick-and-dirty little briefing on the happy command, nothing more πŸ’…

Real talk: this man page was written for the Debian GNU/Linux distribution because the original program literally doesn't ship a manual page of its own 😭 Instead it has documentation in a whole bunch of other formats β€” DVI, Info and HTML included β€” so peep below for where to find those.

So what is Happy? It's a parser generator system for Haskell. And HAPPY? Adorable fact: it's a dyslexic acronym for A Yacc-like Haskell Parser generator πŸ‘‘

There are two types of grammar files, file.y and file.ly β€” the .ly ones observe the reverse comment bird track convention, meaning every single code line has to begin with >. The examples that ship with Happy are all of the .ly form, iykyk 🐦

⚠️ Caveat, and listen up: when you're using hbc (Chalmers Haskell), the command argument structure is slightly different. Why? Because the hbc run time system grabs some flags for itself (things like setting the heap size, etc). You can dodge the whole problem by adding a single dash (-) to your command line. So with an hbc-generated version of Happy, the argument structure is:
happy - [OPTION]... file [OPTION]...

✨ OPTIONS ✨

These programs follow the usual GNU command line syntax, with long options starting with two dashes (--). Here's a summary of the options β€” for a complete description, go read the other documentation, bestie 🫢

  • -h, --help β€” shows a summary of options. That's it, that's the whole vibe πŸ’β€β™€οΈ
  • -v, --version β€” prints version information to standard output, then exits successfully. Slay and goodbye ✌️
  • -a, --array β€” tells Happy to generate a parser using an array-based shift reduce parser. Team it up with -g and the arrays get encoded as strings, which means faster parsers πŸ”₯. Without -g? Standard Haskell arrays, no fancy business.
  • -g, --ghc β€” tells Happy to generate a parser that uses GHC-specific extensions to get faster code. Speed demon energy ⚑
  • -c, --coerce β€” uses GHC's unsafeCoerce# extension to generate smaller, faster parsers. But there's a catch, and it's a real one: some type safety is lost, which means a parser generated with -c may compile just fine and then crash at run-time πŸ’€ So definitely compile your grammar without -c first to make sure it's type-correct. This option has quite a significant effect on the performance of the resulting parser β€” but remember, parsers generated this way can only be compiled by GHC 3.02 and above. Also: it may only be used in conjunction with -g.
  • -d, --debug β€” generates a parser that prints debugging information to stderr at run-time, including all the shifts, reductions, state transitions and token inputs the parser performs. Very "let me see your work" of it πŸ‘€ This option may only be used in conjunction with -a.
  • -i [FILE], --info[=FILE] β€” directs Happy to produce an info file with detailed information about the grammar, parser states, parser actions, and conflicts. Info files are vital during the debugging of grammars β€” genuinely, don't skip this one. The filename argument is optional; if you omit it, the info file gets written to FILE.info (where FILE is the input file name with any extension removed). πŸŽ€
  • -o FILE, --outfile=FILE β€” specifies where the generated parser module goes. If you omit it, the parser lands in FILE.hs, where FILE is the name of the input file with any extension removed. And if FILE is -, the generated parser is sent to standard output 🌈
  • -m NAME, --magic-name=NAME β€” Happy prefixes all the symbols it uses internally with either happy or Happy. Want a different string? Say, because happy is conflicting with one of your own functions? Specify the prefix with the -m option. Iconic customisation moment πŸ’…
  • -t DIR, --template=DIR β€” instructs Happy to use this directory when looking for template files: these files contain the static code that Happy includes in every generated parser. Ngl, you shouldn't need this option if Happy is properly configured for your computer.
  • -l, --glr β€” instructs Happy to output a GLR parser instead of an LALR(1) parser. Main character energy, different parser entirely πŸ‘‘
  • -k, --decode β€” causes the GLR parser to generate code for decoding the parse forest to a list of semantic results (requires --ghc).
  • -f, --filter β€” causes the GLR parser to filter out nodes which aren't required for the semantic results β€” it's an experimental optimisation, and it requires --ghc πŸ™ˆ

πŸ“ FILES

@LIBDIR@


🧚 SEE ALSO

@DOCDIR@, the Happy homepage (http://haskell.org/happy/) β€” go click, bestie πŸ’œ


Happy Version @VERSION@

Copyright (c) 1993-1996 Andy Gill, Simon Marlow; (c) 1997-2001 Simon Marlow


🌈 AUTHOR

This manual page was written by Michael Weber <michaelw@debian.org>, for the Debian GNU/Linux system (but may be used by others). Respect the author, periodt 🫢


And that's the whole page! This queen came to you from the Glasgow FP Suite, dated 2000-12-23 β€” yeah, she's a vintage icon and she still ate πŸ’–βœ¨

πŸ“¦ where this page comes from