LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

happy

parser generator for Haskell, similar to yacc for C

TLDR

Generate parser from grammar file
$ happy [grammar.y] -o [Parser.hs]
copy
Generate with info file for debugging
$ happy -i [grammar.y]
copy
Generate with GHC extensions for faster code
$ happy -g [grammar.y]
copy
Generate array-based parser with GHC string encoding
$ happy -ag [grammar.y]
copy
Generate parser with debugging output at runtime
$ happy -d [grammar.y]
copy
Generate GLR parser
$ happy -l [grammar.y]
copy

SYNOPSIS

happy [options] file

DESCRIPTION

Happy is a parser generator for Haskell, similar to yacc for C. It takes a grammar specification and produces a Haskell parser module.The tool generates LALR parsers from BNF-like grammars and can also produce GLR parsers. It integrates with the Alex lexer generator for complete parsing solutions.

PARAMETERS

FILE

Grammar file (.y).
-o FILE
Output file name. Defaults to FILE.hs.
-i [FILE]
Generate info file with grammar details, parser states, and conflicts.
-g, --ghc
Use GHC-specific extensions for faster parsers.
-a, --array
Generate array-based parser (smaller but slower). Combined with -g, arrays are encoded as strings for faster performance.
-c, --coerce
Use GHC's unsafeCoerce# for smaller, faster parsers. May crash at runtime if grammar has type errors.
-d, --debug
Generate a parser that prints shift/reduce debugging info to stderr.
-l, --glr
Generate a GLR parser instead of LALR(1).
-t DIR, --template=DIR
Directory for template files.
-h, --help
Display help information.
-v, --version
Print version information.

CAVEATS

Haskell specific. Learning curve for grammar syntax. Debugging shift/reduce conflicts.

HISTORY

Happy was created for Haskell as an equivalent to yacc/bison, widely used in Haskell compilers and tools like GHC.

SEE ALSO

alex(1), ghc(1), yacc(1), bison(1)

Copied to clipboard
Kai