<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 5. Invoking Happy</title><link rel="stylesheet" href="fptools.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="Happy User Guide"><link rel="up" href="index.html" title="Happy User Guide"><link rel="prev" href="sec-AttributeGrammarExample.html" title="4.4. Example Attribute Grammars"><link rel="next" href="sec-grammar-files.html" title="Chapter 6. Syntax of Grammar Files"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Invoking <span class="application">Happy</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-AttributeGrammarExample.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="sec-grammar-files.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="sec-invoking"></a>Chapter 5. Invoking <span class="application">Happy</span></h2></div></div></div><p>An invocation of <span class="application">Happy</span> has the following syntax:</p><pre class="screen">$ happy [ <span class="emphasis"><em>options</em></span> ] <span class="emphasis"><em>filename</em></span> [ <span class="emphasis"><em>options</em></span> ]</pre><p>All the command line options are optional (!) and may occur either before or after the input file name. Options that take arguments may be given multiple times, and the last occurrence will be the value used.</p><p>There are two types of grammar files, <code class="filename">file.y</code> and <code class="filename">file.ly</code>, with the latter observing the reverse comment (or literate) convention (i.e. each code line must begin with the character <code class="literal">></code>, lines which don't begin with <code class="literal">></code> are treated as comments). The examples distributed with <span class="application">Happy</span> are all of the .ly form.</p><a class="indexterm" name="id2549225"></a><p>The flags accepted by <span class="application">Happy</span> are as follows:</p><div class="variablelist"><dl><dt><span class="term"><code class="option">-o</code> <em class="replaceable"><code>file</code></em>, </span><span class="term"><code class="option">--outfile</code>=<em class="replaceable"><code>file</code></em></span></dt><dd><p>Specifies the destination of the generated parser module. If omitted, the parser will be placed in <em class="replaceable"><code>file</code></em><code class="literal">.hs</code>, where <em class="replaceable"><code>file</code></em> is the name of the input file with any extension removed.</p></dd><dt><span class="term"><code class="option">-i</code>[<span class="optional"><em class="replaceable"><code>file</code></em></span>], </span><span class="term"><code class="option">--info</code>[<span class="optional">=<em class="replaceable"><code>file</code></em></span>]</span></dt><dd><a class="indexterm" name="id2549302"></a><p> Directs <span class="application">Happy</span> to produce an info file containing detailed information about the grammar, parser states, parser actions, and conflicts. Info files are vital during the debugging of grammars. The filename argument is optional (note that there's no space between <code class="literal">-i</code> and the filename in the short version), and if omitted the info file will be written to <em class="replaceable"><code>file</code></em><code class="literal">.info</code> (where <em class="replaceable"><code>file</code></em> is the input file name with any extension removed).</p></dd><dt><span class="term"><code class="option">-t</code> <em class="replaceable"><code>dir</code></em>, </span><span class="term"><code class="option">--template</code>=<em class="replaceable"><code>dir</code></em></span></dt><dd><a class="indexterm" name="id2549364"></a><p>Instructs <span class="application">Happy</span> to use this directory when looking for template files: these files contain the static code that <span class="application">Happy</span> includes in every generated parser. You shouldn't need to use this option if <span class="application">Happy</span> is properly configured for your computer.</p></dd><dt><span class="term"><code class="option">-m</code> <em class="replaceable"><code>name</code></em>, </span><span class="term"><code class="option">--magic-name</code>=<em class="replaceable"><code>name</code></em></span></dt><dd><p> <span class="application">Happy</span> prefixes all the symbols it uses internally with either <code class="literal">happy</code> or <code class="literal">Happy</code>. To use a different string, for example if the use of <code class="literal">happy</code> is conflicting with one of your own functions, specify the prefix using the <code class="option">-m</code> option.</p></dd><dt><span class="term"><code class="option">-s</code>, </span><span class="term"><code class="option">--strict</code></span></dt><dd><p>NOTE: the <code class="option">--strict</code> option is experimental and may cause unpredictable results.</p><p>This option causes the right hand side of each production (the semantic value) to be evaluated eagerly at the moment the production is reduced. If the lazy behaviour is not required, then using this option will improve performance and may reduce space leaks. Note that the parser as a whole is never lazy - the whole input will always be consumed before any input is produced, regardless of the setting of the <code class="option">--strict</code> flag.</p></dd><dt><span class="term"><code class="option">-g</code>, </span><span class="term"><code class="option">--ghc</code></span></dt><dd><a class="indexterm" name="id2549500"></a><a class="indexterm" name="id2549509"></a><p>Instructs <span class="application">Happy</span> to generate a parser that uses GHC-specific extensions to obtain faster code.</p></dd><dt><span class="term"><code class="option">-c</code>, </span><span class="term"><code class="option">--coerce</code></span></dt><dd><a class="indexterm" name="id2549545"></a><a class="indexterm" name="id2549554"></a><p> Use GHC's <code class="literal">unsafeCoerce#</code> extension to generate smaller faster parsers. Type-safety isn't compromised.</p><p>This option may only be used in conjuction with <code class="option">-g</code>.</p></dd><dt><span class="term"><code class="option">-a</code>, </span><span class="term"><code class="option">--arrays</code></span></dt><dd><a class="indexterm" name="id2549598"></a><a class="indexterm" name="id2549606"></a><p> Instructs <span class="application">Happy</span> to generate a parser using an array-based shift reduce parser. When used in conjunction with <code class="option">-g</code>, the arrays will be encoded as strings, resulting in faster parsers. Without <code class="option">-g</code>, standard Haskell arrays will be used.</p></dd><dt><span class="term"><code class="option">-d</code>, </span><span class="term"><code class="option">--debug</code></span></dt><dd><a class="indexterm" name="id2549652"></a><a class="indexterm" name="id2549661"></a><p>Generate a parser that will print debugging information to <code class="literal">stderr</code> at run-time, including all the shifts, reductions, state transitions and token inputs performed by the parser.</p><p>This option can only be used in conjunction with <code class="option">-a</code>.</p></dd><dt><span class="term"><code class="option">-?</code>, </span><span class="term"><code class="option">--help</code></span></dt><dd><p>Print usage information on standard output then exit successfully.</p></dd><dt><span class="term"><code class="option">-V</code>, </span><span class="term"><code class="option">--version</code></span></dt><dd><p>Print version information on standard output then exit successfully. Note that for legacy reasons <code class="option">-v</code> is supported, too, but the use of it is deprecated. <code class="option">-v</code> will be used for verbose mode when it is actually implemented.</p></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-AttributeGrammarExample.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="sec-grammar-files.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.4. Example Attribute Grammars </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. Syntax of Grammar Files</td></tr></table></div></body></html>