<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 1. Introduction</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="index.html" title="Happy User Guide"><link rel="next" href="sec-reporting-bugs.html" title="1.2. Reporting Bugs"></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 1. Introduction</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="sec-reporting-bugs.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="happy-introduction"></a>Chapter 1. Introduction</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="happy-introduction.html#sec-compatibility">1.1. Compatibility</a></span></dt><dt><span class="sect1"><a href="sec-reporting-bugs.html">1.2. Reporting Bugs</a></span></dt><dt><span class="sect1"><a href="sec-license.html">1.3. License</a></span></dt><dt><span class="sect1"><a href="sec-obtaining.html">1.4. Obtaining <span class="application">Happy</span></a></span></dt></dl></div><p> <span class="application">Happy</span> is a parser generator system for Haskell, similar to the tool <span class="application">yacc</span> for C. Like <span class="application">yacc</span>, it takes a file containing an annotated BNF specification of a grammar and produces a Haskell module containing a parser for the grammar. </p><a class="indexterm" name="id2535700"></a><p> <span class="application">Happy</span> is flexible: you can have several <span class="application">Happy</span> parsers in the same program, and each parser may have multiple entry points. <span class="application">Happy</span> can work in conjunction with a lexical analyser supplied by the user (either hand-written or generated by another program), or it can parse a stream of characters directly (but this isn't practical in most cases). In a future version we hope to include a lexical analyser generator with <span class="application">Happy</span> as a single package. </p><p> Parsers generated by <span class="application">Happy</span> are fast; generally faster than an equivalent parser written using parsing combinators or similar tools. Furthermore, any future improvements made to <span class="application">Happy</span> will benefit an existing grammar, without need for a rewrite. </p><p> <span class="application">Happy</span> is sufficiently powerful to parse Haskell itself - there's a freely available Haskell parser written using <span class="application">Happy</span> which can be obtained from <a class="ulink" href="http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne/haskell_libs/hsparser.html" target="_top"> The <code class="literal">hsparser</code> Page</a>, and included with versions of GHC from 5.00 onwards.</p><a class="indexterm" name="id2494735"></a><a class="indexterm" name="id2494745"></a><p> <span class="application">Happy</span> can currently generate four types of parser from a given grammar, the intention being that we can experiment with different kinds of functional code to see which is the best, and compiler writers can use the different types of parser to tune their compilers. The types of parser supported are: </p><div class="orderedlist"><ol type="1"><li><p><a name="item-default-backend"></a>`standard' Haskell 98 (should work with any compiler that compiles Haskell 98).</p></li><li><a class="indexterm" name="id2494794"></a><a class="indexterm" name="id2494803"></a><p>standard Haskell using arrays (this is not the default because we have found this generates slower parsers than <a class="xref" href="happy-introduction.html#item-default-backend">1</a>).</p></li><li><a class="indexterm" name="id2494930"></a><a class="indexterm" name="id2494936"></a><p>Haskell with GHC (Glasgow Haskell) extensions. This is a slightly faster option than <a class="xref" href="happy-introduction.html#item-default-backend">1</a> for Glasgow Haskell users.</p></li><li><p>GHC Haskell with string-encoded arrays. This is the fastest/smallest option for GHC users. If you're using GHC, the optimum flag settings are <code class="literal">-agc</code> (see <a class="xref" href="sec-invoking.html" title="Chapter 5. Invoking Happy">Chapter 5, <i>Invoking <span class="application">Happy</span></i></a>).</p></li></ol></div><p>Happy can also generate parsers which will dump debugging information at run time, showing state transitions and the input tokens to the parser.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-compatibility"></a>1.1. Compatibility</h2></div></div></div><p> <span class="application">Happy</span> is written in Glasgow Haskell. This means that (for the time being), you need GHC to compile it. Any version of GHC >= 3.02 should work.</p><p> Remember: parsers produced using <span class="application">Happy</span> should compile without difficulty under any Haskell 98 complier or interpreter<sup>[<a name="id2495014" href="#ftn.id2495014" class="footnote">1</a>]</sup></p></div><div class="footnotes"><br><hr width="100" align="left"><div class="footnote"><p><sup>[<a name="ftn.id2495014" href="#id2495014" class="para">1</a>] </sup>With one exception: if you have a production with a polymorphic type signature, then a compiler that supports local universal quantification is required. See <a class="xref" href="sec-type-signatures.html" title="2.4. Type Signatures">Section 2.4, “Type Signatures”</a>.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="sec-reporting-bugs.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Happy User Guide </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.2. Reporting Bugs</td></tr></table></div></body></html>