/usr/local/poudriere/data/packages/e24a8cae34360705d022f17584bb6b4507b8eb89-build1/All/hs-happy-1.19.5.txz vs.
/usr/local/poudriere/data/packages/e24a8cae34360705d022f17584bb6b4507b8eb89-build2/All/hs-happy-1.19.5.txz
hs-happy-1.19.5.txz-content
+MANIFEST
Offset 1, 1 lines modifiedOffset 1, 1 lines modified
1 {"name":​"hs-​happy",​"origin":​"devel/​hs-​happy",​"version":​"1.​19.​5",​"comment":​"Happy·​is·​a·​parser·​generator·​for·​Haskell",​"maintainer":​"haskell@FreeBSD.​org",​"www":​"http:​/​/​www.​haskell.​org/​happy/​",​"abi":​"FreeBSD:​11:​amd64",​"arch":​"freebsd:​11:​x86:​64",​"prefix":​"/​usr/​local",​"flatsize":​1372462,​"licenselogic":​"single",​"licenses":​["BSD3CLAUSE"],​"desc":​"Happy·​is·​a·​parser·​generator·​system·​for·​Haskell.​\n\nWWW:​·​http:​/​/​www.​haskell.​org/​happy/​",​"deps":​{"gmp":​{"origin":​"math/​gmp",​"version":​"5.​1.​3_3"},​"ghc":​{"origin":​"lang/​ghc",​"version":​"7.​10.​2"},​"hs-​mtl":​{"origin":​"devel/​hs-​mtl",​"version":​"2.​2.​1"},​"gcc":​{"origin":​"lang/​gcc",​"version":​"4.​8.​5_2"}},​"categories":​["devel",​"haskell"],​"shlibs_required":​["libHSmtl-​2.​2.​1-​KMpng31YRYc5JfMWFZ3FC​U-​ghc7.​10.​2.​so",​"libcharset.​so.​1",​"libgmp.​so.​10",​"libHSghc-​prim-​0.​4.​0.​0-​8TmvWUcS1U1IKHT0levwg​3-​ghc7.​10.​2.​so",​"libHSbase-​4.​8.​1.​0-​GDytRqRVSUX7zckgKqJjg​w-​ghc7.​10.​2.​so",​"libHStransformers-​0.​4.​2.​0-​3eG64VdP2vzGjP6wJiCp5​X-​ghc7.​10.​2.​so",​"libHSdeepseq-​1.​4.​1.​1-​LbCWUlehDDeLxurARKDH5​o-​ghc7.​10.​2.​so",​"libffi.​so.​6",​"·​✂1 {"name":​"hs-​happy",​"origin":​"devel/​hs-​happy",​"version":​"1.​19.​5",​"comment":​"Happy·​is·​a·​parser·​generator·​for·​Haskell",​"maintainer":​"haskell@FreeBSD.​org",​"www":​"http:​/​/​www.​haskell.​org/​happy/​",​"abi":​"FreeBSD:​11:​amd64",​"arch":​"freebsd:​11:​x86:​64",​"prefix":​"/​usr/​local",​"flatsize":​1372462,​"licenselogic":​"single",​"licenses":​["BSD3CLAUSE"],​"desc":​"Happy·​is·​a·​parser·​generator·​system·​for·​Haskell.​\n\nWWW:​·​http:​/​/​www.​haskell.​org/​happy/​",​"deps":​{"gmp":​{"origin":​"math/​gmp",​"version":​"5.​1.​3_3"},​"ghc":​{"origin":​"lang/​ghc",​"version":​"7.​10.​2"},​"hs-​mtl":​{"origin":​"devel/​hs-​mtl",​"version":​"2.​2.​1"},​"gcc":​{"origin":​"lang/​gcc",​"version":​"4.​8.​5_2"}},​"categories":​["devel",​"haskell"],​"shlibs_required":​["libHSmtl-​2.​2.​1-​KMpng31YRYc5JfMWFZ3FC​U-​ghc7.​10.​2.​so",​"libcharset.​so.​1",​"libgmp.​so.​10",​"libHSghc-​prim-​0.​4.​0.​0-​8TmvWUcS1U1IKHT0levwg​3-​ghc7.​10.​2.​so",​"libHSbase-​4.​8.​1.​0-​GDytRqRVSUX7zckgKqJjg​w-​ghc7.​10.​2.​so",​"libHStransformers-​0.​4.​2.​0-​3eG64VdP2vzGjP6wJiCp5​X-​ghc7.​10.​2.​so",​"libHSdeepseq-​1.​4.​1.​1-​LbCWUlehDDeLxurARKDH5​o-​ghc7.​10.​2.​so",​"libffi.​so.​6",​"·​✂
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/happy-introduction.html
Offset 1, 42 lines modifiedOffset 1, 42 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 1.​ Introduction</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​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"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 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"·​title="Chapter 1.​ Introduction"><div·​class·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 1.​ Introduction</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​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"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 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"·​title="Chapter 1.​ Introduction"><div·​class·​✂
2 ····​system·​for·​Haskell,​·​similar·​to·​the·​tool2 ····​system·​for·​Haskell,​·​similar·​to·​the·​tool
3 ····​<span·​class="application">y​acc</​span>·​for·​C.​··​Like3 ····​<span·​class="application">y​acc</​span>·​for·​C.​··​Like
4 ····​<span·​class="application">y​acc</​span>,​·​it·​takes·​a·​file·​containing·​an4 ····​<span·​class="application">y​acc</​span>,​·​it·​takes·​a·​file·​containing·​an
5 ····​annotated·​BNF·​specification·​of·​a·​grammar·​and·​produces·​a·​Haskell5 ····​annotated·​BNF·​specification·​of·​a·​grammar·​and·​produces·​a·​Haskell
6 ····​module·​containing·​a·​parser·​for·​the·​grammar.​·​</​p><a·​class="indexterm"·​name="idp63076792"></​a><p>·​<span·​class="application">H​appy</​span>·​is·​flexible:​·​you·​can·​have·​several6 ····​module·​containing·​a·​parser·​for·​the·​grammar.​·​</​p><a·​class="indexterm"·​name="idp63142328"></​a><p>·​<span·​class="application">H​appy</​span>·​is·​flexible:​·​you·​can·​have·​several
7 ····​<span·​class="application">H​appy</​span>·​parsers·​in·​the·​same·​program,​·​and7 ····​<span·​class="application">H​appy</​span>·​parsers·​in·​the·​same·​program,​·​and
8 ····​each·​parser·​may·​have·​multiple·​entry·​points.​8 ····​each·​parser·​may·​have·​multiple·​entry·​points.​
9 ····​<span·​class="application">H​appy</​span>·​can·​work·​in·​conjunction·​with·​a9 ····​<span·​class="application">H​appy</​span>·​can·​work·​in·​conjunction·​with·​a
10 ····​lexical·​analyser·​supplied·​by·​the·​user·​(either·​hand-​written·​or10 ····​lexical·​analyser·​supplied·​by·​the·​user·​(either·​hand-​written·​or
11 ····​generated·​by·​another·​program)​,​·​or·​it·​can·​parse·​a·​stream·​of11 ····​generated·​by·​another·​program)​,​·​or·​it·​can·​parse·​a·​stream·​of
12 ····​characters·​directly·​(but·​this·​isn't·​practical·​in·​most·​cases)​.​··​In12 ····​characters·​directly·​(but·​this·​isn't·​practical·​in·​most·​cases)​.​··​In
13 ····​a·​future·​version·​we·​hope·​to·​include·​a·​lexical·​analyser·​generator13 ····​a·​future·​version·​we·​hope·​to·​include·​a·​lexical·​analyser·​generator
14 ····​with·​<span·​class="application">H​appy</​span>·​as·​a·​single·​package.​·​</​p><p>·​Parsers·​generated·​by·​<span·​class="application">H​appy</​span>·​are14 ····​with·​<span·​class="application">H​appy</​span>·​as·​a·​single·​package.​·​</​p><p>·​Parsers·​generated·​by·​<span·​class="application">H​appy</​span>·​are
15 ····​fast;​·​generally·​faster·​than·​an·​equivalent·​parser·​written·​using15 ····​fast;​·​generally·​faster·​than·​an·​equivalent·​parser·​written·​using
16 ····​parsing·​combinators·​or·​similar·​tools.​··​Furthermore,​·​any·​future16 ····​parsing·​combinators·​or·​similar·​tools.​··​Furthermore,​·​any·​future
17 ····​improvements·​made·​to·​<span·​class="application">H​appy</​span>·​will·​benefit17 ····​improvements·​made·​to·​<span·​class="application">H​appy</​span>·​will·​benefit
18 ····​an·​existing·​grammar,​·​without·​need·​for·​a·​rewrite.​·​</​p><p>·​<span·​class="application">H​appy</​span>·​is·​sufficiently·​powerful18 ····​an·​existing·​grammar,​·​without·​need·​for·​a·​rewrite.​·​</​p><p>·​<span·​class="application">H​appy</​span>·​is·​sufficiently·​powerful
19 ····​to·​parse·​full·​Haskell19 ····​to·​parse·​full·​Haskell
20 ····​-​·​<a·​class="ulink"·​href="http:​/​/​www.​haskell.​org/​ghc"·​target="_top">GHC</​a>·​itself·​uses20 ····​-​·​<a·​class="ulink"·​href="http:​/​/​www.​haskell.​org/​ghc"·​target="_top">GHC</​a>·​itself·​uses
21 ····​a·​Happy·​parser.​</​p><a·​class="indexterm"·​name="idp63082680"></​a><a·​class="indexterm"·​name="idp63083576"></​a><p>·​<span·​class="application">H​appy</​span>·​can·​currently·​generate21 ····​a·​Happy·​parser.​</​p><a·​class="indexterm"·​name="idp63148216"></​a><a·​class="indexterm"·​name="idp63149112"></​a><p>·​<span·​class="application">H​appy</​span>·​can·​currently·​generate
22 ····​four·​types·​of·​parser·​from·​a·​given·​grammar,​·​the·​intention·​being22 ····​four·​types·​of·​parser·​from·​a·​given·​grammar,​·​the·​intention·​being
23 ····​that·​we·​can·​experiment·​with·​different·​kinds·​of·​functional·​code·​to23 ····​that·​we·​can·​experiment·​with·​different·​kinds·​of·​functional·​code·​to
24 ····​see·​which·​is·​the·​best,​·​and·​compiler·​writers·​can·​use·​the·​different24 ····​see·​which·​is·​the·​best,​·​and·​compiler·​writers·​can·​use·​the·​different
25 ····​types·​of·​parser·​to·​tune·​their·​compilers.​··​The·​types·​of·​parser25 ····​types·​of·​parser·​to·​tune·​their·​compilers.​··​The·​types·​of·​parser
26 ····​supported·​are:​·​</​p><div·​class="orderedlist"><​ol·​class="orderedlist"·​type="1"><li·​class="listitem"><p><​a·​name="item-​default-​backend"></​a>`standard'·​Haskell·​98·​(should·​work·​with·​any·​compiler26 ····​supported·​are:​·​</​p><div·​class="orderedlist"><​ol·​class="orderedlist"·​type="1"><li·​class="listitem"><p><​a·​name="item-​default-​backend"></​a>`standard'·​Haskell·​98·​(should·​work·​with·​any·​compiler
27 »       ​that·​compiles·​Haskell·​98)​.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63087672"></​a><a·​class="indexterm"·​name="idp63088440"></​a><p>standard·​Haskell·​using·​arrays·​(this·​is·​not·​the·​default27 »       ​that·​compiles·​Haskell·​98)​.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63153208"></​a><a·​class="indexterm"·​name="idp63153976"></​a><p>standard·​Haskell·​using·​arrays·​(this·​is·​not·​the·​default
28 »       ​because·​we·​have·​found·​this·​generates·​slower·​parsers·​than·​<a·​class="xref"·​href="happy-​introduction.​html#item-​default-​backend">1</​a>)​.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63090744"></​a><a·​class="indexterm"·​name="idp63091384"></​a><p>Haskell·​with·​GHC·​(Glasgow·​Haskell)​·​extensions.​·​This·​is·​a28 »       ​because·​we·​have·​found·​this·​generates·​slower·​parsers·​than·​<a·​class="xref"·​href="happy-​introduction.​html#item-​default-​backend">1</​a>)​.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63156280"></​a><a·​class="indexterm"·​name="idp63156920"></​a><p>Haskell·​with·​GHC·​(Glasgow·​Haskell)​·​extensions.​·​This·​is·​a
29 »       ​slightly·​faster·​option·​than·​<a·​class="xref"·​href="happy-​introduction.​html#item-​default-​backend">1</​a>·​for·​Glasgow·​Haskell29 »       ​slightly·​faster·​option·​than·​<a·​class="xref"·​href="happy-​introduction.​html#item-​default-​backend">1</​a>·​for·​Glasgow·​Haskell
30 »       ​users.​</​p></​li><li·​class="listitem"><p>G​HC·​Haskell·​with·​string-​encoded·​arrays.​··​This·​is·​the30 »       ​users.​</​p></​li><li·​class="listitem"><p>G​HC·​Haskell·​with·​string-​encoded·​arrays.​··​This·​is·​the
31 »       ​fastest/​smallest·​option·​for·​GHC·​users.​··​If·​you're·​using·​GHC,​31 »       ​fastest/​smallest·​option·​for·​GHC·​users.​··​If·​you're·​using·​GHC,​
32 »       ​the·​optimum·​flag·​settings·​are·​<code·​class="literal">-​agc</​code>·​(see32 »       ​the·​optimum·​flag·​settings·​are·​<code·​class="literal">-​agc</​code>·​(see
33 »       ​<a·​class="xref"·​href="sec-​invoking.​html"·​title="Chapter 5.​ Invoking·​Happy">Chapter 5,​·​<i>Invoking·​<span·​class="application">H​appy</​span></​i></​a>)​.​</​p></​li></​ol></​div><p>Happy·​can·​also·​generate·​parsers·​which·​will·​dump·​debugging33 »       ​<a·​class="xref"·​href="sec-​invoking.​html"·​title="Chapter 5.​ Invoking·​Happy">Chapter 5,​·​<i>Invoking·​<span·​class="application">H​appy</​span></​i></​a>)​.​</​p></​li></​ol></​div><p>Happy·​can·​also·​generate·​parsers·​which·​will·​dump·​debugging
34 ····​information·​at·​run·​time,​·​showing·​state·​transitions·​and·​the·​input34 ····​information·​at·​run·​time,​·​showing·​state·​transitions·​and·​the·​input
35 ····​tokens·​to·​the·​parser.​</​p><div·​class="sect1"·​title="1.​1.​ Compatibility"><div·​class="titlepage"><di​v><div><h2·​class="title"·​style="clear:​·​both"><a·​name="sec-​compatibility"></​a>1.​1.​ Compatibility</​h2></​div></​div></​div><p>·​<span·​class="application">H​appy</​span>·​is·​written·​in·​Glasgow·​Haskell.​··​This35 ····​tokens·​to·​the·​parser.​</​p><div·​class="sect1"·​title="1.​1.​ Compatibility"><div·​class="titlepage"><di​v><div><h2·​class="title"·​style="clear:​·​both"><a·​name="sec-​compatibility"></​a>1.​1.​ Compatibility</​h2></​div></​div></​div><p>·​<span·​class="application">H​appy</​span>·​is·​written·​in·​Glasgow·​Haskell.​··​This
36 ······​means·​that·​(for·​the·​time·​being)​,​·​you·​need·​GHC·​to·​compile·​it.​36 ······​means·​that·​(for·​the·​time·​being)​,​·​you·​need·​GHC·​to·​compile·​it.​
37 ······​Any·​version·​of·​GHC·​&gt;​=·​6.​2·​should·​work.​</​p><p>·​Remember:​·​parsers·​produced·​using37 ······​Any·​version·​of·​GHC·​&gt;​=·​6.​2·​should·​work.​</​p><p>·​Remember:​·​parsers·​produced·​using
38 ······​<span·​class="application">H​appy</​span>·​should·​compile·​without38 ······​<span·​class="application">H​appy</​span>·​should·​compile·​without
39 ······​difficulty·​under·​any·​Haskell·​98·​compiler·​or·​interpreter<sup>[<a·​name="idp63110072"·​href="#ftn.​idp63110072"·​class="footnote">1</​a>]</​sup></​p></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63110072"·​href="#idp63110072"·​class="para">1</​a>]·​</​sup>With·​one39 ······​difficulty·​under·​any·​Haskell·​98·​compiler·​or·​interpreter<sup>[<a·​name="idp63175608"·​href="#ftn.​idp63175608"·​class="footnote">1</​a>]</​sup></​p></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63175608"·​href="#idp63175608"·​class="para">1</​a>]·​</​sup>With·​one
40 »       ​exception:​·​if·​you·​have·​a·​production·​with·​a·​polymorphic·​type·​signature,​40 »       ​exception:​·​if·​you·​have·​a·​production·​with·​a·​polymorphic·​type·​signature,​
41 »       ​then·​a·​compiler·​that·​supports·​local·​universal·​quantification·​is41 »       ​then·​a·​compiler·​that·​supports·​local·​universal·​quantification·​is
42 »       ​required.​··​See·​<a·​class="xref"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures">Section 2​.​4,​·​&#8220;​Type·​Signatures&#8221;​</​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>42 »       ​required.​··​See·​<a·​class="xref"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures">Section 2​.​4,​·​&#8220;​Type·​Signatures&#8221;​</​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>
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/index.html
Offset 1, 2 lines modifiedOffset 1, 2 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Happy·​User·​Guide</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><meta·​name="description"·​content="This·​document·​describes·​Happy,​·​the·​Haskell·​Parser·​Generator,​·​version·​1.​18.​"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="next"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Happy·​User·​Guide</​th></​tr><tr><td·​width="20%"·​align="left"> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="happy-​introduction.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="book"·​title="Happy·​User·​Guide"><div·​class="titlepage"><di​v><div><h1·​class="title"><a·​name="happy"></​a>Happy·​User·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Happy·​User·​Guide</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><meta·​name="description"·​content="This·​document·​describes·​Happy,​·​the·​Haskell·​Parser·​Generator,​·​version·​1.​18.​"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="next"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Happy·​User·​Guide</​th></​tr><tr><td·​width="20%"·​align="left"> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="happy-​introduction.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="book"·​title="Happy·​User·​Guide"><div·​class="titlepage"><di​v><div><h1·​class="title"><a·​name="happy"></​a>Happy·​User·​✂
2 »       ​Generator,​·​version·​1.​18.​</​p></​div></​div></​div><hr></​div><div·​class="toc"><p><b>Tab​le·​of·​Contents</​b></​p><dl><dt><span·​class="chapter"><a·​href="happy-​introduction.​html">1.​·​Introduction</​a></​span></​dt><dd><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">H​appy</​span></​a></​span></​dt></​dl></​dd><dt><span·​class="chapter"><a·​href="sec-​using.​html">2.​·​Using·​<span·​class="application">H​appy</​span></​a></​span></​dt><dd><dl><dt><span·​class="sect1"><a·​href="sec-​using.​html#sec-​other-​datatypes">2.​1.​·​Returning·​other·​datatypes</​a></​span></​dt><dt><span·​class="sect1"><a·​href="sec-​sequences.​html">2.​2.​·​Parsing·​sequences</​a></​span></​dt><dd><dl><dt><span·​class="sect2"><a·​href="sec-​sequences.​html#sec-​separators·​✂2 »       ​Generator,​·​version·​1.​18.​</​p></​div></​div></​div><hr></​div><div·​class="toc"><p><b>Tab​le·​of·​Contents</​b></​p><dl><dt><span·​class="chapter"><a·​href="happy-​introduction.​html">1.​·​Introduction</​a></​span></​dt><dd><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">H​appy</​span></​a></​span></​dt></​dl></​dd><dt><span·​class="chapter"><a·​href="sec-​using.​html">2.​·​Using·​<span·​class="application">H​appy</​span></​a></​span></​dt><dd><dl><dt><span·​class="sect1"><a·​href="sec-​using.​html#sec-​other-​datatypes">2.​1.​·​Returning·​other·​datatypes</​a></​span></​dt><dt><span·​class="sect1"><a·​href="sec-​sequences.​html">2.​2.​·​Parsing·​sequences</​a></​span></​dt><dd><dl><dt><span·​class="sect2"><a·​href="sec-​sequences.​html#sec-​separators·​✂
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/ix01.html
Offset 1, 1 lines modifiedOffset 1, 1 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Index</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​monad-​alex.​html"·​title="8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Index<​/​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​monad-​alex.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> </​td></​tr></​table><hr></​div><div·​class="index"·​title="Index"><div·​class="titlepage"><di​v><div><h2·​class="title"><a·​name="idp64079544"></​a>Index</​h2></​div></​div></​div><div·​class="index"><div·​class="indexdiv"><h3>​Symbols<·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Index</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​monad-​alex.​html"·​title="8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Index<​/​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​monad-​alex.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> </​td></​tr></​table><hr></​div><div·​class="index"·​title="Index"><div·​class="titlepage"><di​v><div><h2·​class="title"><a·​name="idp64145080"></​a>Index</​h2></​div></​div></​div><div·​class="index"><div·​class="indexdiv"><h3>​Symbols<·​✂
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-AtrributeGrammarsInHappy.html
Offset 40, 15 lines modifiedOffset 40, 15 lines modified
40 ·······​and·​<code·​class="literal">value​</​code>·​would·​be·​the·​default·​attribute.​40 ·······​and·​<code·​class="literal">value​</​code>·​would·​be·​the·​default·​attribute.​
41 ·······​</​p></​div><div·​class="sect2"·​title="4.​2.​2.​ Semantic·​Rules"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​semanticRules"></​a>4.​2.​2.​ Semantic·​Rules</​h3></​div></​div></​div><p>In·​an·​ordinary·​Happy·​grammar,​·​a·​production·​consists·​of·​a·​list41 ·······​</​p></​div><div·​class="sect2"·​title="4.​2.​2.​ Semantic·​Rules"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​semanticRules"></​a>4.​2.​2.​ Semantic·​Rules</​h3></​div></​div></​div><p>In·​an·​ordinary·​Happy·​grammar,​·​a·​production·​consists·​of·​a·​list
42 ······​of·​terminals·​and/​or·​non-​terminals·​followed·​by·​an·​uninterpreted42 ······​of·​terminals·​and/​or·​non-​terminals·​followed·​by·​an·​uninterpreted
43 ······​code·​fragment·​enclosed·​in·​braces.​··​With·​an·​attribute·​grammar,​·​the43 ······​code·​fragment·​enclosed·​in·​braces.​··​With·​an·​attribute·​grammar,​·​the
44 ······​format·​is·​very·​similar,​·​but·​the·​braces·​enclose·​a·​set·​of·​semantic·​rules44 ······​format·​is·​very·​similar,​·​but·​the·​braces·​enclose·​a·​set·​of·​semantic·​rules
45 ······​rather·​than·​uninterpreted·​Haskell·​code.​··​Each·​semantic·​rule·​is·​either45 ······​rather·​than·​uninterpreted·​Haskell·​code.​··​Each·​semantic·​rule·​is·​either
46 ······​an·​attribute·​calculation·​or·​a·​conditional,​·​and·​rules·​are·​separated·​by46 ······​an·​attribute·​calculation·​or·​a·​conditional,​·​and·​rules·​are·​separated·​by
47 ······​semicolons<sup>[<a·​name="idp63742264"·​href="#ftn.​idp63742264"·​class="footnote">3</​a>]</​sup>.​47 ······​semicolons<sup>[<a·​name="idp63807800"·​href="#ftn.​idp63807800"·​class="footnote">3</​a>]</​sup>.​
48 ······​</​p><p>48 ······​</​p><p>
49 ······​Both·​attribute·​calculations·​and·​conditionals·​may·​contain·​attribute·​references49 ······​Both·​attribute·​calculations·​and·​conditionals·​may·​contain·​attribute·​references
50 ······​and/​or·​terminal·​references.​··​Just·​like·​regular·​Happy·​grammars,​·​the·​tokens50 ······​and/​or·​terminal·​references.​··​Just·​like·​regular·​Happy·​grammars,​·​the·​tokens
51 ······​<code·​class="literal">$1</​code>·​through·​<code·​class="literal">$&lt;​n&gt;​</​code>,​·​where51 ······​<code·​class="literal">$1</​code>·​through·​<code·​class="literal">$&lt;​n&gt;​</​code>,​·​where
52 ······​<code·​class="literal">n</​code>·​is·​the·​number·​of·​symbols·​in·​the·​production,​·​refer·​to52 ······​<code·​class="literal">n</​code>·​is·​the·​number·​of·​symbols·​in·​the·​production,​·​refer·​to
53 ······​subtrees·​of·​the·​parse.​··​If·​the·​referenced·​symbol·​is·​a·​terminal,​·​then·​the53 ······​subtrees·​of·​the·​parse.​··​If·​the·​referenced·​symbol·​is·​a·​terminal,​·​then·​the
54 ······​value·​of·​the·​reference·​is·​just·​the·​value·​of·​the·​terminal,​·​the·​same·​way·​as54 ······​value·​of·​the·​reference·​is·​just·​the·​value·​of·​the·​terminal,​·​the·​same·​way·​as
Offset 101, 10 lines modifiedOffset 101, 10 lines modified
101 ······​if·​the·​inherited·​length·​attribute·​is·​not·​0.​101 ······​if·​the·​inherited·​length·​attribute·​is·​not·​0.​
102 ······​</​p><pre·​class="programlisting​">102 ······​</​p><pre·​class="programlisting​">
103 where·​if·​$$.​length·​==·​0·​then·​()​·​else·​error·​"length·​not·​equal·​to·​0"103 where·​if·​$$.​length·​==·​0·​then·​()​·​else·​error·​"length·​not·​equal·​to·​0"
104 </​pre><p>104 </​pre><p>
105 ······​This·​conditional·​is·​the·​monadic·​equivalent:​105 ······​This·​conditional·​is·​the·​monadic·​equivalent:​
106 ······​</​p><pre·​class="programlisting​">106 ······​</​p><pre·​class="programlisting​">
107 where·​unless·​($$.​length·​==·​0)​·​(fail·​"length·​not·​equal·​to·​0")​107 where·​unless·​($$.​length·​==·​0)​·​(fail·​"length·​not·​equal·​to·​0")​
108 </​pre></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63742264"·​href="#idp63742264"·​class="para">3</​a>]·​</​sup>Note·​that·​semantic·​rules·​must·​not·​rely·​on108 </​pre></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63807800"·​href="#idp63807800"·​class="para">3</​a>]·​</​sup>Note·​that·​semantic·​rules·​must·​not·​rely·​on
109 ······​layout,​·​because·​whitespace·​alignment·​is·​not·​guaranteed·​to·​be109 ······​layout,​·​because·​whitespace·​alignment·​is·​not·​guaranteed·​to·​be
110 ······​preserved</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="sec-​AttributeGrammar.​html">Prev</​a> </​td><td·​width="20%"·​align="center"><a·​accesskey="u"·​href="sec-​AttributeGrammar.​html">Up</​a></​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="sec-​AttrGrammarLimits.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">Chapter ​4.​ Attribute·​Grammars </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> 4.​3.​ Limits·​of·​Happy·​Attribute·​Grammars</​td></​tr></​table></​div></​body></​html>110 ······​preserved</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="sec-​AttributeGrammar.​html">Prev</​a> </​td><td·​width="20%"·​align="center"><a·​accesskey="u"·​href="sec-​AttributeGrammar.​html">Up</​a></​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="sec-​AttrGrammarLimits.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">Chapter ​4.​ Attribute·​Grammars </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> 4.​3.​ Limits·​of·​Happy·​Attribute·​Grammars</​td></​tr></​table></​div></​body></​html>
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-Precedences.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​3.​ Using·​Precedences</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​sequences.​html"·​title="2.​2.​ Parsing·​sequences"><link·​rel="next"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​3.​ Using·​Precedences</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​sequences.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​type-​signatures.​html">Next</​a></​td·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​3.​ Using·​Precedences</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​sequences.​html"·​title="2.​2.​ Parsing·​sequences"><link·​rel="next"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​3.​ Using·​Precedences</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​sequences.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​type-​signatures.​html">Next</​a></​td·​✂
2 ······​wouldn't·​it·​be·​nicer·​if·​we·​didn't·​have·​to·​explicitly·​separate2 ······​wouldn't·​it·​be·​nicer·​if·​we·​didn't·​have·​to·​explicitly·​separate
3 ······​the·​expressions·​into·​terms·​and·​factors,​·​merely·​to·​make·​it3 ······​the·​expressions·​into·​terms·​and·​factors,​·​merely·​to·​make·​it
4 ······​clear·​that·​<code·​class="literal">'*'</​code>·​and·​<code·​class="literal">'/​'</​code>4 ······​clear·​that·​<code·​class="literal">'*'</​code>·​and·​<code·​class="literal">'/​'</​code>
5 ······​operators·​bind·​more·​tightly·​than·​<code·​class="literal">'+'</​code>·​and5 ······​operators·​bind·​more·​tightly·​than·​<code·​class="literal">'+'</​code>·​and
6 ······​<code·​class="literal">'-​'</​code>?</​p><p>We·​could·​just·​change·​the·​grammar·​as·​follows·​(making·​the6 ······​<code·​class="literal">'-​'</​code>?</​p><p>We·​could·​just·​change·​the·​grammar·​as·​follows·​(making·​the
7 ······​appropriate·​changes·​to·​the·​expression·​datatype·​too)​:​</​p><pre·​class="programlisting​">7 ······​appropriate·​changes·​to·​the·​expression·​datatype·​too)​:​</​p><pre·​class="programlisting​">
8 Exp···​:​·​let·​var·​'='·​Exp·​in·​Exp··​{·​Let·​$2·​$4·​$6·​}8 Exp···​:​·​let·​var·​'='·​Exp·​in·​Exp··​{·​Let·​$2·​$4·​$6·​}
Offset 16, 22 lines modifiedOffset 16, 22 lines modified
16 </​pre><p>but·​now·​Happy·​will·​complain·​that·​there·​are·​shift/​reduce16 </​pre><p>but·​now·​Happy·​will·​complain·​that·​there·​are·​shift/​reduce
17 ······​conflicts·​because·​the·​grammar·​is·​ambiguous·​-​·​we·​haven't17 ······​conflicts·​because·​the·​grammar·​is·​ambiguous·​-​·​we·​haven't
18 ······​specified·​whether·​e.​g.​·​<code·​class="literal">1·​+·​2·​*·​3</​code>·​is·​to·​be18 ······​specified·​whether·​e.​g.​·​<code·​class="literal">1·​+·​2·​*·​3</​code>·​is·​to·​be
19 ······​parsed·​as·​<code·​class="literal">1·​+·​(2·​*·​3)​</​code>·​or·​<code·​class="literal">(1·​+·​2)​·​*19 ······​parsed·​as·​<code·​class="literal">1·​+·​(2·​*·​3)​</​code>·​or·​<code·​class="literal">(1·​+·​2)​·​*
20 ······​3</​code>.​··​Happy·​allows·​these·​ambiguities·​to·​be·​resolved·​by20 ······​3</​code>.​··​Happy·​allows·​these·​ambiguities·​to·​be·​resolved·​by
21 ······​specifying·​the·​<em·​class="firstterm">pre​cedences</​em>·​of·​the21 ······​specifying·​the·​<em·​class="firstterm">pre​cedences</​em>·​of·​the
22 ······​operators·​involved·​using·​directives·​in·​the22 ······​operators·​involved·​using·​directives·​in·​the
23 ······​header<sup>[<a·​name="idp63276216"·​href="#ftn.​idp63276216"·​class="footnote">2</​a>]</​sup>:​</​p><pre·​class="programlisting​">23 ······​header<sup>[<a·​name="idp63341752"·​href="#ftn.​idp63341752"·​class="footnote">2</​a>]</​sup>:​</​p><pre·​class="programlisting​">
24 .​.​.​24 .​.​.​
25 %right·​in25 %right·​in
26 %left·​'+'·​'-​'26 %left·​'+'·​'-​'
27 %left·​'*'·​'/​'27 %left·​'*'·​'/​'
28 %%28 %%
29 .​.​.​29 .​.​.​
30 </​pre><a·​class="indexterm"·​name="idp63277880"></​a><a·​class="indexterm"·​name="idp63278904"></​a><a·​class="indexterm"·​name="idp63279928"></​a><p>The·​<code·​class="literal">%left​</​code>·​or·​<code·​class="literal">%righ​t</​code>30 </​pre><a·​class="indexterm"·​name="idp63343416"></​a><a·​class="indexterm"·​name="idp63344440"></​a><a·​class="indexterm"·​name="idp63345464"></​a><p>The·​<code·​class="literal">%left​</​code>·​or·​<code·​class="literal">%righ​t</​code>
31 ······​directive·​is·​followed·​by·​a·​list·​of·​terminals,​·​and·​declares·​all31 ······​directive·​is·​followed·​by·​a·​list·​of·​terminals,​·​and·​declares·​all
32 ······​these·​tokens·​to·​be·​left·​or·​right-​associative·​respectively.​··​The32 ······​these·​tokens·​to·​be·​left·​or·​right-​associative·​respectively.​··​The
33 ······​precedence·​of·​these·​tokens·​with·​respect·​to·​other·​tokens·​is33 ······​precedence·​of·​these·​tokens·​with·​respect·​to·​other·​tokens·​is
34 ······​established·​by·​the·​order·​of·​the·​<code·​class="literal">%left​</​code>·​and34 ······​established·​by·​the·​order·​of·​the·​<code·​class="literal">%left​</​code>·​and
35 ······​<code·​class="literal">%righ​t</​code>·​directives:​·​earlier·​means·​lower35 ······​<code·​class="literal">%righ​t</​code>·​directives:​·​earlier·​means·​lower
36 ······​precedence.​··​A·​higher·​precedence·​causes·​an·​operator·​to·​bind·​more36 ······​precedence.​··​A·​higher·​precedence·​causes·​an·​operator·​to·​bind·​more
37 ······​tightly;​·​in·​our·​example·​above,​·​because·​<code·​class="literal">'*'</​code>37 ······​tightly;​·​in·​our·​example·​above,​·​because·​<code·​class="literal">'*'</​code>
Offset 86, 17 lines modifiedOffset 86, 17 lines modified
86 ······​|·​Exp·​'+'·​Exp·············​{·​Plus·​$1·​$3·​}86 ······​|·​Exp·​'+'·​Exp·············​{·​Plus·​$1·​$3·​}
87 ······​|·​Exp·​'-​'·​Exp·············​{·​Minus·​$1·​$3·​}87 ······​|·​Exp·​'-​'·​Exp·············​{·​Minus·​$1·​$3·​}
88 ······​|·​Exp·​'*'·​Exp·············​{·​Times·​$1·​$3·​}88 ······​|·​Exp·​'*'·​Exp·············​{·​Times·​$1·​$3·​}
89 ······​|·​Exp·​'/​'·​Exp·············​{·​Div·​$1·​$3·​}89 ······​|·​Exp·​'/​'·​Exp·············​{·​Div·​$1·​$3·​}
90 ······​|·​'('·​Exp·​')​'·············​{·​Brack·​$2·​}90 ······​|·​'('·​Exp·​')​'·············​{·​Brack·​$2·​}
91 ······​|·​'-​'·​Exp·​%prec·​NEG·······​{·​Negate·​$2·​}91 ······​|·​'-​'·​Exp·​%prec·​NEG·······​{·​Negate·​$2·​}
92 ······​|·​int·····················​{·​Int·​$1·​}92 ······​|·​int·····················​{·​Int·​$1·​}
93 ······​|·​var·····················​{·​Var·​$1·​}</​pre><a·​class="indexterm"·​name="idp63315768"></​a><p>We·​invent·​a·​new·​token·​<code·​class="literal">NEG</​code>·​as·​a93 ······​|·​var·····················​{·​Var·​$1·​}</​pre><a·​class="indexterm"·​name="idp63381304"></​a><p>We·​invent·​a·​new·​token·​<code·​class="literal">NEG</​code>·​as·​a
94 »       ​placeholder·​for·​the·​precedence·​of·​our·​prefix·​negation·​rule.​94 »       ​placeholder·​for·​the·​precedence·​of·​our·​prefix·​negation·​rule.​
95 »       ​The·​<code·​class="literal">NEG</​code>·​token·​doesn't·​need·​to·​appear·​in95 »       ​The·​<code·​class="literal">NEG</​code>·​token·​doesn't·​need·​to·​appear·​in
96 »       ​a·​<code·​class="literal">%toke​n</​code>·​directive.​··​The·​prefix·​negation96 »       ​a·​<code·​class="literal">%toke​n</​code>·​directive.​··​The·​prefix·​negation
97 »       ​rule·​has·​a·​<code·​class="literal">%prec​·​NEG</​code>·​directive·​attached,​97 »       ​rule·​has·​a·​<code·​class="literal">%prec​·​NEG</​code>·​directive·​attached,​
98 »       ​which·​overrides·​the·​default·​precedence·​for·​the·​rule·​(which98 »       ​which·​overrides·​the·​default·​precedence·​for·​the·​rule·​(which
99 »       ​would·​normally·​be·​the·​precedence·​of·​'-​')​·​with·​the·​precedence99 »       ​would·​normally·​be·​the·​precedence·​of·​'-​')​·​with·​the·​precedence
100 »       ​of·​<code·​class="literal">NEG</​code>.​</​p></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63276216"·​href="#idp63276216"·​class="para">2</​a>]·​</​sup>Users·​of·​<code·​class="literal">yacc<​/​code>·​will·​find100 »       ​of·​<code·​class="literal">NEG</​code>.​</​p></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63341752"·​href="#idp63341752"·​class="para">2</​a>]·​</​sup>Users·​of·​<code·​class="literal">yacc<​/​code>·​will·​find
101 ······​this·​familiar,​·​Happy's·​precedence·​scheme·​works·​in·​exactly·​the101 ······​this·​familiar,​·​Happy's·​precedence·​scheme·​works·​in·​exactly·​the
102 ······​same·​way.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="sec-​sequences.​html">Prev</​a> </​td><td·​width="20%"·​align="center"><a·​accesskey="u"·​href="sec-​using.​html">Up</​a></​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="sec-​type-​signatures.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">2.​2.​ Parsing·​sequences </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> 2.​4.​ Type·​Signatures</​td></​tr></​table></​div></​body></​html>102 ······​same·​way.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="sec-​sequences.​html">Prev</​a> </​td><td·​width="20%"·​align="center"><a·​accesskey="u"·​href="sec-​using.​html">Up</​a></​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="sec-​type-​signatures.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">2.​2.​ Parsing·​sequences </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> 2.​4.​ Type·​Signatures</​td></​tr></​table></​div></​body></​html>
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-compilation-time.html
Offset 1, 13 lines modifiedOffset 1, 13 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​2.​ Compilation-​Time·​Tips</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="next"·​href="sec-​finding-​errors.​html"·​title="8.​3.​ Finding·​Type·​Errors"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​2.​ Compilation-​Time·​Tips</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​tips.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​finding-​errors.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​title="8.​2.​ ·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​2.​ Compilation-​Time·​Tips</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="next"·​href="sec-​finding-​errors.​html"·​title="8.​3.​ Finding·​Type·​Errors"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​2.​ Compilation-​Time·​Tips</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​tips.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​finding-​errors.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​title="8.​2.​ ·​✂
2 ······​<span·​class="application">H​appy</​span>·​can·​take·​a·​large·​amount·​of·​time/​memory,​·​so2 ······​<span·​class="application">H​appy</​span>·​can·​take·​a·​large·​amount·​of·​time/​memory,​·​so
3 ······​here's·​some·​tips·​on·​making·​things·​more·​sensible:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>·​Include·​as·​little·​code·​as·​possible·​in·​the·​module3 ······​here's·​some·​tips·​on·​making·​things·​more·​sensible:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>·​Include·​as·​little·​code·​as·​possible·​in·​the·​module
4 ··········​trailer.​··​This·​code·​is·​included·​verbatim·​in·​the·​generated4 ··········​trailer.​··​This·​code·​is·​included·​verbatim·​in·​the·​generated
5 ··········​parser,​·​so·​if·​any·​of·​it·​can·​go·​in·​a·​separate·​module,​·​do5 ··········​parser,​·​so·​if·​any·​of·​it·​can·​go·​in·​a·​separate·​module,​·​do
6 ··········​so.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63991480"></​a><p>·​Give·​type·​signatures·​for·​everything·​(see·​<a·​class="xref"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures">Section 2​.​4,​·​&#8220;​Type·​Signatures&#8221;​</​a>.​··​This·​is·​reported·​to·​improve6 ··········​so.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp64057016"></​a><p>·​Give·​type·​signatures·​for·​everything·​(see·​<a·​class="xref"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures">Section 2​.​4,​·​&#8220;​Type·​Signatures&#8221;​</​a>.​··​This·​is·​reported·​to·​improve
7 ··········​things·​by·​about·​50%.​··​If·​there·​is·​a·​type·​signature·​for·​every7 ··········​things·​by·​about·​50%.​··​If·​there·​is·​a·​type·​signature·​for·​every
8 ··········​single·​non-​terminal·​in·​the·​grammar,​·​then·​<span·​class="application">H​appy</​span>8 ··········​single·​non-​terminal·​in·​the·​grammar,​·​then·​<span·​class="application">H​appy</​span>
9 ··········​automatically·​generates·​type·​signatures·​for·​most·​functions9 ··········​automatically·​generates·​type·​signatures·​for·​most·​functions
10 ··········​in·​the·​parser.​</​p></​li><li·​class="listitem"><p>·​Simplify·​the·​grammar·​as·​much·​as·​possible·​(applies·​to10 ··········​in·​the·​parser.​</​p></​li><li·​class="listitem"><p>·​Simplify·​the·​grammar·​as·​much·​as·​possible·​(applies·​to
11 ··········​everything,​·​this·​one)​.​</​p></​li><li·​class="listitem"><p>·​Use·​a·​recent·​version·​of·​GHC.​··​Versions·​from·​4.​0411 ··········​everything,​·​this·​one)​.​</​p></​li><li·​class="listitem"><p>·​Use·​a·​recent·​version·​of·​GHC.​··​Versions·​from·​4.​04
12 »       ​··​onwards·​have·​lower·​memory·​requirements·​for·​compiling12 »       ​··​onwards·​have·​lower·​memory·​requirements·​for·​compiling
13 »       ​··​<span·​class="application">H​appy</​span>-​generated·​parsers.​</​p></​li><li·​class="listitem"><p>·​Using·​<span·​class="application">H​appy</​span>'s·​<code·​class="literal">-​g·​-​a·​-​c</​code>13 »       ​··​<span·​class="application">H​appy</​span>-​generated·​parsers.​</​p></​li><li·​class="listitem"><p>·​Using·​<span·​class="application">H​appy</​span>'s·​<code·​class="literal">-​g·​-​a·​-​c</​code>
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-conflict-tips.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​4.​ Conflict·​Tips</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​finding-​errors.​html"·​title="8.​3.​ Finding·​Type·​Errors"><link·​rel="next"·​href="sec-​happy-​ghci.​html"·​title="8.​5.​ Using·​Happy·​with·​GHCi"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​4.​ Conflict·​Tips</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​finding-​errors.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​happy-​ghci.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​title·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​4.​ Conflict·​Tips</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​finding-​errors.​html"·​title="8.​3.​ Finding·​Type·​Errors"><link·​rel="next"·​href="sec-​happy-​ghci.​html"·​title="8.​5.​ Using·​Happy·​with·​GHCi"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​4.​ Conflict·​Tips</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​finding-​errors.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​happy-​ghci.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​title·​✂
2 ······​some·​input·​sequences·​may·​possess·​more·​than·​one·​parse.​2 ······​some·​input·​sequences·​may·​possess·​more·​than·​one·​parse.​
3 ······​Shift/​reduce·​conflicts·​are·​benign·​in·​the·​sense·​that·​they·​are3 ······​Shift/​reduce·​conflicts·​are·​benign·​in·​the·​sense·​that·​they·​are
4 ······​easily·​resolved·​(<span·​class="application">H​appy</​span>·​automatically·​selects·​the4 ······​easily·​resolved·​(<span·​class="application">H​appy</​span>·​automatically·​selects·​the
5 ······​shift·​action,​·​as·​this·​is·​usually·​the·​intended·​one)​.​5 ······​shift·​action,​·​as·​this·​is·​usually·​the·​intended·​one)​.​
6 ······​Reduce/​reduce·​conflicts·​are·​more·​serious.​··​A·​reduce/​reduce6 ······​Reduce/​reduce·​conflicts·​are·​more·​serious.​··​A·​reduce/​reduce
7 ······​conflict·​implies·​that·​a·​certain·​sequence·​of·​tokens·​on·​the·​input7 ······​conflict·​implies·​that·​a·​certain·​sequence·​of·​tokens·​on·​the·​input
8 ······​can·​represent·​more·​than·​one·​non-​terminal,​·​and·​the·​parser·​is8 ······​can·​represent·​more·​than·​one·​non-​terminal,​·​and·​the·​parser·​is
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-directives.html
Offset 1, 21 lines modifiedOffset 1, 21 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​3.​ Directives</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​module-​header.​html"·​title="6.​2.​ Module·​Header"><link·​rel="next"·​href="sec-​grammar.​html"·​title="6.​4.​ Grammar"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​3.​ Directives</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​module-​header.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​grammar.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class=·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​3.​ Directives</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​module-​header.​html"·​title="6.​2.​ Module·​Header"><link·​rel="next"·​href="sec-​grammar.​html"·​title="6.​4.​ Grammar"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​3.​ Directives</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​module-​header.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​grammar.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class=·​✂
2 %&lt;​directive·​name&gt;​·​&lt;​argument&gt;​·​.​.​.​2 %&lt;​directive·​name&gt;​·​&lt;​argument&gt;​·​.​.​.​
3 </​pre><p>The·​statements·​here·​are·​all·​annotations·​to·​help3 </​pre><p>The·​statements·​here·​are·​all·​annotations·​to·​help
4 ······​<span·​class="application">H​appy</​span>·​generate·​the·​Haskell·​code·​for·​the·​grammar.​4 ······​<span·​class="application">H​appy</​span>·​generate·​the·​Haskell·​code·​for·​the·​grammar.​
5 ······​Some·​of·​them·​are·​optional,​·​and·​some·​of·​them·​are·​required.​</​p><div·​class="sect2"·​title="6.​3.​1.​ Token·​Type"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​token-​type"></​a>6.​3.​1.​ Token·​Type</​h3></​div></​div></​div><pre·​class="programlisting​">5 ······​Some·​of·​them·​are·​optional,​·​and·​some·​of·​them·​are·​required.​</​p><div·​class="sect2"·​title="6.​3.​1.​ Token·​Type"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​token-​type"></​a>6.​3.​1.​ Token·​Type</​h3></​div></​div></​div><pre·​class="programlisting​">
6 %tokentype···​{·​&lt;​valid·​Haskell·​type&gt;​·​}6 %tokentype···​{·​&lt;​valid·​Haskell·​type&gt;​·​}
7 </​pre><a·​class="indexterm"·​name="idp63852856"></​a><p>(mandatory)​·​The·​<code·​class="literal">%toke​ntype</​code>·​directive·​gives·​the7 </​pre><a·​class="indexterm"·​name="idp63918392"></​a><p>(mandatory)​·​The·​<code·​class="literal">%toke​ntype</​code>·​directive·​gives·​the
8 ········​type·​of·​the·​tokens·​passed·​from·​the·​lexical·​analyser·​to·​the8 ········​type·​of·​the·​tokens·​passed·​from·​the·​lexical·​analyser·​to·​the
9 ········​parser·​(in·​order·​that·​<span·​class="application">H​appy</​span>·​can·​supply·​types·​for9 ········​parser·​(in·​order·​that·​<span·​class="application">H​appy</​span>·​can·​supply·​types·​for
10 ········​functions·​and·​data·​in·​the·​generated·​parser)​.​</​p></​div><div·​class="sect2"·​title="6.​3.​2.​ Tokens"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​tokens"></​a>6.​3.​2.​ Tokens</​h3></​div></​div></​div><pre·​class="programlisting​">10 ········​functions·​and·​data·​in·​the·​generated·​parser)​.​</​p></​div><div·​class="sect2"·​title="6.​3.​2.​ Tokens"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​tokens"></​a>6.​3.​2.​ Tokens</​h3></​div></​div></​div><pre·​class="programlisting​">
11 %token·​&lt;​name&gt;​·​{·​&lt;​Haskell·​pattern&gt;​·​}11 %token·​&lt;​name&gt;​·​{·​&lt;​Haskell·​pattern&gt;​·​}
12 ·······​&lt;​name&gt;​·​{·​&lt;​Haskell·​pattern&gt;​·​}12 ·······​&lt;​name&gt;​·​{·​&lt;​Haskell·​pattern&gt;​·​}
13 ·······​.​.​.​13 ·······​.​.​.​
14 </​pre><a·​class="indexterm"·​name="idp63856952"></​a><p>(mandatory)​·​The·​<code·​class="literal">%toke​n</​code>·​directive·​is·​used·​to14 </​pre><a·​class="indexterm"·​name="idp63922488"></​a><p>(mandatory)​·​The·​<code·​class="literal">%toke​n</​code>·​directive·​is·​used·​to
15 ········​tell·​<span·​class="application">H​appy</​span>·​about·​all·​the·​terminal·​symbols·​used15 ········​tell·​<span·​class="application">H​appy</​span>·​about·​all·​the·​terminal·​symbols·​used
16 ········​in·​the·​grammar.​··​Each·​terminal·​has·​a·​name,​·​by·​which·​it·​is16 ········​in·​the·​grammar.​··​Each·​terminal·​has·​a·​name,​·​by·​which·​it·​is
17 ········​referred·​to·​in·​the·​grammar·​itself,​·​and·​a·​Haskell17 ········​referred·​to·​in·​the·​grammar·​itself,​·​and·​a·​Haskell
18 ········​representation·​enclosed·​in·​braces.​··​Each·​of·​the·​patterns·​must18 ········​representation·​enclosed·​in·​braces.​··​Each·​of·​the·​patterns·​must
19 ········​be·​of·​the·​same·​type,​·​given·​by·​the·​<code·​class="literal">%toke​ntype</​code>19 ········​be·​of·​the·​same·​type,​·​given·​by·​the·​<code·​class="literal">%toke​ntype</​code>
20 ········​directive.​</​p><p>The·​name·​of·​each·​terminal·​follows·​the·​lexical·​rules·​for20 ········​directive.​</​p><p>The·​name·​of·​each·​terminal·​follows·​the·​lexical·​rules·​for
21 ········​<span·​class="application">H​appy</​span>·​identifiers·​given·​above.​··​There·​are·​no21 ········​<span·​class="application">H​appy</​span>·​identifiers·​given·​above.​··​There·​are·​no
Offset 24, 76 lines modifiedOffset 24, 76 lines modified
24 ········​for·​example·​using·​upper·​case·​letters·​for·​terminals·​and·​lower24 ········​for·​example·​using·​upper·​case·​letters·​for·​terminals·​and·​lower
25 ········​case·​for·​non-​terminals,​·​or·​vice-​versa.​</​p><p><span·​class="application">H​appy</​span>·​will·​give·​you·​a·​warning·​if·​you·​try25 ········​case·​for·​non-​terminals,​·​or·​vice-​versa.​</​p><p><span·​class="application">H​appy</​span>·​will·​give·​you·​a·​warning·​if·​you·​try
26 ········​to·​use·​the·​same·​identifier·​both·​as·​a·​non-​terminal·​and·​a26 ········​to·​use·​the·​same·​identifier·​both·​as·​a·​non-​terminal·​and·​a
27 ········​terminal,​·​or·​introduce·​an·​identifier·​which·​is·​declared·​as27 ········​terminal,​·​or·​introduce·​an·​identifier·​which·​is·​declared·​as
28 ········​neither.​</​p><p>To·​save·​writing·​lots·​of·​projection·​functions·​that·​map28 ········​neither.​</​p><p>To·​save·​writing·​lots·​of·​projection·​functions·​that·​map
29 ········​tokens·​to·​their·​components,​·​you·​can·​include29 ········​tokens·​to·​their·​components,​·​you·​can·​include
30 ········​<code·​class="literal">$$</​code>·​in·​your·​Haskell·​pattern.​·​For30 ········​<code·​class="literal">$$</​code>·​in·​your·​Haskell·​pattern.​·​For
31 ········​example:​</​p><a·​class="indexterm"·​name="idp63862712"></​a><pre·​class="programlisting​">31 ········​example:​</​p><a·​class="indexterm"·​name="idp63928248"></​a><pre·​class="programlisting​">
32 %token·​INT·​{·​TokenInt·​$$·​}32 %token·​INT·​{·​TokenInt·​$$·​}
33 ·······​.​.​.​33 ·······​.​.​.​
34 </​pre><p>This·​makes·​the·​semantic·​value·​of·​<code·​class="literal">INT</​code>·​refer·​to·​the·​first·​argument34 </​pre><p>This·​makes·​the·​semantic·​value·​of·​<code·​class="literal">INT</​code>·​refer·​to·​the·​first·​argument
35 of·​<code·​class="literal">Token​Int</​code>·​rather·​than·​the·​whole·​token,​·​eliminating·​the·​need·​for35 of·​<code·​class="literal">Token​Int</​code>·​rather·​than·​the·​whole·​token,​·​eliminating·​the·​need·​for
36 any·​projection·​function.​</​p></​div><div·​class="sect2"·​title="6.​3.​3.​ Parser·​Name"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​parser-​name"></​a>6.​3.​3.​ Parser·​Name</​h3></​div></​div></​div><pre·​class="programlisting​">36 any·​projection·​function.​</​p></​div><div·​class="sect2"·​title="6.​3.​3.​ Parser·​Name"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​parser-​name"></​a>6.​3.​3.​ Parser·​Name</​h3></​div></​div></​div><pre·​class="programlisting​">
37 %name·​&lt;​Haskell·​identifier&gt;​·​[·​&lt;​non-​terminal&gt;​·​]37 %name·​&lt;​Haskell·​identifier&gt;​·​[·​&lt;​non-​terminal&gt;​·​]
38 .​.​.​38 .​.​.​
39 </​pre><a·​class="indexterm"·​name="idp63867192"></​a><p>(optional)​·​The·​<code·​class="literal">%name​</​code>·​directive·​is·​followed·​by39 </​pre><a·​class="indexterm"·​name="idp63932728"></​a><p>(optional)​·​The·​<code·​class="literal">%name​</​code>·​directive·​is·​followed·​by
40 ········​a·​valid·​Haskell·​identifier,​·​and·​gives·​the·​name·​of·​the40 ········​a·​valid·​Haskell·​identifier,​·​and·​gives·​the·​name·​of·​the
41 ········​top-​level·​parsing·​function·​in·​the·​generated·​parser.​··​This·​is41 ········​top-​level·​parsing·​function·​in·​the·​generated·​parser.​··​This·​is
42 ········​the·​only·​function·​that·​needs·​to·​be·​exported·​from·​a·​parser42 ········​the·​only·​function·​that·​needs·​to·​be·​exported·​from·​a·​parser
43 ········​module.​</​p><p>If·​the·​<code·​class="literal">%name​</​code>·​directive·​is·​omitted,​·​it43 ········​module.​</​p><p>If·​the·​<code·​class="literal">%name​</​code>·​directive·​is·​omitted,​·​it
44 ········​defaults·​to·​<code·​class="literal">happy​Parse</​code>.​</​p><a·​class="indexterm"·​name="idp63870648"></​a><p>The·​<code·​class="literal">%name​</​code>·​directive·​takes·​an·​optional44 ········​defaults·​to·​<code·​class="literal">happy​Parse</​code>.​</​p><a·​class="indexterm"·​name="idp63936184"></​a><p>The·​<code·​class="literal">%name​</​code>·​directive·​takes·​an·​optional
45 »       ​second·​parameter·​which·​specifies·​the·​top-​level·​non-​terminal45 »       ​second·​parameter·​which·​specifies·​the·​top-​level·​non-​terminal
46 »       ​which·​is·​to·​be·​parsed.​··​If·​this·​parameter·​is·​omitted,​·​it46 »       ​which·​is·​to·​be·​parsed.​··​If·​this·​parameter·​is·​omitted,​·​it
47 »       ​defaults·​to·​the·​first·​non-​terminal·​defined·​in·​the47 »       ​defaults·​to·​the·​first·​non-​terminal·​defined·​in·​the
48 »       ​grammar.​</​p><p>Multiple·​<code·​class="literal">%name​</​code>·​directives·​may·​be48 »       ​grammar.​</​p><p>Multiple·​<code·​class="literal">%name​</​code>·​directives·​may·​be
49 »       ​given,​·​specifying·​multiple·​parser·​entry·​points·​for·​this49 »       ​given,​·​specifying·​multiple·​parser·​entry·​points·​for·​this
50 »       ​grammar·​(see·​<a·​class="xref"·​href="sec-​multiple-​parsers.​html"·​title="2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar">Section 2.​7,​·​&#8220;​Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar&#8221;​</​a>)​.​··​When50 »       ​grammar·​(see·​<a·​class="xref"·​href="sec-​multiple-​parsers.​html"·​title="2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar">Section 2.​7,​·​&#8220;​Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar&#8221;​</​a>)​.​··​When
51 »       ​multiple·​<code·​class="literal">%name​</​code>·​directives·​are·​given,​·​they51 »       ​multiple·​<code·​class="literal">%name​</​code>·​directives·​are·​given,​·​they
52 »       ​must·​all·​specify·​explicit·​non-​terminals.​</​p></​div><div·​class="sect2"·​title="6.​3.​4.​ Partial·​Parsers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​partial-​parsers"></​a>6.​3.​4.​ Partial·​Parsers</​h3></​div></​div></​div><pre·​class="programlisting​">52 »       ​must·​all·​specify·​explicit·​non-​terminals.​</​p></​div><div·​class="sect2"·​title="6.​3.​4.​ Partial·​Parsers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​partial-​parsers"></​a>6.​3.​4.​ Partial·​Parsers</​h3></​div></​div></​div><pre·​class="programlisting​">
53 %partial·​&lt;​Haskell·​identifier&gt;​·​[·​&lt;​non-​terminal&gt;​·​]53 %partial·​&lt;​Haskell·​identifier&gt;​·​[·​&lt;​non-​terminal&gt;​·​]
54 .​.​.​54 .​.​.​
55 </​pre><a·​class="indexterm"·​name="idp63875896"></​a><p>The·​<code·​class="literal">%part​ial</​code>·​directive·​can·​be·​used·​instead·​of55 </​pre><a·​class="indexterm"·​name="idp63941432"></​a><p>The·​<code·​class="literal">%part​ial</​code>·​directive·​can·​be·​used·​instead·​of
56 »       ​··​<code·​class="literal">%name​</​code>.​··​It·​indicates·​that·​the·​generated·​parser56 »       ​··​<code·​class="literal">%name​</​code>.​··​It·​indicates·​that·​the·​generated·​parser
57 »       ​··​should·​be·​able·​to·​parse·​an·​initial·​portion·​of·​the·​input.​··​In57 »       ​··​should·​be·​able·​to·​parse·​an·​initial·​portion·​of·​the·​input.​··​In
58 »       ​··​contrast,​·​a·​parser·​specified·​with·​<code·​class="literal">%name​</​code>·​will·​only58 »       ​··​contrast,​·​a·​parser·​specified·​with·​<code·​class="literal">%name​</​code>·​will·​only
59 »       ​··​parse·​the·​entire·​input.​</​p><p>A·​parser·​specified·​with·​<code·​class="literal">%part​ial</​code>·​will·​stop59 »       ​··​parse·​the·​entire·​input.​</​p><p>A·​parser·​specified·​with·​<code·​class="literal">%part​ial</​code>·​will·​stop
60 »       ​··​parsing·​and·​return·​a·​result·​as·​soon·​as·​there·​exists·​a·​complete·​parse,​60 »       ​··​parsing·​and·​return·​a·​result·​as·​soon·​as·​there·​exists·​a·​complete·​parse,​
61 »       ​··​and·​no·​more·​of·​the·​input·​can·​be·​parsed.​··​It·​does·​this·​by·​accepting61 »       ​··​and·​no·​more·​of·​the·​input·​can·​be·​parsed.​··​It·​does·​this·​by·​accepting
62 »       ​··​the·​parse·​if·​it·​is·​followed·​by·​the·​<code·​class="literal">error​</​code>·​token,​62 »       ​··​the·​parse·​if·​it·​is·​followed·​by·​the·​<code·​class="literal">error​</​code>·​token,​
63 »       ​··​rather·​than·​insisting·​that·​the·​parse·​is·​followed·​by·​the63 »       ​··​rather·​than·​insisting·​that·​the·​parse·​is·​followed·​by·​the
64 »       ​··​end·​of·​the·​token·​stream·​(or·​the·​<code·​class="literal">eof</​code>·​token·​in·​the64 »       ​··​end·​of·​the·​token·​stream·​(or·​the·​<code·​class="literal">eof</​code>·​token·​in·​the
65 »       ​··​case·​of·​a·​<code·​class="literal">%lexe​r</​code>·​parser)​.​</​p></​div><div·​class="sect2"·​title="6.​3.​5.​ Monad·​Directive"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​monad-​decl"></​a>6.​3.​5.​ Monad·​Directive</​h3></​div></​div></​div><pre·​class="programlisting​">65 »       ​··​case·​of·​a·​<code·​class="literal">%lexe​r</​code>·​parser)​.​</​p></​div><div·​class="sect2"·​title="6.​3.​5.​ Monad·​Directive"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​monad-​decl"></​a>6.​3.​5.​ Monad·​Directive</​h3></​div></​div></​div><pre·​class="programlisting​">
66 %monad·​{·​&lt;​type&gt;​·​}·​{·​&lt;​then&gt;​·​}·​{·​&lt;​return&gt;​·​}66 %monad·​{·​&lt;​type&gt;​·​}·​{·​&lt;​then&gt;​·​}·​{·​&lt;​return&gt;​·​}
67 </​pre><a·​class="indexterm"·​name="idp63882808"></​a><p>(optional)​·​The·​<code·​class="literal">%mona​d</​code>·​directive·​takes·​three67 </​pre><a·​class="indexterm"·​name="idp63948344"></​a><p>(optional)​·​The·​<code·​class="literal">%mona​d</​code>·​directive·​takes·​three
68 ········​arguments:​·​the·​type·​constructor·​of·​the·​monad,​·​the68 ········​arguments:​·​the·​type·​constructor·​of·​the·​monad,​·​the
69 ········​<code·​class="literal">then<​/​code>·​(or·​<code·​class="literal">bind<​/​code>)​·​operation,​·​and·​the69 ········​<code·​class="literal">then<​/​code>·​(or·​<code·​class="literal">bind<​/​code>)​·​operation,​·​and·​the
70 ········​<code·​class="literal">retur​n</​code>·​(or·​<code·​class="literal">unit<​/​code>)​·​operation.​··​The·​type70 ········​<code·​class="literal">retur​n</​code>·​(or·​<code·​class="literal">unit<​/​code>)​·​operation.​··​The·​type
71 ········​constructor·​can·​be·​any·​type·​with·​kind·​<code·​class="literal">*·​-​&gt;​·​*</​code>.​</​p><p>Monad·​declarations·​are·​described·​in·​more·​detail·​in·​<a·​class="xref"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers">Section 2.​5,​·​&#8220;​Monadic·​Parsers&#8221;​</​a>.​</​p></​div><div·​class="sect2"·​title="6.​3.​6.​ Lexical·​Analyser"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​lexer-​decl"></​a>6.​3.​6.​ Lexical·​Analyser</​h3></​div></​div></​div><pre·​class="programlisting​">71 ········​constructor·​can·​be·​any·​type·​with·​kind·​<code·​class="literal">*·​-​&gt;​·​*</​code>.​</​p><p>Monad·​declarations·​are·​described·​in·​more·​detail·​in·​<a·​class="xref"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers">Section 2.​5,​·​&#8220;​Monadic·​Parsers&#8221;​</​a>.​</​p></​div><div·​class="sect2"·​title="6.​3.​6.​ Lexical·​Analyser"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​lexer-​decl"></​a>6.​3.​6.​ Lexical·​Analyser</​h3></​div></​div></​div><pre·​class="programlisting​">
72 %lexer·​{·​&lt;​lexer&gt;​·​}·​{·​&lt;​eof&gt;​·​}72 %lexer·​{·​&lt;​lexer&gt;​·​}·​{·​&lt;​eof&gt;​·​}
73 </​pre><a·​class="indexterm"·​name="idp63889592"></​a><p>(optional)​·​The·​<code·​class="literal">%lexe​r</​code>·​directive·​takes·​two73 </​pre><a·​class="indexterm"·​name="idp63967416"></​a><p>(optional)​·​The·​<code·​class="literal">%lexe​r</​code>·​directive·​takes·​two
74 ········​arguments:​·​<code·​class="literal">&lt;​lexer&gt;​</​code>·​is·​the·​name·​of·​the·​lexical74 ········​arguments:​·​<code·​class="literal">&lt;​lexer&gt;​</​code>·​is·​the·​name·​of·​the·​lexical
75 ········​analyser·​function,​·​and·​<code·​class="literal">&lt;​eof&gt;​</​code>·​is·​a·​token·​that75 ········​analyser·​function,​·​and·​<code·​class="literal">&lt;​eof&gt;​</​code>·​is·​a·​token·​that
76 ········​is·​to·​be·​treated·​as·​the·​end·​of·​file.​</​p><p>Lexer·​declarations·​are·​described·​in·​more·​detail·​in·​<a·​class="xref"·​href="sec-​monads.​html#sec-​lexers"·​title="2.​5.​2.​ Threaded·​Lexers">Section 2.​5.​2,​·​&#8220;​Threaded·​Lexers&#8221;​</​a>.​</​p></​div><div·​class="sect2"·​title="6.​3.​7.​ Precedence·​declarations"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​prec-​decls"></​a>6.​3.​7.​ Precedence·​declarations</​h3></​div></​div></​div><pre·​class="programlisting​">76 ········​is·​to·​be·​treated·​as·​the·​end·​of·​file.​</​p><p>Lexer·​declarations·​are·​described·​in·​more·​detail·​in·​<a·​class="xref"·​href="sec-​monads.​html#sec-​lexers"·​title="2.​5.​2.​ Threaded·​Lexers">Section 2.​5.​2,​·​&#8220;​Threaded·​Lexers&#8221;​</​a>.​</​p></​div><div·​class="sect2"·​title="6.​3.​7.​ Precedence·​declarations"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​prec-​decls"></​a>6.​3.​7.​ Precedence·​declarations</​h3></​div></​div></​div><pre·​class="programlisting​">
77 %left·····​&lt;​name&gt;​·​.​.​.​77 %left·····​&lt;​name&gt;​·​.​.​.​
78 %right····​&lt;​name&gt;​·​.​.​.​78 %right····​&lt;​name&gt;​·​.​.​.​
79 %nonassoc·​&lt;​name&gt;​·​.​.​.​79 %nonassoc·​&lt;​name&gt;​·​.​.​.​
80 </​pre><a·​class="indexterm"·​name="idp63907128"></​a><a·​class="indexterm"·​name="idp63908408"></​a><a·​class="indexterm"·​name="idp63913784"></​a><p>These·​declarations·​are·​used·​to·​specify·​the·​precedences80 </​pre><a·​class="indexterm"·​name="idp63972664"></​a><a·​class="indexterm"·​name="idp63973944"></​a><a·​class="indexterm"·​name="idp63979320"></​a><p>These·​declarations·​are·​used·​to·​specify·​the·​precedences
81 »       ​and·​associativity·​of·​tokens.​··​The·​precedence·​assigned·​by·​a81 »       ​and·​associativity·​of·​tokens.​··​The·​precedence·​assigned·​by·​a
82 »       ​<code·​class="literal">%left​</​code>,​·​<code·​class="literal">%righ​t</​code>·​or82 »       ​<code·​class="literal">%left​</​code>,​·​<code·​class="literal">%righ​t</​code>·​or
83 »       ​<code·​class="literal">%nona​ssoc</​code>·​declaration·​is·​defined·​to·​be83 »       ​<code·​class="literal">%nona​ssoc</​code>·​declaration·​is·​defined·​to·​be
84 »       ​higher·​than·​the·​precedence·​assigned·​by·​all·​declarations84 »       ​higher·​than·​the·​precedence·​assigned·​by·​all·​declarations
85 »       ​earlier·​in·​the·​file,​·​and·​lower·​than·​the·​precedence·​assigned·​by85 »       ​earlier·​in·​the·​file,​·​and·​lower·​than·​the·​precedence·​assigned·​by
86 »       ​all·​declarations·​later·​in·​the·​file.​</​p><p>The·​associativity·​of·​a·​token·​relative·​to·​tokens·​in·​the86 »       ​all·​declarations·​later·​in·​the·​file.​</​p><p>The·​associativity·​of·​a·​token·​relative·​to·​tokens·​in·​the
87 »       ​same·​<code·​class="literal">%left​</​code>,​·​<code·​class="literal">%righ​t</​code>,​·​or87 »       ​same·​<code·​class="literal">%left​</​code>,​·​<code·​class="literal">%righ​t</​code>,​·​or
88 »       ​<code·​class="literal">%nona​ssoc</​code>·​declaration·​is·​to·​the·​left,​·​to88 »       ​<code·​class="literal">%nona​ssoc</​code>·​declaration·​is·​to·​the·​left,​·​to
89 »       ​the·​right,​·​or·​non-​associative·​respectively.​</​p><p>Precedence·​declarations·​are·​described·​in·​more·​detail·​in89 »       ​the·​right,​·​or·​non-​associative·​respectively.​</​p><p>Precedence·​declarations·​are·​described·​in·​more·​detail·​in
90 »       ​<a·​class="xref"·​href="sec-​Precedences.​html"·​title="2.​3.​ Using·​Precedences">Section ​2.​3,​·​&#8220;​Using·​Precedences&#8221;​</​a>.​</​p></​div><div·​class="sect2"·​title="6.​3.​8.​ Expect·​declarations"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​expect"></​a>6.​3.​8.​ Expect·​declarations</​h3></​div></​div></​div><pre·​class="programlisting​">90 »       ​<a·​class="xref"·​href="sec-​Precedences.​html"·​title="2.​3.​ Using·​Precedences">Section ​2.​3,​·​&#8220;​Using·​Precedences&#8221;​</​a>.​</​p></​div><div·​class="sect2"·​title="6.​3.​8.​ Expect·​declarations"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​expect"></​a>6.​3.​8.​ Expect·​declarations</​h3></​div></​div></​div><pre·​class="programlisting​">
91 %expect·​&lt;​number&gt;​91 %expect·​&lt;​number&gt;​
92 </​pre><a·​class="indexterm"·​name="idp63921208"></​a><p>(optional)​·​More·​often·​than·​not·​the·​grammar·​you·​write92 </​pre><a·​class="indexterm"·​name="idp63986744"></​a><p>(optional)​·​More·​often·​than·​not·​the·​grammar·​you·​write
93 »       ​will·​have·​conflicts.​·​These·​conflicts·​generate·​warnings.​·​But93 »       ​will·​have·​conflicts.​·​These·​conflicts·​generate·​warnings.​·​But
94 »       ​when·​you·​have·​checked·​the·​warnings·​and·​made·​sure·​that·​Happy94 »       ​when·​you·​have·​checked·​the·​warnings·​and·​made·​sure·​that·​Happy
95 »       ​handles·​them·​correctly·​these·​warnings·​are·​just·​annoying.​·​The95 »       ​handles·​them·​correctly·​these·​warnings·​are·​just·​annoying.​·​The
96 »       ​<code·​class="literal">%expe​ct</​code>·​directive·​gives·​a·​way·​of·​avoiding96 »       ​<code·​class="literal">%expe​ct</​code>·​directive·​gives·​a·​way·​of·​avoiding
97 »       ​them.​·​Declaring·​<code·​class="literal">%expe​ct97 »       ​them.​·​Declaring·​<code·​class="literal">%expe​ct
98 »       ​<em·​class="replaceable"><​code>n</​code></​em></​code>·​is·​a·​way·​of·​telling98 »       ​<em·​class="replaceable"><​code>n</​code></​em></​code>·​is·​a·​way·​of·​telling
99 »       ​Happy·​&#8220;​There·​are·​exactly·​<em·​class="replaceable"><​code>n</​code></​em>99 »       ​Happy·​&#8220;​There·​are·​exactly·​<em·​class="replaceable"><​code>n</​code></​em>
Offset 101, 28 lines modifiedOffset 101, 28 lines modified
101 »       ​this·​grammar.​·​I·​promise·​I·​have·​checked·​them·​and·​they·​are101 »       ​this·​grammar.​·​I·​promise·​I·​have·​checked·​them·​and·​they·​are
102 »       ​resolved·​correctly&#8221;​.​··​When·​processing·​the·​grammar,​·​Happy102 »       ​resolved·​correctly&#8221;​.​··​When·​processing·​the·​grammar,​·​Happy
103 »       ​will·​check·​the·​actual·​number·​of·​conflicts·​against·​the103 »       ​will·​check·​the·​actual·​number·​of·​conflicts·​against·​the
104 »       ​<code·​class="literal">%expe​ct</​code>·​declaration·​if·​any,​·​and·​if·​there·​is104 »       ​<code·​class="literal">%expe​ct</​code>·​declaration·​if·​any,​·​and·​if·​there·​is
105 »       ​a·​discrepancy·​then·​an·​error·​will·​be·​reported.​</​p><p>Happy's·​<code·​class="literal">%expe​ct</​code>·​directive·​works105 »       ​a·​discrepancy·​then·​an·​error·​will·​be·​reported.​</​p><p>Happy's·​<code·​class="literal">%expe​ct</​code>·​directive·​works
106 »       ​exactly·​like·​that·​of·​yacc.​</​p></​div><div·​class="sect2"·​title="6.​3.​9.​ Error·​declaration"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​error-​directive"></​a>6.​3.​9.​ Error·​declaration</​h3></​div></​div></​div><pre·​class="programlisting​">106 »       ​exactly·​like·​that·​of·​yacc.​</​p></​div><div·​class="sect2"·​title="6.​3.​9.​ Error·​declaration"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​error-​directive"></​a>6.​3.​9.​ Error·​declaration</​h3></​div></​div></​div><pre·​class="programlisting​">
107 %error·​{·​&lt;​identifier&gt;​·​}107 %error·​{·​&lt;​identifier&gt;​·​}
108 </​pre><a·​class="indexterm"·​name="idp63927608"></​a><p>Specifies·​the·​function·​to·​be·​called·​in·​the·​event·​of·​a108 </​pre><a·​class="indexterm"·​name="idp63993144"></​a><p>Specifies·​the·​function·​to·​be·​called·​in·​the·​event·​of·​a
109 »       ​parse·​error.​··​The·​type·​of·​<code·​class="literal">&lt;​f&gt;​</​code>·​varies109 »       ​parse·​error.​··​The·​type·​of·​<code·​class="literal">&lt;​f&gt;​</​code>·​varies
110 »       ​depending·​on·​the·​presence·​of·​<code·​class="literal">%lexe​r</​code>·​(see110 »       ​depending·​on·​the·​presence·​of·​<code·​class="literal">%lexe​r</​code>·​(see
111 »       ​<a·​class="xref"·​href="sec-​monads.​html#sec-​monad-​summary"·​title="2.​5.​4.​ Summary">Section 2.​5.​4,​·​&#8220;​Summary&#8221;​</​a>)​.​</​p></​div><div·​class="sect2"·​title="6.​3.​10.​ Attribute·​Type·​Declaration"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​attributes"></​a>6.​3.​10.​ Attribute·​Type·​Declaration</​h3></​div></​div></​div><pre·​class="programlisting​">111 »       ​<a·​class="xref"·​href="sec-​monads.​html#sec-​monad-​summary"·​title="2.​5.​4.​ Summary">Section 2.​5.​4,​·​&#8220;​Summary&#8221;​</​a>)​.​</​p></​div><div·​class="sect2"·​title="6.​3.​10.​ Attribute·​Type·​Declaration"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​attributes"></​a>6.​3.​10.​ Attribute·​Type·​Declaration</​h3></​div></​div></​div><pre·​class="programlisting​">
112 %attributetype·​{·​&lt;​valid·​Haskell·​type·​declaration&gt;​·​}112 %attributetype·​{·​&lt;​valid·​Haskell·​type·​declaration&gt;​·​}
113 </​pre><a·​class="indexterm"·​name="idp63931960"></​a><p>(optional)​·​This·​directive·​allows·​you·​to·​declare·​the·​type·​of·​the113 </​pre><a·​class="indexterm"·​name="idp63997496"></​a><p>(optional)​·​This·​directive·​allows·​you·​to·​declare·​the·​type·​of·​the
114 »       ​attributes·​record·​when·​defining·​an·​attribute·​grammar.​··​If·​this·​declaration114 »       ​attributes·​record·​when·​defining·​an·​attribute·​grammar.​··​If·​this·​declaration
115 »       ​is·​not·​given,​·​Happy·​will·​choose·​a·​default.​··​This·​declaration·​may·​only115 »       ​is·​not·​given,​·​Happy·​will·​choose·​a·​default.​··​This·​declaration·​may·​only
116 »       ​appear·​once·​in·​a·​grammar.​116 »       ​appear·​once·​in·​a·​grammar.​
117 »       ​</​p><p>117 »       ​</​p><p>
118 »       ​··​Attribute·​grammars·​are·​explained·​in·​<a·​class="xref"·​href="sec-​AttributeGrammar.​html"·​title="Chapter 4.​ Attribute·​Grammars">Chapter 4,​·​<i>Attribute·​Grammars</​i></​a>.​118 »       ​··​Attribute·​grammars·​are·​explained·​in·​<a·​class="xref"·​href="sec-​AttributeGrammar.​html"·​title="Chapter 4.​ Attribute·​Grammars">Chapter 4,​·​<i>Attribute·​Grammars</​i></​a>.​
119 »       ​</​p></​div><div·​class="sect2"·​title="6.​3.​11.​ Attribute·​declaration"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​attribute"></​a>6.​3.​11.​ Attribute·​declaration</​h3></​div></​div></​div><pre·​class="programlisting​">119 »       ​</​p></​div><div·​class="sect2"·​title="6.​3.​11.​ Attribute·​declaration"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​attribute"></​a>6.​3.​11.​ Attribute·​declaration</​h3></​div></​div></​div><pre·​class="programlisting​">
120 %attribute·​&lt;​Haskell·​identifier&gt;​·​{·​&lt;​valid·​Haskell·​type&gt;​·​}120 %attribute·​&lt;​Haskell·​identifier&gt;​·​{·​&lt;​valid·​Haskell·​type&gt;​·​}
121 </​pre><a·​class="indexterm"·​name="idp63939896"></​a><p>The·​presence·​of·​one·​or·​more·​of·​these·​directives·​declares·​that·​the121 </​pre><a·​class="indexterm"·​name="idp64005432"></​a><p>The·​presence·​of·​one·​or·​more·​of·​these·​directives·​declares·​that·​the
122 ·······​grammar·​is·​an·​attribute·​grammar.​··​The·​first·​attribute·​listed·​becomes·​the122 ·······​grammar·​is·​an·​attribute·​grammar.​··​The·​first·​attribute·​listed·​becomes·​the
123 ·······​default·​attribute.​··​Each·​<code·​class="literal">%attr​ibute</​code>·​directive·​generates·​a123 ·······​default·​attribute.​··​Each·​<code·​class="literal">%attr​ibute</​code>·​directive·​generates·​a
124 ·······​field·​in·​the·​attributes·​record·​with·​the·​given·​label·​and·​type.​··​If·​there124 ·······​field·​in·​the·​attributes·​record·​with·​the·​given·​label·​and·​type.​··​If·​there
125 ·······​is·​an·​<code·​class="literal">%attr​ibutetype</​code>·​declaration·​in·​the·​grammar·​which125 ·······​is·​an·​<code·​class="literal">%attr​ibutetype</​code>·​declaration·​in·​the·​grammar·​which
126 ·······​introduces·​type·​variables,​·​then·​the·​type·​of·​an·​attribute·​may·​mention·​any126 ·······​introduces·​type·​variables,​·​then·​the·​type·​of·​an·​attribute·​may·​mention·​any
127 ·······​such·​type·​variables.​127 ·······​such·​type·​variables.​
128 ·······​</​p><p>128 ·······​</​p><p>
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-error.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​6.​ The·​Error·​Token</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers"><link·​rel="next"·​href="sec-​multiple-​parsers.​html"·​title="2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​6.​ The·​Error·​Token</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​monads.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​multiple-​pa·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​6.​ The·​Error·​Token</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers"><link·​rel="next"·​href="sec-​multiple-​parsers.​html"·​title="2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​6.​ The·​Error·​Token</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​monads.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​multiple-​pa·​✂
2 ······​recovery,​·​using·​the·​special·​symbol·​<code·​class="literal">error​</​code>·​in·​a·​grammar2 ······​recovery,​·​using·​the·​special·​symbol·​<code·​class="literal">error​</​code>·​in·​a·​grammar
3 ······​file.​··​When·​<span·​class="application">H​appy</​span>·​finds·​a·​parse·​error·​during3 ······​file.​··​When·​<span·​class="application">H​appy</​span>·​finds·​a·​parse·​error·​during
4 ······​parsing,​·​it·​automatically·​inserts·​the·​<code·​class="literal">error​</​code>·​symbol;​·​if4 ······​parsing,​·​it·​automatically·​inserts·​the·​<code·​class="literal">error​</​code>·​symbol;​·​if
5 ······​your·​grammar·​deals·​with·​<code·​class="literal">error​</​code>·​explicitly,​·​then·​it·​can5 ······​your·​grammar·​deals·​with·​<code·​class="literal">error​</​code>·​explicitly,​·​then·​it·​can
6 ······​detect·​the·​error·​and·​carry·​on.​</​p><p>For·​example,​·​the·​<span·​class="application">H​appy</​span>·​grammar·​for·​Haskell6 ······​detect·​the·​error·​and·​carry·​on.​</​p><p>For·​example,​·​the·​<span·​class="application">H​appy</​span>·​grammar·​for·​Haskell
7 ······​uses·​error·​recovery·​to·​implement·​Haskell·​layout.​··​The·​grammar7 ······​uses·​error·​recovery·​to·​implement·​Haskell·​layout.​··​The·​grammar
8 ······​has·​a·​rule·​that·​looks·​like·​this:​</​p><pre·​class="programlisting​">8 ······​has·​a·​rule·​that·​looks·​like·​this:​</​p><pre·​class="programlisting​">
Offset 10, 15 lines modifiedOffset 10, 15 lines modified
10 ······​|·​error»  ​»       ​·····​{·​()​·​}10 ······​|·​error»  ​»       ​·····​{·​()​·​}
11 </​pre><p>This·​says·​that·​a·​close·​brace·​in·​a·​layout-​indented·​context11 </​pre><p>This·​says·​that·​a·​close·​brace·​in·​a·​layout-​indented·​context
12 ······​may·​be·​either·​a·​curly·​brace·​(inserted·​by·​the·​lexical·​analyser)​,​12 ······​may·​be·​either·​a·​curly·​brace·​(inserted·​by·​the·​lexical·​analyser)​,​
13 ······​or·​a·​parse·​error.​··​</​p><p>This·​rule·​is·​used·​to·​parse·​expressions·​like·​<code·​class="literal">let·​x13 ······​or·​a·​parse·​error.​··​</​p><p>This·​rule·​is·​used·​to·​parse·​expressions·​like·​<code·​class="literal">let·​x
14 ······​=·​e·​in·​e'</​code>:​·​the·​layout·​system·​inserts·​an·​open·​brace·​before14 ······​=·​e·​in·​e'</​code>:​·​the·​layout·​system·​inserts·​an·​open·​brace·​before
15 ······​<code·​class="literal">x</​code>,​·​and·​the·​occurrence·​of·​the·​<code·​class="literal">in</​code>·​symbol15 ······​<code·​class="literal">x</​code>,​·​and·​the·​occurrence·​of·​the·​<code·​class="literal">in</​code>·​symbol
16 ······​generates·​a·​parse·​error,​·​which·​is·​interpreted·​as·​a·​close·​brace16 ······​generates·​a·​parse·​error,​·​which·​is·​interpreted·​as·​a·​close·​brace
17 ······​by·​the·​above·​rule.​</​p><a·​class="indexterm"·​name="idp63497016"></​a><p>Note·​for·​<code·​class="literal">yacc<​/​code>·​users:​·​this·​form·​of·​error·​recovery17 ······​by·​the·​above·​rule.​</​p><a·​class="indexterm"·​name="idp63562552"></​a><p>Note·​for·​<code·​class="literal">yacc<​/​code>·​users:​·​this·​form·​of·​error·​recovery
18 ······​is·​strictly·​more·​limited·​than·​that·​provided·​by·​<code·​class="literal">yacc<​/​code>.​18 ······​is·​strictly·​more·​limited·​than·​that·​provided·​by·​<code·​class="literal">yacc<​/​code>.​
19 ······​During·​a·​parse·​error·​condition,​·​<code·​class="literal">yacc<​/​code>·​attempts·​to19 ······​During·​a·​parse·​error·​condition,​·​<code·​class="literal">yacc<​/​code>·​attempts·​to
20 ······​discard·​states·​and·​tokens·​in·​order·​to·​get·​back·​into·​a·​state20 ······​discard·​states·​and·​tokens·​in·​order·​to·​get·​back·​into·​a·​state
21 ······​where·​parsing·​may·​continue;​·​<span·​class="application">H​appy</​span>·​doesn't·​do·​this.​21 ······​where·​parsing·​may·​continue;​·​<span·​class="application">H​appy</​span>·​doesn't·​do·​this.​
22 ······​The·​reason·​is·​that·​normal·​<code·​class="literal">yacc<​/​code>·​error·​recovery·​is22 ······​The·​reason·​is·​that·​normal·​<code·​class="literal">yacc<​/​code>·​error·​recovery·​is
23 ······​notoriously·​hard·​to·​describe,​·​and·​the·​semantics·​depend·​heavily23 ······​notoriously·​hard·​to·​describe,​·​and·​the·​semantics·​depend·​heavily
24 ······​on·​the·​workings·​of·​a·​shift-​reduce·​parser.​··​Furthermore,​24 ······​on·​the·​workings·​of·​a·​shift-​reduce·​parser.​··​Furthermore,​
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-finding-errors.html
Offset 1, 20 lines modifiedOffset 1, 20 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​3.​ Finding·​Type·​Errors</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​compilation-​time.​html"·​title="8.​2.​ Compilation-​Time·​Tips"><link·​rel="next"·​href="sec-​conflict-​tips.​html"·​title="8.​4.​ Conflict·​Tips"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​3.​ Finding·​Type·​Errors</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​compilation-​time.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​conflict-​tips.​html">Next</​a></​td></​tr></​table><hr></​div><div·​cla·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​3.​ Finding·​Type·​Errors</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​compilation-​time.​html"·​title="8.​2.​ Compilation-​Time·​Tips"><link·​rel="next"·​href="sec-​conflict-​tips.​html"·​title="8.​4.​ Conflict·​Tips"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​3.​ Finding·​Type·​Errors</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​compilation-​time.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​conflict-​tips.​html">Next</​a></​td></​tr></​table><hr></​div><div·​cla·​✂
2 ······​difficult·​because·​the·​code·​for·​reductions·​is·​moved·​around·​before2 ······​difficult·​because·​the·​code·​for·​reductions·​is·​moved·​around·​before
3 ······​being·​placed·​in·​the·​parser.​··​We·​currently·​have·​no·​way·​of·​passing3 ······​being·​placed·​in·​the·​parser.​··​We·​currently·​have·​no·​way·​of·​passing
4 ······​the·​original·​filename·​and·​line·​numbers·​to·​the·​Haskell·​compiler,​4 ······​the·​original·​filename·​and·​line·​numbers·​to·​the·​Haskell·​compiler,​
5 ······​so·​there·​is·​no·​alternative·​but·​to·​look·​at·​the·​parser·​and·​match5 ······​so·​there·​is·​no·​alternative·​but·​to·​look·​at·​the·​parser·​and·​match
6 ······​the·​code·​to·​the·​grammar·​file.​··​An·​info·​file·​(generated·​by·​the6 ······​the·​code·​to·​the·​grammar·​file.​··​An·​info·​file·​(generated·​by·​the
7 ······​<code·​class="literal">-​i</​code>·​option)​·​can·​be·​helpful·​here.​</​p><a·​class="indexterm"·​name="idp64005304"></​a><p>Type·​signature·​sometimes·​help·​by·​pinning·​down·​the7 ······​<code·​class="literal">-​i</​code>·​option)​·​can·​be·​helpful·​here.​</​p><a·​class="indexterm"·​name="idp64070840"></​a><p>Type·​signature·​sometimes·​help·​by·​pinning·​down·​the
8 ······​particular·​error·​to·​the·​place·​where·​the·​mistake·​is·​made,​·​not8 ······​particular·​error·​to·​the·​place·​where·​the·​mistake·​is·​made,​·​not
9 ······​half·​way·​down·​the·​file.​··​For·​each·​production·​in·​the·​grammar,​9 ······​half·​way·​down·​the·​file.​··​For·​each·​production·​in·​the·​grammar,​
10 ······​there's·​a·​bit·​of·​code·​in·​the·​generated·​file·​that·​looks·​like10 ······​there's·​a·​bit·​of·​code·​in·​the·​generated·​file·​that·​looks·​like
11 ······​this:​</​p><pre·​class="programlisting​">11 ······​this:​</​p><pre·​class="programlisting​">
12 HappyAbsSyn&lt;​n&gt;​·​(·​E·​)​12 HappyAbsSyn&lt;​n&gt;​·​(·​E·​)​
13 </​pre><a·​class="indexterm"·​name="idp64007480"></​a><p>where·​<code·​class="literal">E</​code>·​is·​the·​Haskell·​expression·​from·​the13 </​pre><a·​class="indexterm"·​name="idp64085304"></​a><p>where·​<code·​class="literal">E</​code>·​is·​the·​Haskell·​expression·​from·​the
14 ······​grammar·​file·​(with·​<code·​class="literal">$n</​code>·​replaced·​by14 ······​grammar·​file·​(with·​<code·​class="literal">$n</​code>·​replaced·​by
15 ······​<code·​class="literal">happy​_var_n</​code>)​.​··​If·​there·​is·​a·​type·​signature·​for·​this15 ······​<code·​class="literal">happy​_var_n</​code>)​.​··​If·​there·​is·​a·​type·​signature·​for·​this
16 ······​production,​·​then·​<span·​class="application">H​appy</​span>·​will·​have·​taken·​it·​into16 ······​production,​·​then·​<span·​class="application">H​appy</​span>·​will·​have·​taken·​it·​into
17 ······​account·​when·​declaring·​the·​HappyAbsSyn·​datatype,​·​and·​errors·​in17 ······​account·​when·​declaring·​the·​HappyAbsSyn·​datatype,​·​and·​errors·​in
18 ······​<code·​class="literal">E</​code>·​will·​be·​caught·​right·​here.​··​Of·​course,​·​the·​error·​may18 ······​<code·​class="literal">E</​code>·​will·​be·​caught·​right·​here.​··​Of·​course,​·​the·​error·​may
19 ······​be·​really·​caused·​by·​incorrect·​use·​of·​one·​of·​the19 ······​be·​really·​caused·​by·​incorrect·​use·​of·​one·​of·​the
20 ······​<code·​class="literal">happy​_var_n</​code>·​variables.​</​p><p>(this·​section·​will·​contain·​more·​info·​as·​we·​gain·​experience20 ······​<code·​class="literal">happy​_var_n</​code>·​variables.​</​p><p>(this·​section·​will·​contain·​more·​info·​as·​we·​gain·​experience
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-grammar-files.html
Offset 4, 15 lines modifiedOffset 4, 15 lines modified
4 ····​module·​that·​can·​be·​included·​in·​your·​program.​··​This·​section·​gives4 ····​module·​that·​can·​be·​included·​in·​your·​program.​··​This·​section·​gives
5 ····​the·​exact·​syntax·​of·​grammar·​files.​·​</​p><p>The·​overall·​format·​of·​the·​grammar·​file·​is·​given·​below:​</​p><pre·​class="programlisting​">5 ····​the·​exact·​syntax·​of·​grammar·​files.​·​</​p><p>The·​overall·​format·​of·​the·​grammar·​file·​is·​given·​below:​</​p><pre·​class="programlisting​">
6 &lt;​optional·​module·​header&gt;​6 &lt;​optional·​module·​header&gt;​
7 &lt;​directives&gt;​7 &lt;​directives&gt;​
8 %%8 %%
9 &lt;​grammar&gt;​9 &lt;​grammar&gt;​
10 &lt;​optional·​module·​trailer&gt;​10 &lt;​optional·​module·​trailer&gt;​
11 </​pre><a·​class="indexterm"·​name="idp63836728"></​a><a·​class="indexterm"·​name="idp63838008"></​a><p>If·​the·​name·​of·​the·​grammar·​file·​ends·​in·​<code·​class="literal">.​ly</​code>,​·​then11 </​pre><a·​class="indexterm"·​name="idp63902264"></​a><a·​class="indexterm"·​name="idp63903544"></​a><p>If·​the·​name·​of·​the·​grammar·​file·​ends·​in·​<code·​class="literal">.​ly</​code>,​·​then
12 ····​it·​is·​assumed·​to·​be·​a·​literate·​script.​··​All·​lines·​except·​those12 ····​it·​is·​assumed·​to·​be·​a·​literate·​script.​··​All·​lines·​except·​those
13 ····​beginning·​with·​a·​<code·​class="literal">&gt;​</​code>·​will·​be·​ignored,​·​and·​the13 ····​beginning·​with·​a·​<code·​class="literal">&gt;​</​code>·​will·​be·​ignored,​·​and·​the
14 ····​<code·​class="literal">&gt;​</​code>·​will·​be·​stripped·​from·​the·​beginning·​of·​all·​the·​code14 ····​<code·​class="literal">&gt;​</​code>·​will·​be·​stripped·​from·​the·​beginning·​of·​all·​the·​code
15 ····​lines.​··​There·​must·​be·​a·​blank·​line·​between·​each·​code·​section15 ····​lines.​··​There·​must·​be·​a·​blank·​line·​between·​each·​code·​section
16 ····​(lines·​beginning·​with·​<code·​class="literal">&gt;​</​code>)​·​and·​comment·​section.​16 ····​(lines·​beginning·​with·​<code·​class="literal">&gt;​</​code>)​·​and·​comment·​section.​
17 ····​Grammars·​not·​using·​the·​literate·​notation·​must·​be·​in·​a·​file·​with17 ····​Grammars·​not·​using·​the·​literate·​notation·​must·​be·​in·​a·​file·​with
18 ····​the·​<code·​class="literal">.​y</​code>·​suffix.​</​p><div·​class="sect1"·​title="6.​1.​ Lexical·​Rules"><div·​class="titlepage"><di​v><div><h2·​class="title"·​style="clear:​·​both"><a·​name="sec-​lexical-​rules"></​a>6.​1.​ Lexical·​Rules</​h2></​div></​div></​div><p>Identifiers·​in·​<span·​class="application">H​appy</​span>·​grammar·​files·​must·​take·​the·​following·​form·​(using18 ····​the·​<code·​class="literal">.​y</​code>·​suffix.​</​p><div·​class="sect1"·​title="6.​1.​ Lexical·​Rules"><div·​class="titlepage"><di​v><div><h2·​class="title"·​style="clear:​·​both"><a·​name="sec-​lexical-​rules"></​a>6.​1.​ Lexical·​Rules</​h2></​div></​div></​div><p>Identifiers·​in·​<span·​class="application">H​appy</​span>·​grammar·​files·​must·​take·​the·​following·​form·​(using
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-grammar.html
Offset 1, 12 lines modifiedOffset 1, 12 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​4.​ Grammar</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​directives.​html"·​title="6.​3.​ Directives"><link·​rel="next"·​href="sec-​module-​trailer.​html"·​title="6.​5.​ Module·​Trailer"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​4.​ Grammar</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​directives.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​module-​trailer.​html">Next</​a></​td></​tr></​table><hr></​div><div··​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​4.​ Grammar</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​directives.​html"·​title="6.​3.​ Directives"><link·​rel="next"·​href="sec-​module-​trailer.​html"·​title="6.​5.​ Module·​Trailer"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​4.​ Grammar</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​directives.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​module-​trailer.​html">Next</​a></​td></​tr></​table><hr></​div><div··​✂
2 ······​from·​them·​by·​a·​double-​percent·​(<code·​class="literal">%%</​code>)​·​symbol.​2 ······​from·​them·​by·​a·​double-​percent·​(<code·​class="literal">%%</​code>)​·​symbol.​
3 ······​This·​section·​contains·​a·​number·​of3 ······​This·​section·​contains·​a·​number·​of
4 ······​<span·​class="emphasis"><em>​productions</​em></​span>,​·​each·​of·​which·​defines·​a·​single4 ······​<span·​class="emphasis"><em>​productions</​em></​span>,​·​each·​of·​which·​defines·​a·​single
5 ······​non-​terminal.​··​Each·​production·​has·​the·​following·​syntax:​</​p><a·​class="indexterm"·​name="idp63945784"></​a><pre·​class="programlisting​">5 ······​non-​terminal.​··​Each·​production·​has·​the·​following·​syntax:​</​p><a·​class="indexterm"·​name="idp64011320"></​a><pre·​class="programlisting​">
6 &lt;​non-​terminal&gt;​·​[·​:​:​·​{·​&lt;​type&gt;​·​}·​]6 &lt;​non-​terminal&gt;​·​[·​:​:​·​{·​&lt;​type&gt;​·​}·​]
7 ········​:​··​&lt;​id&gt;​·​.​.​.​·​{[%]·​&lt;​expression&gt;​·​}7 ········​:​··​&lt;​id&gt;​·​.​.​.​·​{[%]·​&lt;​expression&gt;​·​}
8 ······​[·​|··​&lt;​id&gt;​·​.​.​.​·​{[%]·​&lt;​expression&gt;​·​}8 ······​[·​|··​&lt;​id&gt;​·​.​.​.​·​{[%]·​&lt;​expression&gt;​·​}
9 ········​.​.​.​·​]9 ········​.​.​.​·​]
10 </​pre><p>The·​first·​line·​gives·​the·​non-​terminal·​to·​be·​defined·​by·​the10 </​pre><p>The·​first·​line·​gives·​the·​non-​terminal·​to·​be·​defined·​by·​the
11 ······​production·​and·​optionally·​its·​type·​(type·​signatures·​for11 ······​production·​and·​optionally·​its·​type·​(type·​signatures·​for
12 ······​productions·​are·​discussed·​in·​<a·​class="xref"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures">Section 2​.​4,​·​&#8220;​Type·​Signatures&#8221;​</​a>)​.​</​p><p>Each·​production·​has·​at·​least·​one,​·​and·​possibly·​many12 ······​productions·​are·​discussed·​in·​<a·​class="xref"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures">Section 2​.​4,​·​&#8220;​Type·​Signatures&#8221;​</​a>)​.​</​p><p>Each·​production·​has·​at·​least·​one,​·​and·​possibly·​many
Offset 21, 15 lines modifiedOffset 21, 15 lines modified
21 ······​the·​current·​rule.​·​The·​symbol·​<code·​class="literal">$</​code>·​may·​be21 ······​the·​current·​rule.​·​The·​symbol·​<code·​class="literal">$</​code>·​may·​be
22 ······​inserted·​literally·​in·​the·​Haskell·​expression·​using·​the·​sequence22 ······​inserted·​literally·​in·​the·​Haskell·​expression·​using·​the·​sequence
23 ······​<code·​class="literal">\$</​code>·​(this·​isn't·​necessary·​inside·​a23 ······​<code·​class="literal">\$</​code>·​(this·​isn't·​necessary·​inside·​a
24 ······​string·​or·​character·​literal)​.​</​p><p>Additionally,​·​the·​sequence·​<code·​class="literal">$&gt;​</​code>24 ······​string·​or·​character·​literal)​.​</​p><p>Additionally,​·​the·​sequence·​<code·​class="literal">$&gt;​</​code>
25 ······​can·​be·​used·​to·​represent·​the·​value·​of·​the·​rightmost·​symbol.​</​p><p>A·​semantic·​value·​of·​the·​form·​<code·​class="literal">{%·​.​.​.​·​}</​code>·​is·​a25 ······​can·​be·​used·​to·​represent·​the·​value·​of·​the·​rightmost·​symbol.​</​p><p>A·​semantic·​value·​of·​the·​form·​<code·​class="literal">{%·​.​.​.​·​}</​code>·​is·​a
26 ······​<span·​class="emphasis"><em>​monadic·​action</​em></​span>,​·​and·​is·​only·​valid·​when·​the·​grammar26 ······​<span·​class="emphasis"><em>​monadic·​action</​em></​span>,​·​and·​is·​only·​valid·​when·​the·​grammar
27 ······​file·​contains·​a·​<code·​class="literal">%mona​d</​code>·​directive·​(<a·​class="xref"·​href="sec-​directives.​html#sec-​monad-​decl"·​title="6.​3.​5.​ Monad·​Directive">Section 6.​3.​5,​·​&#8220;​Monad·​Directive&#8221;​</​a>)​.​··​Monadic·​actions·​are·​discussed·​in27 ······​file·​contains·​a·​<code·​class="literal">%mona​d</​code>·​directive·​(<a·​class="xref"·​href="sec-​directives.​html#sec-​monad-​decl"·​title="6.​3.​5.​ Monad·​Directive">Section 6.​3.​5,​·​&#8220;​Monad·​Directive&#8221;​</​a>)​.​··​Monadic·​actions·​are·​discussed·​in
28 ······​<a·​class="xref"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers">Section 2.​5,​·​&#8220;​Monadic·​Parsers&#8221;​</​a>.​</​p><a·​class="indexterm"·​name="idp63955000"></​a><p>Remember·​that·​all·​the·​expressions·​for·​a·​production·​must28 ······​<a·​class="xref"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers">Section 2.​5,​·​&#8220;​Monadic·​Parsers&#8221;​</​a>.​</​p><a·​class="indexterm"·​name="idp64020536"></​a><p>Remember·​that·​all·​the·​expressions·​for·​a·​production·​must
29 ······​have·​the·​same·​type.​</​p><div·​class="sect2"·​title="6.​4.​1.​ Parameterized·​Productions"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​param-​prods"></​a>6.​4.​1.​ Parameterized·​Productions</​h3></​div></​div></​div>29 ······​have·​the·​same·​type.​</​p><div·​class="sect2"·​title="6.​4.​1.​ Parameterized·​Productions"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​param-​prods"></​a>6.​4.​1.​ Parameterized·​Productions</​h3></​div></​div></​div>
30 ········​Starting·​from·​version·​1.​17.​1,​·​<span·​class="application">H​appy</​span>·​supports30 ········​Starting·​from·​version·​1.​17.​1,​·​<span·​class="application">H​appy</​span>·​supports
31 ········​<span·​class="emphasis"><em>​parameterized·​productions</​em></​span>·​which·​provide·​a31 ········​<span·​class="emphasis"><em>​parameterized·​productions</​em></​span>·​which·​provide·​a
32 ········​convenient·​notation·​for·​capturing·​recurring·​patterns·​in·​context·​free32 ········​convenient·​notation·​for·​capturing·​recurring·​patterns·​in·​context·​free
33 ········​grammars.​·​This·​gives·​the·​benefits·​of·​something·​similar·​to·​parsing33 ········​grammars.​·​This·​gives·​the·​benefits·​of·​something·​similar·​to·​parsing
34 ········​combinators·​in·​the·​context·​of·​<span·​class="application">H​appy</​span>34 ········​combinators·​in·​the·​context·​of·​<span·​class="application">H​appy</​span>
35 ········​grammars.​35 ········​grammars.​
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-happy-ghci.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​5.​ Using·​Happy·​with·​GHCi</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​conflict-​tips.​html"·​title="8.​4.​ Conflict·​Tips"><link·​rel="next"·​href="sec-​monad-​alex.​html"·​title="8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​5.​ Using·​Happy·​with·​<span·​class="application">G​HCi</​span></​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​conflict-​tips.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​monad-​alex.​html">Next</​a·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​5.​ Using·​Happy·​with·​GHCi</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​conflict-​tips.​html"·​title="8.​4.​ Conflict·​Tips"><link·​rel="next"·​href="sec-​monad-​alex.​html"·​title="8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​5.​ Using·​Happy·​with·​<span·​class="application">G​HCi</​span></​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​conflict-​tips.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​monad-​alex.​html">Next</​a·​✂
2 ······​doesn't·​understand·​Happy·​grammars,​·​but·​with·​some·​creative·​use·​of2 ······​doesn't·​understand·​Happy·​grammars,​·​but·​with·​some·​creative·​use·​of
3 ······​macros·​and·​makefiles·​we·​can·​give·​the·​impression·​that3 ······​macros·​and·​makefiles·​we·​can·​give·​the·​impression·​that
4 ······​<span·​class="application">G​HCi</​span>·​is·​invoking·​Happy4 ······​<span·​class="application">G​HCi</​span>·​is·​invoking·​Happy
5 ······​automatically:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>C​reate·​a·​simple·​makefile,​·​called5 ······​automatically:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>C​reate·​a·​simple·​makefile,​·​called
6 »       ​··​<code·​class="filename">Make​file_happysrcs</​code>:​</​p><pre·​class="programlisting​">HAPPY·​=·​happy6 »       ​··​<code·​class="filename">Make​file_happysrcs</​code>:​</​p><pre·​class="programlisting​">HAPPY·​=·​happy
7 HAPPY_OPTS·​=7 HAPPY_OPTS·​=
  
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-info-files.html
Offset 1, 1 lines modifiedOffset 1, 1 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 7.​ Info·​Files</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​module-​trailer.​html"·​title="6.​5.​ Module·​Trailer"><link·​rel="next"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 7.​ Info·​Files</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​module-​trailer.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​tips.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="chapter"·​title="Chapter 7.​ Info·​Files"><div·​class=·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 7.​ Info·​Files</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​module-​trailer.​html"·​title="6.​5.​ Module·​Trailer"><link·​rel="next"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 7.​ Info·​Files</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​module-​trailer.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​tips.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="chapter"·​title="Chapter 7.​ Info·​Files"><div·​class=·​✂
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-invoking.html
Offset 4, 28 lines modifiedOffset 4, 28 lines modified
4 ····​will·​be·​the·​value·​used.​</​p><p>There·​are·​two·​types·​of·​grammar·​files,​4 ····​will·​be·​the·​value·​used.​</​p><p>There·​are·​two·​types·​of·​grammar·​files,​
5 ····​<code·​class="filename">file​.​y</​code>·​and·​<code·​class="filename">file​.​ly</​code>,​·​with5 ····​<code·​class="filename">file​.​y</​code>·​and·​<code·​class="filename">file​.​ly</​code>,​·​with
6 ····​the·​latter·​observing·​the·​reverse·​comment·​(or·​literate)​·​convention6 ····​the·​latter·​observing·​the·​reverse·​comment·​(or·​literate)​·​convention
7 ····​(i.​e.​·​each·​code·​line·​must·​begin·​with·​the·​character7 ····​(i.​e.​·​each·​code·​line·​must·​begin·​with·​the·​character
8 ····​<code·​class="literal">&gt;​</​code>,​·​lines·​which·​don't·​begin·​with8 ····​<code·​class="literal">&gt;​</​code>,​·​lines·​which·​don't·​begin·​with
9 ····​<code·​class="literal">&gt;​</​code>·​are·​treated·​as·​comments)​.​··​The·​examples9 ····​<code·​class="literal">&gt;​</​code>·​are·​treated·​as·​comments)​.​··​The·​examples
10 ····​distributed·​with·​<span·​class="application">H​appy</​span>·​are·​all·​of·​the10 ····​distributed·​with·​<span·​class="application">H​appy</​span>·​are·​all·​of·​the
11 ····​.​ly·​form.​</​p><a·​class="indexterm"·​name="idp63780152"></​a><p>The·​flags·​accepted·​by·​<span·​class="application">H​appy</​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.​11 ····​.​ly·​form.​</​p><a·​class="indexterm"·​name="idp63845688"></​a><p>The·​flags·​accepted·​by·​<span·​class="application">H​appy</​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.​
12 »       ​··​If·​omitted,​·​the·​parser·​will·​be·​placed·​in12 »       ​··​If·​omitted,​·​the·​parser·​will·​be·​placed·​in
13 ··········​<em·​class="replaceable"><​code>file</​code></​em><code·​class="literal">.​hs</​code>,​13 ··········​<em·​class="replaceable"><​code>file</​code></​em><code·​class="literal">.​hs</​code>,​
14 »       ​··​where·​<em·​class="replaceable"><​code>file</​code></​em>·​is·​the·​name·​of·​the·​input14 »       ​··​where·​<em·​class="replaceable"><​code>file</​code></​em>·​is·​the·​name·​of·​the·​input
15 ··········​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="idp63788856"></​a><p>·​Directs·​<span·​class="application">H​appy</​span>·​to·​produce·​an·​info·​file15 ··········​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="idp63854392"></​a><p>·​Directs·​<span·​class="application">H​appy</​span>·​to·​produce·​an·​info·​file
16 ··········​containing·​detailed·​information·​about·​the·​grammar,​·​parser16 ··········​containing·​detailed·​information·​about·​the·​grammar,​·​parser
17 ··········​states,​·​parser·​actions,​·​and·​conflicts.​··​Info·​files·​are·​vital17 ··········​states,​·​parser·​actions,​·​and·​conflicts.​··​Info·​files·​are·​vital
18 ··········​during·​the·​debugging·​of·​grammars.​··​The·​filename·​argument·​is18 ··········​during·​the·​debugging·​of·​grammars.​··​The·​filename·​argument·​is
19 ··········​optional·​(note·​that·​there's·​no·​space·​between19 ··········​optional·​(note·​that·​there's·​no·​space·​between
20 ··········​<code·​class="literal">-​i</​code>·​and·​the·​filename·​in·​the·​short20 ··········​<code·​class="literal">-​i</​code>·​and·​the·​filename·​in·​the·​short
21 ··········​version)​,​·​and·​if·​omitted·​the·​info·​file·​will·​be·​written·​to21 ··········​version)​,​·​and·​if·​omitted·​the·​info·​file·​will·​be·​written·​to
22 ··········​<em·​class="replaceable"><​code>file</​code></​em><code·​class="literal">.​info</​code>·​(where22 ··········​<em·​class="replaceable"><​code>file</​code></​em><code·​class="literal">.​info</​code>·​(where
23 ··········​<em·​class="replaceable"><​code>file</​code></​em>·​is·​the·​input·​file·​name·​with·​any23 ··········​<em·​class="replaceable"><​code>file</​code></​em>·​is·​the·​input·​file·​name·​with·​any
24 ··········​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="idp63794872"></​a><p>Instructs·​<span·​class="application">H​appy</​span>·​to·​use·​this·​directory24 ··········​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="idp63860408"></​a><p>Instructs·​<span·​class="application">H​appy</​span>·​to·​use·​this·​directory
25 ··········​when·​looking·​for·​template·​files:​·​these·​files·​contain·​the25 ··········​when·​looking·​for·​template·​files:​·​these·​files·​contain·​the
26 ··········​static·​code·​that·​<span·​class="application">H​appy</​span>·​includes·​in·​every26 ··········​static·​code·​that·​<span·​class="application">H​appy</​span>·​includes·​in·​every
27 ··········​generated·​parser.​··​You·​shouldn't·​need·​to·​use·​this·​option·​if27 ··········​generated·​parser.​··​You·​shouldn't·​need·​to·​use·​this·​option·​if
28 ··········​<span·​class="application">H​appy</​span>·​is·​properly·​configured·​for·​your28 ··········​<span·​class="application">H​appy</​span>·​is·​properly·​configured·​for·​your
29 ··········​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">H​appy</​span>·​prefixes·​all·​the·​symbols·​it·​uses·​internally29 ··········​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">H​appy</​span>·​prefixes·​all·​the·​symbols·​it·​uses·​internally
30 ··········​with·​either·​<code·​class="literal">happy​</​code>·​or·​<code·​class="literal">Happy​</​code>.​··​To·​use·​a30 ··········​with·​either·​<code·​class="literal">happy​</​code>·​or·​<code·​class="literal">Happy​</​code>.​··​To·​use·​a
31 ··········​different·​string,​·​for·​example·​if·​the·​use·​of·​<code·​class="literal">happy​</​code>31 ··········​different·​string,​·​for·​example·​if·​the·​use·​of·​<code·​class="literal">happy​</​code>
Offset 34, 24 lines modifiedOffset 34, 24 lines modified
34 »       ​··​experimental·​and·​may·​cause·​unpredictable·​results.​</​p><p>This·​option·​causes·​the·​right·​hand·​side·​of·​each34 »       ​··​experimental·​and·​may·​cause·​unpredictable·​results.​</​p><p>This·​option·​causes·​the·​right·​hand·​side·​of·​each
35 »       ​··​production·​(the·​semantic·​value)​·​to·​be·​evaluated·​eagerly·​at35 »       ​··​production·​(the·​semantic·​value)​·​to·​be·​evaluated·​eagerly·​at
36 »       ​··​the·​moment·​the·​production·​is·​reduced.​··​If·​the·​lazy·​behaviour36 »       ​··​the·​moment·​the·​production·​is·​reduced.​··​If·​the·​lazy·​behaviour
37 »       ​··​is·​not·​required,​·​then·​using·​this·​option·​will·​improve37 »       ​··​is·​not·​required,​·​then·​using·​this·​option·​will·​improve
38 »       ​··​performance·​and·​may·​reduce·​space·​leaks.​··​Note·​that·​the38 »       ​··​performance·​and·​may·​reduce·​space·​leaks.​··​Note·​that·​the
39 »       ​··​parser·​as·​a·​whole·​is·​never·​lazy·​-​·​the·​whole·​input·​will39 »       ​··​parser·​as·​a·​whole·​is·​never·​lazy·​-​·​the·​whole·​input·​will
40 »       ​··​always·​be·​consumed·​before·​any·​input·​is·​produced,​·​regardless40 »       ​··​always·​be·​consumed·​before·​any·​input·​is·​produced,​·​regardless
41 »       ​··​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="idp63808312"></​a><a·​class="indexterm"·​name="idp63809208"></​a><p>Instructs·​<span·​class="application">H​appy</​span>·​to·​generate·​a·​parser41 »       ​··​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="idp63873848"></​a><a·​class="indexterm"·​name="idp63874744"></​a><p>Instructs·​<span·​class="application">H​appy</​span>·​to·​generate·​a·​parser
42 »       ​··​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="idp63813176"></​a><a·​class="indexterm"·​name="idp63814072"></​a><p>·​Use·​GHC's·​<code·​class="literal">unsaf​eCoerce#</​code>·​extension·​to42 »       ​··​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="idp63878712"></​a><a·​class="indexterm"·​name="idp63879608"></​a><p>·​Use·​GHC's·​<code·​class="literal">unsaf​eCoerce#</​code>·​extension·​to
43 ··········​generate·​smaller·​faster·​parsers.​··​Type-​safety·​isn't43 ··········​generate·​smaller·​faster·​parsers.​··​Type-​safety·​isn't
44 ··········​compromised.​</​p><p>This·​option·​may·​only·​be·​used·​in·​conjuction·​with44 ··········​compromised.​</​p><p>This·​option·​may·​only·​be·​used·​in·​conjuction·​with
45 ··········​<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="idp63818808"></​a><a·​class="indexterm"·​name="idp63819704"></​a><p>·​Instructs·​<span·​class="application">H​appy</​span>·​to·​generate·​a·​parser45 ··········​<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="idp63884344"></​a><a·​class="indexterm"·​name="idp63885240"></​a><p>·​Instructs·​<span·​class="application">H​appy</​span>·​to·​generate·​a·​parser
46 ··········​using·​an·​array-​based·​shift·​reduce·​parser.​··​When·​used·​in46 ··········​using·​an·​array-​based·​shift·​reduce·​parser.​··​When·​used·​in
47 ··········​conjunction·​with·​<code·​class="option">-​g</​code>,​·​the·​arrays·​will·​be47 ··········​conjunction·​with·​<code·​class="option">-​g</​code>,​·​the·​arrays·​will·​be
48 ··········​encoded·​as·​strings,​·​resulting·​in·​faster·​parsers.​··​Without48 ··········​encoded·​as·​strings,​·​resulting·​in·​faster·​parsers.​··​Without
49 ··········​<code·​class="option">-​g</​code>,​·​standard·​Haskell·​arrays·​will·​be49 ··········​<code·​class="option">-​g</​code>,​·​standard·​Haskell·​arrays·​will·​be
50 ··········​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="idp63824568"></​a><a·​class="indexterm"·​name="idp63825464"></​a><p>Generate·​a·​parser·​that·​will·​print·​debugging50 ··········​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="idp63890104"></​a><a·​class="indexterm"·​name="idp63891000"></​a><p>Generate·​a·​parser·​that·​will·​print·​debugging
51 »       ​··​information·​to·​<code·​class="literal">stder​r</​code>·​at·​run-​time,​51 »       ​··​information·​to·​<code·​class="literal">stder​r</​code>·​at·​run-​time,​
52 »       ​··​including·​all·​the·​shifts,​·​reductions,​·​state·​transitions·​and52 »       ​··​including·​all·​the·​shifts,​·​reductions,​·​state·​transitions·​and
53 »       ​··​token·​inputs·​performed·​by·​the·​parser.​</​p><p>This·​option·​can·​only·​be·​used·​in·​conjunction·​with53 »       ​··​token·​inputs·​performed·​by·​the·​parser.​</​p><p>This·​option·​can·​only·​be·​used·​in·​conjunction·​with
54 »       ​··​<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·​exit54 »       ​··​<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
55 »       ​··​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·​exit55 »       ​··​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
56 »       ​··​successfully.​·​Note·​that·​for·​legacy·​reasons·​<code·​class="option">-​v</​code>56 »       ​··​successfully.​·​Note·​that·​for·​legacy·​reasons·​<code·​class="option">-​v</​code>
57 »       ​··​is·​supported,​·​too,​·​but·​the·​use·​of·​it·​is·​deprecated.​57 »       ​··​is·​supported,​·​too,​·​but·​the·​use·​of·​it·​is·​deprecated.​
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-license.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>1.​3.​ License</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"><link·​rel="prev"·​href="sec-​reporting-​bugs.​html"·​title="1.​2.​ Reporting·​Bugs"><link·​rel="next"·​href="sec-​obtaining.​html"·​title="1.​4.​ Obtaining·​Happy"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">1.​3.​ License</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​reporting-​bugs.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 1.​ Introduction</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​obtaining.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​titl·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>1.​3.​ License</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"><link·​rel="prev"·​href="sec-​reporting-​bugs.​html"·​title="1.​2.​ Reporting·​Bugs"><link·​rel="next"·​href="sec-​obtaining.​html"·​title="1.​4.​ Obtaining·​Happy"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">1.​3.​ License</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​reporting-​bugs.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 1.​ Introduction</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​obtaining.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​titl·​✂
2 ······​were·​covered·​by·​the·​GNU·​general·​public·​license.​··​We're·​now2 ······​were·​covered·​by·​the·​GNU·​general·​public·​license.​··​We're·​now
3 ······​distributing·​<span·​class="application">H​appy</​span>·​with·​a·​less3 ······​distributing·​<span·​class="application">H​appy</​span>·​with·​a·​less
4 ······​restrictive·​BSD-​style·​license.​··​If·​this·​license·​doesn't·​work·​for4 ······​restrictive·​BSD-​style·​license.​··​If·​this·​license·​doesn't·​work·​for
5 ······​you,​·​please·​get·​in·​touch.​</​p><div·​class="blockquote"><b​lockquote·​class="blockquote"><p​>·​Copyright·​2009,​·​Simon·​Marlow·​and·​Andy·​Gill.​··​All·​rights5 ······​you,​·​please·​get·​in·​touch.​</​p><div·​class="blockquote"><b​lockquote·​class="blockquote"><p​>·​Copyright·​2009,​·​Simon·​Marlow·​and·​Andy·​Gill.​··​All·​rights
6 »       ​reserved.​·​</​p><p>·​Redistribution·​and·​use·​in·​source·​and·​binary·​forms,​·​with6 »       ​reserved.​·​</​p><p>·​Redistribution·​and·​use·​in·​source·​and·​binary·​forms,​·​with
7 »       ​or·​without·​modification,​·​are·​permitted·​provided·​that·​the7 »       ​or·​without·​modification,​·​are·​permitted·​provided·​that·​the
8 »       ​following·​conditions·​are·​met:​·​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>R​edistributions·​of·​source·​code·​must·​retain·​the·​above8 »       ​following·​conditions·​are·​met:​·​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>R​edistributions·​of·​source·​code·​must·​retain·​the·​above
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-module-header.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​2.​ Module·​Header</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="next"·​href="sec-​directives.​html"·​title="6.​3.​ Directives"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​2.​ Module·​Header</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​grammar-​files.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​directives.​html">Next</​a></​td></​t·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​2.​ Module·​Header</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="next"·​href="sec-​directives.​html"·​title="6.​3.​ Directives"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​2.​ Module·​Header</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​grammar-​files.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​directives.​html">Next</​a></​td></​t·​✂
2 ······​following·​form:​</​p><pre·​class="programlisting​">2 ······​following·​form:​</​p><pre·​class="programlisting​">
3 {3 {
4 &lt;​Haskell·​module·​header&gt;​4 &lt;​Haskell·​module·​header&gt;​
5 }5 }
6 </​pre><p>The·​Haskell·​module·​header·​contains·​the·​module·​name,​6 </​pre><p>The·​Haskell·​module·​header·​contains·​the·​module·​name,​
7 ······​exports,​·​and·​imports.​··​No·​other·​code·​is·​allowed·​in·​the7 ······​exports,​·​and·​imports.​··​No·​other·​code·​is·​allowed·​in·​the
8 ······​header-​-​-​this·​is·​because·​<span·​class="application">H​appy</​span>·​may·​need·​to·​include8 ······​header-​-​-​this·​is·​because·​<span·​class="application">H​appy</​span>·​may·​need·​to·​include
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-module-trailer.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​5.​ Module·​Trailer</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​grammar.​html"·​title="6.​4.​ Grammar"><link·​rel="next"·​href="sec-​info-​files.​html"·​title="Chapter 7.​ Info·​Files"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​5.​ Module·​Trailer</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​grammar.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​info-​files.​html">Next</​a></​td></​tr></​table><hr></​div><div·​c·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>6.​5.​ Module·​Trailer</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​grammar-​files.​html"·​title="Chapter 6.​ Syntax·​of·​Grammar·​Files"><link·​rel="prev"·​href="sec-​grammar.​html"·​title="6.​4.​ Grammar"><link·​rel="next"·​href="sec-​info-​files.​html"·​title="Chapter 7.​ Info·​Files"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">6.​5.​ Module·​Trailer</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​grammar.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 6.​ Syntax·​of·​Grammar·​Files</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​info-​files.​html">Next</​a></​td></​tr></​table><hr></​div><div·​c·​✂
2 ······​the·​grammar·​file,​·​and·​takes·​the·​same·​form·​as·​the·​module2 ······​the·​grammar·​file,​·​and·​takes·​the·​same·​form·​as·​the·​module
3 ······​header:​</​p><pre·​class="programlisting​">3 ······​header:​</​p><pre·​class="programlisting​">
4 {4 {
5 &lt;​Haskell·​code&gt;​5 &lt;​Haskell·​code&gt;​
6 }6 }
7 </​pre><p>This·​section·​is·​used·​for·​placing·​auxiliary·​definitions7 </​pre><p>This·​section·​is·​used·​for·​placing·​auxiliary·​definitions
8 ······​that·​need·​to·​be·​in·​the·​same·​module·​as·​the·​parser.​··​In·​small8 ······​that·​need·​to·​be·​in·​the·​same·​module·​as·​the·​parser.​··​In·​small
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-monad-alex.html
Offset 1, 37 lines modifiedOffset 1, 37 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​happy-​ghci.​html"·​title="8.​5.​ Using·​Happy·​with·​GHCi"><link·​rel="next"·​href="ix01.​html"·​title="Index"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​happy-​ghci.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="ix01.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​title="8.​6.​ ·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​tips.​html"·​title="Chapter 8.​ Tips"><link·​rel="prev"·​href="sec-​happy-​ghci.​html"·​title="8.​5.​ Using·​Happy·​with·​GHCi"><link·​rel="next"·​href="ix01.​html"·​title="Index"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">8.​6.​ Basic·​monadic·​Happy·​use·​with·​Alex</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​happy-​ghci.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 8.​ Tips</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="ix01.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1"·​title="8.​6.​ ·​✂
2 ········​<span·​class="application">A​lex</​span>·​lexers·​are·​often·​used·​by2 ········​<span·​class="application">A​lex</​span>·​lexers·​are·​often·​used·​by
3 ········​<span·​class="application">H​appy</​span>·​parsers,​·​for·​example·​in3 ········​<span·​class="application">H​appy</​span>·​parsers,​·​for·​example·​in
4 ········​GHC.​·​While·​many·​of·​these·​applications·​are·​quite·​sophisticated,​4 ········​GHC.​·​While·​many·​of·​these·​applications·​are·​quite·​sophisticated,​
5 ········​it·​is·​still·​quite·​useful·​to·​combine·​the·​basic5 ········​it·​is·​still·​quite·​useful·​to·​combine·​the·​basic
6 ········​<span·​class="application">H​appy</​span>·​<code·​class="literal">%mona​d</​code>6 ········​<span·​class="application">H​appy</​span>·​<code·​class="literal">%mona​d</​code>
7 ········​directive·​with·​the·​<span·​class="application">A​lex</​span>7 ········​directive·​with·​the·​<span·​class="application">A​lex</​span>
8 ········​<code·​class="literal">monad​</​code>·​wrapper.​·​By·​using·​monads·​for·​both,​8 ········​<code·​class="literal">monad​</​code>·​wrapper.​·​By·​using·​monads·​for·​both,​
9 ········​the·​resulting·​parser·​and·​lexer·​can·​handle·​errors·​far·​more9 ········​the·​resulting·​parser·​and·​lexer·​can·​handle·​errors·​far·​more
10 ········​gracefully·​than·​by·​throwing·​an·​exception.​10 ········​gracefully·​than·​by·​throwing·​an·​exception.​
11 ······​</​p><p>11 ······​</​p><p>
12 ········​The·​most·​straightforward·​way·​to·​use·​a·​monadic12 ········​The·​most·​straightforward·​way·​to·​use·​a·​monadic
13 ········​<span·​class="application">A​lex</​span>·​lexer·​is·​to·​simply·​use·​the13 ········​<span·​class="application">A​lex</​span>·​lexer·​is·​to·​simply·​use·​the
14 ········​<code·​class="literal">Alex<​/​code>·​monad·​as·​the14 ········​<code·​class="literal">Alex<​/​code>·​monad·​as·​the
15 ········​<span·​class="application">H​appy</​span>·​monad:​15 ········​<span·​class="application">H​appy</​span>·​monad:​
16 ······​</​p><div·​class="example"><a·​name="idp64074808"></​a><p·​class="title"><b>Exam​ple 8.​1.​ Lexer.​x</​b></​p><div·​class="example-​contents"><pre·​class="programlisting​">{16 ······​</​p><div·​class="example"><a·​name="idp64140344"></​a><p·​class="title"><b>Exam​ple 8.​1.​ Lexer.​x</​b></​p><div·​class="example-​contents"><pre·​class="programlisting​">{
17 module·​Lexer·​where17 module·​Lexer·​where
18 }18 }
  
19 %wrapper·​"monad"19 %wrapper·​"monad"
  
20 tokens·​:​-​20 tokens·​:​-​
21 ··​.​.​.​21 ··​.​.​.​
  
22 {22 {
23 data·​Token·​=·​.​.​.​·​|·​EOF23 data·​Token·​=·​.​.​.​·​|·​EOF
24 ··​deriving·​(Eq,​·​Show)​24 ··​deriving·​(Eq,​·​Show)​
  
25 alexEOF·​=·​return·​EOF25 alexEOF·​=·​return·​EOF
26 }</​pre></​div></​div><br·​class="example-​break"><div·​class="example"><a·​name="idp64075832"></​a><p·​class="title"><b>Exam​ple 8.​2.​ Parser.​y</​b></​p><div·​class="example-​contents"><pre·​class="programlisting​">{26 }</​pre></​div></​div><br·​class="example-​break"><div·​class="example"><a·​name="idp64141368"></​a><p·​class="title"><b>Exam​ple 8.​2.​ Parser.​y</​b></​p><div·​class="example-​contents"><pre·​class="programlisting​">{
27 module·​Parser·​where27 module·​Parser·​where
  
28 import·​Lexer28 import·​Lexer
29 }29 }
  
30 %name·​pFoo30 %name·​pFoo
31 %tokentype·​{·​Token·​}31 %tokentype·​{·​Token·​}
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-monads.html
Offset 1, 17 lines modifiedOffset 1, 17 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​5.​ Monadic·​Parsers</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures"><link·​rel="next"·​href="sec-​error.​html"·​title="2.​6.​ The·​Error·​Token"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​5.​ Monadic·​Parsers</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​type-​signatures.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​error.​html">Next</​a></​td></​tr></​table>·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​5.​ Monadic·​Parsers</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​type-​signatures.​html"·​title="2.​4.​ Type·​Signatures"><link·​rel="next"·​href="sec-​error.​html"·​title="2.​6.​ The·​Error·​Token"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​5.​ Monadic·​Parsers</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​type-​signatures.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​error.​html">Next</​a></​td></​tr></​table>·​✂
2 ······​through·​the·​generated·​parser.​··​This·​might·​be·​useful·​for·​several2 ······​through·​the·​generated·​parser.​··​This·​might·​be·​useful·​for·​several
3 ······​reasons:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><a·​class="indexterm"·​name="idp63333432"></​a><p>·​Handling·​parse·​errors·​by·​using·​an·​exception·​monad3 ······​reasons:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><a·​class="indexterm"·​name="idp63398968"></​a><p>·​Handling·​parse·​errors·​by·​using·​an·​exception·​monad
4 ··········​(see·​<a·​class="xref"·​href="sec-​monads.​html#sec-​exception"·​title="2.​5.​1.​ Handling·​Parse·​Errors">Section 2.​5.​1,​·​&#8220;​Handling·​Parse·​Errors&#8221;​</​a>)​.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63336248"></​a><p>·​Keeping·​track·​of·​line·​numbers·​in·​the·​input·​file,​·​for4 ··········​(see·​<a·​class="xref"·​href="sec-​monads.​html#sec-​exception"·​title="2.​5.​1.​ Handling·​Parse·​Errors">Section 2.​5.​1,​·​&#8220;​Handling·​Parse·​Errors&#8221;​</​a>)​.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63401784"></​a><p>·​Keeping·​track·​of·​line·​numbers·​in·​the·​input·​file,​·​for
5 ··········​example·​for·​use·​in·​error·​messages·​(see·​<a·​class="xref"·​href="sec-​monads.​html#sec-​line-​numbers"·​title="2.​5.​3.​ Line·​Numbers">Section 2.​5.​3,​·​&#8220;​Line·​Numbers&#8221;​</​a>)​.​</​p></​li><li·​class="listitem"><p>·​Performing·​IO·​operations·​during·​parsing.​</​p></​li><li·​class="listitem"><p>·​Parsing·​languages·​with·​context-​dependencies·​(such·​as5 ··········​example·​for·​use·​in·​error·​messages·​(see·​<a·​class="xref"·​href="sec-​monads.​html#sec-​line-​numbers"·​title="2.​5.​3.​ Line·​Numbers">Section 2.​5.​3,​·​&#8220;​Line·​Numbers&#8221;​</​a>)​.​</​p></​li><li·​class="listitem"><p>·​Performing·​IO·​operations·​during·​parsing.​</​p></​li><li·​class="listitem"><p>·​Parsing·​languages·​with·​context-​dependencies·​(such·​as
6 ··········​C)​·​require·​some·​state·​in·​the·​parser.​</​p></​li></​ul></​div><p>Adding·​monadic·​support·​to·​your·​parser·​couldn't·​be·​simpler.​6 ··········​C)​·​require·​some·​state·​in·​the·​parser.​</​p></​li></​ul></​div><p>Adding·​monadic·​support·​to·​your·​parser·​couldn't·​be·​simpler.​
7 ······​Just·​add·​the·​following·​directive·​to·​the·​declaration·​section·​of7 ······​Just·​add·​the·​following·​directive·​to·​the·​declaration·​section·​of
8 ······​the·​grammar·​file:​</​p><pre·​class="programlisting​">8 ······​the·​grammar·​file:​</​p><pre·​class="programlisting​">
9 %monad·​{·​&lt;​type&gt;​·​}·​[·​{·​&lt;​then&gt;​·​}·​{·​&lt;​return&gt;​·​}·​]9 %monad·​{·​&lt;​type&gt;​·​}·​[·​{·​&lt;​then&gt;​·​}·​{·​&lt;​return&gt;​·​}·​]
10 </​pre><a·​class="indexterm"·​name="idp63340600"></​a><p>where·​<code·​class="literal">&lt;​type&gt;​</​code>·​is·​the·​type·​constructor·​for10 </​pre><a·​class="indexterm"·​name="idp63406136"></​a><p>where·​<code·​class="literal">&lt;​type&gt;​</​code>·​is·​the·​type·​constructor·​for
11 ······​the·​monad,​·​<code·​class="literal">&lt;​then&gt;​</​code>·​is·​the·​bind·​operation·​of·​the11 ······​the·​monad,​·​<code·​class="literal">&lt;​then&gt;​</​code>·​is·​the·​bind·​operation·​of·​the
12 ······​monad,​·​and·​<code·​class="literal">&lt;​return&gt;​</​code>·​is·​the·​return·​operation.​·​If12 ······​monad,​·​and·​<code·​class="literal">&lt;​return&gt;​</​code>·​is·​the·​return·​operation.​·​If
13 ······​you·​leave·​out·​the·​names·​for·​the·​bind·​and·​return·​operations,​13 ······​you·​leave·​out·​the·​names·​for·​the·​bind·​and·​return·​operations,​
14 ······​<span·​class="application">H​appy</​span>·​assumes·​that·​<code·​class="literal">&lt;​type&gt;​</​code>·​is·​an14 ······​<span·​class="application">H​appy</​span>·​assumes·​that·​<code·​class="literal">&lt;​type&gt;​</​code>·​is·​an
15 ······​instance·​of·​the·​standard·​Haskell·​type·​class·​<code·​class="literal">Monad​</​code>·​and15 ······​instance·​of·​the·​standard·​Haskell·​type·​class·​<code·​class="literal">Monad​</​code>·​and
16 ······​uses·​the·​overloaded·​names·​for·​the·​bind·​and·​return16 ······​uses·​the·​overloaded·​names·​for·​the·​bind·​and·​return
17 ······​operations.​</​p><p>When·​this·​declaration·​is·​included·​in·​the·​grammar,​17 ······​operations.​</​p><p>When·​this·​declaration·​is·​included·​in·​the·​grammar,​
Offset 30, 15 lines modifiedOffset 30, 15 lines modified
30 ······​specify·​that·​the·​productions·​can·​also·​have·​type·​<code·​class="literal">P·​a</​code>?30 ······​specify·​that·​the·​productions·​can·​also·​have·​type·​<code·​class="literal">P·​a</​code>?
31 ······​Most·​of·​the·​time,​·​you·​don't·​want·​a·​production·​to·​have·​this·​type:​31 ······​Most·​of·​the·​time,​·​you·​don't·​want·​a·​production·​to·​have·​this·​type:​
32 ······​you'd·​have·​to·​write·​explicit·​<code·​class="literal">retur​nP</​code>s·​everywhere.​32 ······​you'd·​have·​to·​write·​explicit·​<code·​class="literal">retur​nP</​code>s·​everywhere.​
33 ······​However,​·​there·​may·​be·​a·​few·​rules·​in·​a·​grammar·​that·​need·​to·​get33 ······​However,​·​there·​may·​be·​a·​few·​rules·​in·​a·​grammar·​that·​need·​to·​get
34 ······​at·​the·​monad,​·​so·​<span·​class="application">H​appy</​span>·​has·​a·​special·​syntax·​for34 ······​at·​the·​monad,​·​so·​<span·​class="application">H​appy</​span>·​has·​a·​special·​syntax·​for
35 ······​monadic·​actions:​</​p><pre·​class="programlisting​">35 ······​monadic·​actions:​</​p><pre·​class="programlisting​">
36 n··​:​··​t_1·​.​.​.​·​t_n··········​{%·​&lt;​expr&gt;​·​}36 n··​:​··​t_1·​.​.​.​·​t_n··········​{%·​&lt;​expr&gt;​·​}
37 </​pre><a·​class="indexterm"·​name="idp63357240"></​a><p>The·​<code·​class="literal">%</​code>·​in·​the·​action·​indicates·​that·​this·​is·​a37 </​pre><a·​class="indexterm"·​name="idp63451448"></​a><p>The·​<code·​class="literal">%</​code>·​in·​the·​action·​indicates·​that·​this·​is·​a
38 ······​monadic·​action,​·​with·​type·​<code·​class="literal">P·​a</​code>,​·​where·​<code·​class="literal">a</​code>·​is38 ······​monadic·​action,​·​with·​type·​<code·​class="literal">P·​a</​code>,​·​where·​<code·​class="literal">a</​code>·​is
39 ······​the·​real·​return·​type·​of·​the·​production.​··​When39 ······​the·​real·​return·​type·​of·​the·​production.​··​When
40 ······​<span·​class="application">H​appy</​span>·​reduces·​one·​of·​these·​rules,​·​it·​evaluates·​the40 ······​<span·​class="application">H​appy</​span>·​reduces·​one·​of·​these·​rules,​·​it·​evaluates·​the
41 ······​expression·​</​p><pre·​class="programlisting​">41 ······​expression·​</​p><pre·​class="programlisting​">
42 &lt;​expr&gt;​·​`then`·​\result·​-​&gt;​·​&lt;​continue·​parsing&gt;​42 &lt;​expr&gt;​·​`then`·​\result·​-​&gt;​·​&lt;​continue·​parsing&gt;​
43 </​pre><p><span·​class="application">H​appy</​span>·​uses·​<code·​class="literal">resul​t</​code>·​as·​the·​real43 </​pre><p><span·​class="application">H​appy</​span>·​uses·​<code·​class="literal">resul​t</​code>·​as·​the·​real
44 ······​semantic·​value·​of·​the·​production.​··​During·​parsing,​·​several44 ······​semantic·​value·​of·​the·​production.​··​During·​parsing,​·​several
Offset 55, 15 lines modifiedOffset 55, 15 lines modified
55 ······​doesn't·​impose·​any·​performance·​overhead·​for·​normal·​reductions·​-​55 ······​doesn't·​impose·​any·​performance·​overhead·​for·​normal·​reductions·​-​
56 ······​only·​the·​monadic·​ones·​are·​translated·​like·​this.​</​p><p>Take·​a·​look·​at·​the·​Haskell·​parser·​for·​a·​good·​illustration56 ······​only·​the·​monadic·​ones·​are·​translated·​like·​this.​</​p><p>Take·​a·​look·​at·​the·​Haskell·​parser·​for·​a·​good·​illustration
57 ······​of·​how·​to·​use·​a·​monad·​in·​your·​parser:​·​it·​contains·​examples·​of57 ······​of·​how·​to·​use·​a·​monad·​in·​your·​parser:​·​it·​contains·​examples·​of
58 ······​all·​the·​principles·​discussed·​in·​this·​section,​·​namely·​parse58 ······​all·​the·​principles·​discussed·​in·​this·​section,​·​namely·​parse
59 ······​errors,​·​a·​threaded·​lexer,​·​line/​column·​numbers,​·​and·​state59 ······​errors,​·​a·​threaded·​lexer,​·​line/​column·​numbers,​·​and·​state
60 ······​communication·​between·​the·​parser·​and·​lexer.​</​p><p>The·​following·​sections·​consider·​a·​couple·​of·​uses·​for60 ······​communication·​between·​the·​parser·​and·​lexer.​</​p><p>The·​following·​sections·​consider·​a·​couple·​of·​uses·​for
61 ······​monadic·​parsers,​·​and·​describe·​how·​to·​also·​thread·​the·​monad61 ······​monadic·​parsers,​·​and·​describe·​how·​to·​also·​thread·​the·​monad
62 ······​through·​the·​lexical·​analyser.​</​p><div·​class="sect2"·​title="2.​5.​1.​ Handling·​Parse·​Errors"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​exception"></​a>2.​5.​1.​ Handling·​Parse·​Errors</​h3></​div></​div></​div><a·​class="indexterm"·​name="idp63365560"></​a><p>It's·​not·​very·​convenient·​to·​just·​call·​<code·​class="literal">error​</​code>·​when62 ······​through·​the·​lexical·​analyser.​</​p><div·​class="sect2"·​title="2.​5.​1.​ Handling·​Parse·​Errors"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​exception"></​a>2.​5.​1.​ Handling·​Parse·​Errors</​h3></​div></​div></​div><a·​class="indexterm"·​name="idp63459768"></​a><p>It's·​not·​very·​convenient·​to·​just·​call·​<code·​class="literal">error​</​code>·​when
63 ······​a·​parse·​error·​is·​detected:​·​in·​a·​robust·​setting,​·​you'd·​like·​the63 ······​a·​parse·​error·​is·​detected:​·​in·​a·​robust·​setting,​·​you'd·​like·​the
64 ······​program·​to·​recover·​gracefully·​and·​report·​a·​useful·​error·​message64 ······​program·​to·​recover·​gracefully·​and·​report·​a·​useful·​error·​message
65 ······​to·​the·​user.​··​Exceptions·​(of·​which·​errors·​are·​a·​special·​case)​65 ······​to·​the·​user.​··​Exceptions·​(of·​which·​errors·​are·​a·​special·​case)​
66 ······​are·​normally·​implemented·​in·​Haskell·​by·​using·​an·​exception·​monad,​66 ······​are·​normally·​implemented·​in·​Haskell·​by·​using·​an·​exception·​monad,​
67 ······​something·​like:​</​p><pre·​class="programlisting​">67 ······​something·​like:​</​p><pre·​class="programlisting​">
68 data·​E·​a·​=·​Ok·​a·​|·​Failed·​String68 data·​E·​a·​=·​Ok·​a·​|·​Failed·​String
  
Offset 100, 28 lines modifiedOffset 100, 28 lines modified
100 ········​language·​than·​that·​which·​is·​actually·​intended,​·​and·​check·​it100 ········​language·​than·​that·​which·​is·​actually·​intended,​·​and·​check·​it
101 ········​later.​··​An·​example·​comes·​from·​Haskell,​·​where·​the·​precedence101 ········​later.​··​An·​example·​comes·​from·​Haskell,​·​where·​the·​precedence
102 ········​values·​in·​infix·​declarations·​must·​be·​between·​0·​and·​9:​</​p><pre·​class="programlisting​">prec·​:​:​·​{·​Int·​}102 ········​values·​in·​infix·​declarations·​must·​be·​between·​0·​and·​9:​</​p><pre·​class="programlisting​">prec·​:​:​·​{·​Int·​}
103 ······​:​·​int····​{%·​if·​$1·​&lt;​·​0·​||·​$1·​&gt;​·​9103 ······​:​·​int····​{%·​if·​$1·​&lt;​·​0·​||·​$1·​&gt;​·​9
104 »       ​················​then·​failE·​"Precedence·​out·​of·​range"104 »       ​················​then·​failE·​"Precedence·​out·​of·​range"
105 »       ​»       ​········​else·​returnE·​$1105 »       ​»       ​········​else·​returnE·​$1
106 »       ​»       ​}</​pre><p>The·​monadic·​action·​allows·​the·​check·​to·​be·​placed·​in·​the106 »       ​»       ​}</​pre><p>The·​monadic·​action·​allows·​the·​check·​to·​be·​placed·​in·​the
107 »       ​parser·​itself,​·​where·​it·​belongs.​</​p></​div><div·​class="sect2"·​title="2.​5.​2.​ Threaded·​Lexers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​lexers"></​a>2.​5.​2.​ Threaded·​Lexers</​h3></​div></​div></​div><a·​class="indexterm"·​name="idp63375544"></​a><a·​class="indexterm"·​name="idp63376440"></​a><p><span·​class="application">H​appy</​span>·​allows·​the·​monad·​concept·​to·​be107 »       ​parser·​itself,​·​where·​it·​belongs.​</​p></​div><div·​class="sect2"·​title="2.​5.​2.​ Threaded·​Lexers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​lexers"></​a>2.​5.​2.​ Threaded·​Lexers</​h3></​div></​div></​div><a·​class="indexterm"·​name="idp63469752"></​a><a·​class="indexterm"·​name="idp63470648"></​a><p><span·​class="application">H​appy</​span>·​allows·​the·​monad·​concept·​to·​be
108 »       ​extended·​to·​the·​lexical·​analyser,​·​too.​··​This·​has·​several108 »       ​extended·​to·​the·​lexical·​analyser,​·​too.​··​This·​has·​several
109 »       ​useful·​consequences:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>·​Lexical·​errors·​can·​be·​treated·​in·​the·​same·​way·​as109 »       ​useful·​consequences:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>·​Lexical·​errors·​can·​be·​treated·​in·​the·​same·​way·​as
110 ············​parse·​errors,​·​using·​an·​exception·​monad.​</​p><a·​class="indexterm"·​name="idp63379384"></​a></​li><li·​class="listitem"><p>·​Information·​such·​as·​the·​current·​file·​and·​line110 ············​parse·​errors,​·​using·​an·​exception·​monad.​</​p><a·​class="indexterm"·​name="idp63473592"></​a></​li><li·​class="listitem"><p>·​Information·​such·​as·​the·​current·​file·​and·​line
111 ············​number·​can·​be·​communicated·​between·​the·​lexer·​and111 ············​number·​can·​be·​communicated·​between·​the·​lexer·​and
112 ············​parser.​·​</​p></​li><li·​class="listitem"><p>·​General·​state·​communication·​between·​the·​parser·​and112 ············​parser.​·​</​p></​li><li·​class="listitem"><p>·​General·​state·​communication·​between·​the·​parser·​and
113 ············​lexer·​-​·​for·​example,​·​implementation·​of·​the·​Haskell·​layout113 ············​lexer·​-​·​for·​example,​·​implementation·​of·​the·​Haskell·​layout
114 ············​rule·​requires·​this·​kind·​of·​interaction.​114 ············​rule·​requires·​this·​kind·​of·​interaction.​
115 ············​</​p></​li><li·​class="listitem"><p>·​IO·​operations·​can·​be·​performed·​in·​the·​lexer·​-​·​this115 ············​</​p></​li><li·​class="listitem"><p>·​IO·​operations·​can·​be·​performed·​in·​the·​lexer·​-​·​this
116 ············​could·​be·​useful·​for·​following·​import/​include·​declarations116 ············​could·​be·​useful·​for·​following·​import/​include·​declarations
117 ············​for·​instance.​</​p></​li></​ul></​div><p>A·​monadic·​lexer·​is·​requested·​by·​adding·​the·​following117 ············​for·​instance.​</​p></​li></​ul></​div><p>A·​monadic·​lexer·​is·​requested·​by·​adding·​the·​following
118 »       ​declaration·​to·​the·​grammar·​file:​</​p><pre·​class="programlisting​">118 »       ​declaration·​to·​the·​grammar·​file:​</​p><pre·​class="programlisting​">
119 %lexer·​{·​&lt;​lexer&gt;​·​}·​{·​&lt;​eof&gt;​·​}119 %lexer·​{·​&lt;​lexer&gt;​·​}·​{·​&lt;​eof&gt;​·​}
120 </​pre><a·​class="indexterm"·​name="idp63384120"></​a><p>where·​<code·​class="literal">&lt;​lexer&gt;​</​code>·​is·​the·​name·​of·​the·​lexical120 </​pre><a·​class="indexterm"·​name="idp63478328"></​a><p>where·​<code·​class="literal">&lt;​lexer&gt;​</​code>·​is·​the·​name·​of·​the·​lexical
121 ········​analyser·​function,​·​and·​<code·​class="literal">&lt;​eof&gt;​</​code>·​is·​a·​token·​that121 ········​analyser·​function,​·​and·​<code·​class="literal">&lt;​eof&gt;​</​code>·​is·​a·​token·​that
122 ········​is·​to·​be·​treated·​as·​the·​end·​of·​file.​</​p><p>When·​using·​a·​monadic·​lexer,​·​the·​parser·​no·​longer·​reads·​a122 ········​is·​to·​be·​treated·​as·​the·​end·​of·​file.​</​p><p>When·​using·​a·​monadic·​lexer,​·​the·​parser·​no·​longer·​reads·​a
123 ········​list·​of·​tokens.​··​Instead,​·​it·​calls·​the·​lexical·​analysis123 ········​list·​of·​tokens.​··​Instead,​·​it·​calls·​the·​lexical·​analysis
124 ········​function·​for·​each·​new·​token·​to·​be·​read.​··​This·​has·​the·​side124 ········​function·​for·​each·​new·​token·​to·​be·​read.​··​This·​has·​the·​side
125 ········​effect·​of·​eliminating·​the·​intermediate·​list·​of·​tokens,​·​which125 ········​effect·​of·​eliminating·​the·​intermediate·​list·​of·​tokens,​·​which
126 ········​is·​a·​slight·​performance·​win.​</​p><p>The·​type·​of·​the·​main·​parser·​function·​is·​now·​just126 ········​is·​a·​slight·​performance·​win.​</​p><p>The·​type·​of·​the·​main·​parser·​function·​is·​now·​just
127 ········​<code·​class="literal">P·​a</​code>·​-​·​the·​input·​is·​being·​handled·​completely127 ········​<code·​class="literal">P·​a</​code>·​-​·​the·​input·​is·​being·​handled·​completely
Offset 185, 30 lines modifiedOffset 185, 30 lines modified
185 ········​still·​holds·​(or·​indeed·​ever·​held)​,​·​and·​it's·​entirely·​possible185 ········​still·​holds·​(or·​indeed·​ever·​held)​,​·​and·​it's·​entirely·​possible
186 ········​that·​the·​use·​of·​a·​continuation·​here·​is·​just·​a186 ········​that·​the·​use·​of·​a·​continuation·​here·​is·​just·​a
187 ········​misfeature.​</​p><p>If·​you·​want·​a·​lexer·​of·​type·​<code·​class="literal">P·​Token</​code>,​187 ········​misfeature.​</​p><p>If·​you·​want·​a·​lexer·​of·​type·​<code·​class="literal">P·​Token</​code>,​
188 ········​then·​just·​define·​a·​wrapper·​to·​deal·​with·​the188 ········​then·​just·​define·​a·​wrapper·​to·​deal·​with·​the
189 ········​continuation:​</​p><pre·​class="programlisting​">189 ········​continuation:​</​p><pre·​class="programlisting​">
190 lexwrap·​:​:​·​(Token·​-​&gt;​·​P·​a)​·​-​&gt;​·​P·​a190 lexwrap·​:​:​·​(Token·​-​&gt;​·​P·​a)​·​-​&gt;​·​P·​a
191 lexwrap·​cont·​=·​real_lexer·​`thenP`·​\token·​-​&gt;​·​cont·​token191 lexwrap·​cont·​=·​real_lexer·​`thenP`·​\token·​-​&gt;​·​cont·​token
192 </​pre><div·​class="sect3"·​title="2.​5.​2.​1.​ Monadic·​productions·​with·​%lexer"><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63399864"></​a>2.​5.​2.​1.​ Monadic·​productions·​with·​%lexer</​h4></​div></​div></​div><p>The·​<code·​class="literal">{%·​.​.​.​·​}</​code>·​actions·​work·​fine·​with192 </​pre><div·​class="sect3"·​title="2.​5.​2.​1.​ Monadic·​productions·​with·​%lexer"><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63494072"></​a>2.​5.​2.​1.​ Monadic·​productions·​with·​%lexer</​h4></​div></​div></​div><p>The·​<code·​class="literal">{%·​.​.​.​·​}</​code>·​actions·​work·​fine·​with
193 »       ​<code·​class="literal">%lexe​r</​code>,​·​but·​additionally·​there·​are·​two·​more193 »       ​<code·​class="literal">%lexe​r</​code>,​·​but·​additionally·​there·​are·​two·​more
194 »       ​forms·​which·​are·​useful·​in·​certain·​cases.​··​Firstly:​</​p><pre·​class="programlisting​">194 »       ​forms·​which·​are·​useful·​in·​certain·​cases.​··​Firstly:​</​p><pre·​class="programlisting​">
195 n··​:​··​t_1·​.​.​.​·​t_n··········​{%^·​&lt;​expr&gt;​·​}195 n··​:​··​t_1·​.​.​.​·​t_n··········​{%^·​&lt;​expr&gt;​·​}
196 </​pre><p>In·​this·​case,​·​<code·​class="literal">&lt;​expr&gt;​</​code>·​has·​type196 </​pre><p>In·​this·​case,​·​<code·​class="literal">&lt;​expr&gt;​</​code>·​has·​type
197 »       ​<code·​class="literal">Token​·​-​&gt;​·​P·​a</​code>.​··​That·​is,​·​Happy·​passes·​the197 »       ​<code·​class="literal">Token​·​-​&gt;​·​P·​a</​code>.​··​That·​is,​·​Happy·​passes·​the
198 »       ​current·​lookahead·​token·​to·​the·​monadic·​action198 »       ​current·​lookahead·​token·​to·​the·​monadic·​action
199 »       ​<code·​class="literal">&lt;​expr&gt;​</​code>.​··​This·​is·​a·​useful·​way·​to·​get199 »       ​<code·​class="literal">&lt;​expr&gt;​</​code>.​··​This·​is·​a·​useful·​way·​to·​get
200 »       ​hold·​of·​Happy's·​current·​lookahead·​token·​without·​having·​to200 »       ​hold·​of·​Happy's·​current·​lookahead·​token·​without·​having·​to
201 »       ​store·​it·​in·​the·​monad.​</​p><pre·​class="programlisting​">201 »       ​store·​it·​in·​the·​monad.​</​p><pre·​class="programlisting​">
202 n··​:​··​t_1·​.​.​.​·​t_n··········​{%%·​&lt;​expr&gt;​·​}202 n··​:​··​t_1·​.​.​.​·​t_n··········​{%%·​&lt;​expr&gt;​·​}
203 </​pre><p>This·​is·​a·​slight·​variant·​on·​the·​previous·​form.​··​The·​type203 </​pre><p>This·​is·​a·​slight·​variant·​on·​the·​previous·​form.​··​The·​type
204 »       ​of·​<code·​class="literal">&lt;​expr&gt;​</​code>·​is·​the·​same,​·​but·​in·​this204 »       ​of·​<code·​class="literal">&lt;​expr&gt;​</​code>·​is·​the·​same,​·​but·​in·​this
205 »       ​case·​the·​lookahead·​token·​is·​actually·​discarded·​and·​a·​new·​token205 »       ​case·​the·​lookahead·​token·​is·​actually·​discarded·​and·​a·​new·​token
206 »       ​is·​read·​from·​the·​input.​··​This·​can·​be·​useful·​when·​you·​want·​to206 »       ​is·​read·​from·​the·​input.​··​This·​can·​be·​useful·​when·​you·​want·​to
207 »       ​change·​the·​next·​token·​and·​continue·​parsing.​</​p></​div></​div><div·​class="sect2"·​title="2.​5.​3.​ Line·​Numbers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​line-​numbers"></​a>2.​5.​3.​ Line·​Numbers</​h3></​div></​div></​div><a·​class="indexterm"·​name="idp63447864"></​a><a·​class="indexterm"·​name="idp63448760"></​a><p>Previous·​versions·​of·​<span·​class="application">H​appy</​span>·​had·​a207 »       ​change·​the·​next·​token·​and·​continue·​parsing.​</​p></​div></​div><div·​class="sect2"·​title="2.​5.​3.​ Line·​Numbers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​line-​numbers"></​a>2.​5.​3.​ Line·​Numbers</​h3></​div></​div></​div><a·​class="indexterm"·​name="idp63501112"></​a><a·​class="indexterm"·​name="idp63502008"></​a><p>Previous·​versions·​of·​<span·​class="application">H​appy</​span>·​had·​a
208 ········​<code·​class="literal">%newl​ine</​code>·​directive·​that·​enabled·​simple·​line·​numbers208 ········​<code·​class="literal">%newl​ine</​code>·​directive·​that·​enabled·​simple·​line·​numbers
209 ········​to·​be·​counted·​by·​the·​parser·​and·​referenced·​in·​the·​actions.​··​We209 ········​to·​be·​counted·​by·​the·​parser·​and·​referenced·​in·​the·​actions.​··​We
210 ········​warned·​you·​that·​this·​facility·​may·​go·​away·​and·​be·​replaced·​by210 ········​warned·​you·​that·​this·​facility·​may·​go·​away·​and·​be·​replaced·​by
211 ········​something·​more·​general,​·​well·​guess·​what?·​:​-​)​</​p><p>Line·​numbers·​can·​now·​be·​dealt·​with·​quite211 ········​something·​more·​general,​·​well·​guess·​what?·​:​-​)​</​p><p>Line·​numbers·​can·​now·​be·​dealt·​with·​quite
212 ········​straightforwardly·​using·​a·​monadic·​parser/​lexer·​combination.​212 ········​straightforwardly·​using·​a·​monadic·​parser/​lexer·​combination.​
213 ········​Ok,​·​we·​have·​to·​extend·​the·​monad·​a·​bit·​more:​</​p><pre·​class="programlisting​">213 ········​Ok,​·​we·​have·​to·​extend·​the·​monad·​a·​bit·​more:​</​p><pre·​class="programlisting​">
214 type·​LineNumber·​=·​Int214 type·​LineNumber·​=·​Int
Offset 244, 15 lines modifiedOffset 244, 15 lines modified
244 ········​since·​<span·​class="application">H​appy</​span>·​always·​keeps·​one·​lookahead·​token·​in244 ········​since·​<span·​class="application">H​appy</​span>·​always·​keeps·​one·​lookahead·​token·​in
245 ········​reserve.​</​p></​div><div·​class="sect2"·​title="2.​5.​4.​ Summary"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​monad-​summary"></​a>2.​5.​4.​ Summary</​h3></​div></​div></​div><p>The·​types·​of·​various·​functions·​related·​to·​the·​parser·​are245 ········​reserve.​</​p></​div><div·​class="sect2"·​title="2.​5.​4.​ Summary"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="sec-​monad-​summary"></​a>2.​5.​4.​ Summary</​h3></​div></​div></​div><p>The·​types·​of·​various·​functions·​related·​to·​the·​parser·​are
246 ········​dependent·​on·​what·​combination·​of·​<code·​class="literal">%mona​d</​code>·​and246 ········​dependent·​on·​what·​combination·​of·​<code·​class="literal">%mona​d</​code>·​and
247 ········​<code·​class="literal">%lexe​r</​code>·​directives·​are·​present·​in·​the·​grammar.​··​For247 ········​<code·​class="literal">%lexe​r</​code>·​directives·​are·​present·​in·​the·​grammar.​··​For
248 ········​reference,​·​we·​list·​those·​types·​here.​··​In·​the·​following·​types,​248 ········​reference,​·​we·​list·​those·​types·​here.​··​In·​the·​following·​types,​
249 ········​<span·​class="emphasis"><em>​t</​em></​span>·​is·​the·​return·​type·​of·​the249 ········​<span·​class="emphasis"><em>​t</​em></​span>·​is·​the·​return·​type·​of·​the
250 ········​parser.​··​A·​type·​containing·​a·​type·​variable·​indicates·​that·​the250 ········​parser.​··​A·​type·​containing·​a·​type·​variable·​indicates·​that·​the
251 ········​specified·​function·​must·​be·​polymorphic.​</​p><a·​class="indexterm"·​name="idp63461944"></​a><a·​class="indexterm"·​name="idp63467704"></​a><a·​class="indexterm"·​name="idp63468984"></​a><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p·​title="No·​%monad·​or·​%lexer"><b>·​No·​<code·​class="literal">%mona​d</​code>·​or251 ········​specified·​function·​must·​be·​polymorphic.​</​p><a·​class="indexterm"·​name="idp63527480"></​a><a·​class="indexterm"·​name="idp63533240"></​a><a·​class="indexterm"·​name="idp63534520"></​a><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p·​title="No·​%monad·​or·​%lexer"><b>·​No·​<code·​class="literal">%mona​d</​code>·​or
252 »       ​······​<code·​class="literal">%lexe​r</​code>·​.​ </​b>252 »       ​······​<code·​class="literal">%lexe​r</​code>·​.​ </​b>
253 </​p><pre·​class="programlisting​">253 </​p><pre·​class="programlisting​">
254 parse······​:​:​·​[Token]·​-​&gt;​·​<span·​class="emphasis"><em>​t</​em></​span>254 parse······​:​:​·​[Token]·​-​&gt;​·​<span·​class="emphasis"><em>​t</​em></​span>
255 parseError·​:​:​·​[Token]·​-​&gt;​·​a255 parseError·​:​:​·​[Token]·​-​&gt;​·​a
256 </​pre><p·​title="No·​%monad·​or·​%lexer">256 </​pre><p·​title="No·​%monad·​or·​%lexer">
257 </​p></​li><li·​class="listitem"><p·​title="with·​%monad"><b>·​with·​<code·​class="literal">%mona​d</​code>·​.​ </​b>257 </​p></​li><li·​class="listitem"><p·​title="with·​%monad"><b>·​with·​<code·​class="literal">%mona​d</​code>·​.​ </​b>
258 </​p><pre·​class="programlisting​">258 </​p><pre·​class="programlisting​">
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-multiple-parsers.html
Offset 1, 20 lines modifiedOffset 1, 20 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​error.​html"·​title="2.​6.​ The·​Error·​Token"><link·​rel="next"·​href="sec-​glr.​html"·​title="Chapter 3.​ Generalized·​LR·​Parsing"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​error.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​acc·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​error.​html"·​title="2.​6.​ The·​Error·​Token"><link·​rel="next"·​href="sec-​glr.​html"·​title="Chapter 3.​ Generalized·​LR·​Parsing"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​7.​ Generating·​Multiple·​Parsers·​From·​a·​Single·​Grammar</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​error.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​acc·​✂
2 ······​multiple·​parsers,​·​where·​each·​parser·​has·​a·​different·​top-​level2 ······​multiple·​parsers,​·​where·​each·​parser·​has·​a·​different·​top-​level
3 ······​non-​terminal,​·​but·​parts·​of·​the·​grammar·​are·​shared·​between3 ······​non-​terminal,​·​but·​parts·​of·​the·​grammar·​are·​shared·​between
4 ······​parsers.​··​A·​classic·​example·​of·​this·​is·​an·​interpreter,​·​which4 ······​parsers.​··​A·​classic·​example·​of·​this·​is·​an·​interpreter,​·​which
5 ······​needs·​to·​be·​able·​to·​parse·​both·​entire·​files·​and·​single5 ······​needs·​to·​be·​able·​to·​parse·​both·​entire·​files·​and·​single
6 ······​expressions:​·​the·​expression·​grammar·​is·​likely·​to·​be·​identical6 ······​expressions:​·​the·​expression·​grammar·​is·​likely·​to·​be·​identical
7 ······​for·​the·​two·​parsers,​·​so·​we·​would·​like·​to·​use·​a·​single·​grammar7 ······​for·​the·​two·​parsers,​·​so·​we·​would·​like·​to·​use·​a·​single·​grammar
8 ······​but·​have·​two·​entry·​points.​</​p><p><span·​class="application">H​appy</​span>·​lets·​you·​do·​this·​by8 ······​but·​have·​two·​entry·​points.​</​p><p><span·​class="application">H​appy</​span>·​lets·​you·​do·​this·​by
9 ······​allowing·​multiple·​<code·​class="literal">%name​</​code>·​directives·​in·​the9 ······​allowing·​multiple·​<code·​class="literal">%name​</​code>·​directives·​in·​the
10 ······​grammar·​file.​··​The·​<code·​class="literal">%name​</​code>·​directive·​takes·​an10 ······​grammar·​file.​··​The·​<code·​class="literal">%name​</​code>·​directive·​takes·​an
11 ······​optional·​second·​parameter·​specifying·​the·​top-​level11 ······​optional·​second·​parameter·​specifying·​the·​top-​level
12 ······​non-​terminal·​for·​this·​parser,​·​so·​we·​may·​specify·​multiple·​parsers12 ······​non-​terminal·​for·​this·​parser,​·​so·​we·​may·​specify·​multiple·​parsers
13 ······​like·​so:​</​p><a·​class="indexterm"·​name="idp63506232"></​a><pre·​class="programlisting​">13 ······​like·​so:​</​p><a·​class="indexterm"·​name="idp63571768"></​a><pre·​class="programlisting​">
14 %name·​parse1·​non-​terminal114 %name·​parse1·​non-​terminal1
15 %name·​parse2·​non-​terminal215 %name·​parse2·​non-​terminal2
16 </​pre><p><span·​class="application">H​appy</​span>·​will·​generate·​from·​this·​a16 </​pre><p><span·​class="application">H​appy</​span>·​will·​generate·​from·​this·​a
17 ······​module·​which·​defines·​two·​functions·​<code·​class="function">pars​e1</​code>17 ······​module·​which·​defines·​two·​functions·​<code·​class="function">pars​e1</​code>
18 ······​and·​<code·​class="function">pars​e2</​code>,​·​which·​parse·​the·​grammars·​given18 ······​and·​<code·​class="function">pars​e2</​code>,​·​which·​parse·​the·​grammars·​given
19 ······​by·​<code·​class="literal">non-​terminal1</​code>·​and19 ······​by·​<code·​class="literal">non-​terminal1</​code>·​and
20 ······​<code·​class="literal">non-​terminal2</​code>·​respectively.​··​Each·​parsing20 ······​<code·​class="literal">non-​terminal2</​code>·​respectively.​··​Each·​parsing
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-reporting-bugs.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>1.​2.​ Reporting·​Bugs</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"><link·​rel="prev"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"><link·​rel="next"·​href="sec-​license.​html"·​title="1.​3.​ License"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">1.​2.​ Reporting·​Bugs</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="happy-​introduction.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 1.​ Introduction</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​license.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>1.​2.​ Reporting·​Bugs</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"><link·​rel="prev"·​href="happy-​introduction.​html"·​title="Chapter 1.​ Introduction"><link·​rel="next"·​href="sec-​license.​html"·​title="1.​3.​ License"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">1.​2.​ Reporting·​Bugs</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="happy-​introduction.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 1.​ Introduction</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​license.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="sect1·​✂
2 ······​be·​reported·​to·​me:​·​Simon·​Marlow2 ······​be·​reported·​to·​me:​·​Simon·​Marlow
3 ······​<code·​class="email">&lt;​<a·​class="email"·​href="mailto:​marlowsd@gmail.​com">marlowsd@gmail.​com</​a>&gt;​</​code>·​including·​all·​the·​relevant3 ······​<code·​class="email">&lt;​<a·​class="email"·​href="mailto:​marlowsd@gmail.​com">marlowsd@gmail.​com</​a>&gt;​</​code>·​including·​all·​the·​relevant
4 ······​information:​·​the·​compiler·​used·​to·​compile4 ······​information:​·​the·​compiler·​used·​to·​compile
5 ······​<span·​class="application">H​appy</​span>,​·​the·​command-​line·​options·​used,​5 ······​<span·​class="application">H​appy</​span>,​·​the·​command-​line·​options·​used,​
6 ······​your·​grammar·​file·​or·​preferably·​a·​cut-​down·​example·​showing·​the6 ······​your·​grammar·​file·​or·​preferably·​a·​cut-​down·​example·​showing·​the
7 ······​problem,​·​and·​a·​description·​of·​what·​goes·​wrong.​··​A·​patch·​to·​fix7 ······​problem,​·​and·​a·​description·​of·​what·​goes·​wrong.​··​A·​patch·​to·​fix
8 ······​the·​problem·​would·​also·​be·​greatly·​appreciated.​·​</​p><p>·​Requests·​for·​new·​features·​should·​also·​be·​sent·​to·​the8 ······​the·​problem·​would·​also·​be·​greatly·​appreciated.​·​</​p><p>·​Requests·​for·​new·​features·​should·​also·​be·​sent·​to·​the
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-sequences.html
Offset 9, 15 lines modifiedOffset 9, 15 lines modified
9 prods·​:​·​prod···················​{·​[$1]·​}9 prods·​:​·​prod···················​{·​[$1]·​}
10 ······​|·​prods·​prod·············​{·​$2·​:​·​$1·​}10 ······​|·​prods·​prod·············​{·​$2·​:​·​$1·​}
11 </​pre><p>In·​other·​words,​·​a·​sequence·​of·​productions·​is·​either·​a11 </​pre><p>In·​other·​words,​·​a·​sequence·​of·​productions·​is·​either·​a
12 ······​single·​production,​·​or·​a·​sequence·​of·​productions·​followed·​by·​a12 ······​single·​production,​·​or·​a·​sequence·​of·​productions·​followed·​by·​a
13 ······​single·​production.​··​This·​recursive·​rule·​defines·​a·​sequence·​of13 ······​single·​production.​··​This·​recursive·​rule·​defines·​a·​sequence·​of
14 ······​one·​or·​more·​productions.​</​p><p>One·​thing·​to·​note·​about·​this·​rule·​is·​that·​we·​used14 ······​one·​or·​more·​productions.​</​p><p>One·​thing·​to·​note·​about·​this·​rule·​is·​that·​we·​used
15 ······​<span·​class="emphasis"><em>​left·​recursion</​em></​span>·​to·​define·​it·​-​·​we·​could·​have·​written15 ······​<span·​class="emphasis"><em>​left·​recursion</​em></​span>·​to·​define·​it·​-​·​we·​could·​have·​written
16 ······​it·​like·​this:​</​p><a·​class="indexterm"·​name="idp63251512"></​a><pre·​class="programlisting​">16 ······​it·​like·​this:​</​p><a·​class="indexterm"·​name="idp63317048"></​a><pre·​class="programlisting​">
17 prods·​:​·​prod··················​{·​[$1]·​}17 prods·​:​·​prod··················​{·​[$1]·​}
18 ······​|·​prod·​prods············​{·​$1·​:​·​$2·​}18 ······​|·​prod·​prods············​{·​$1·​:​·​$2·​}
19 </​pre><p>The·​only·​reason·​we·​used·​left·​recursion·​is·​that19 </​pre><p>The·​only·​reason·​we·​used·​left·​recursion·​is·​that
20 ······​<span·​class="application">H​appy</​span>·​is·​more·​efficient·​at·​parsing·​left-​recursive20 ······​<span·​class="application">H​appy</​span>·​is·​more·​efficient·​at·​parsing·​left-​recursive
21 ······​rules;​·​they·​result·​in·​a·​constant·​stack-​space·​parser,​·​whereas21 ······​rules;​·​they·​result·​in·​a·​constant·​stack-​space·​parser,​·​whereas
22 ······​right-​recursive·​rules·​require·​stack·​space·​proportional·​to·​the22 ······​right-​recursive·​rules·​require·​stack·​space·​proportional·​to·​the
23 ······​length·​of·​the·​list·​being·​parsed.​··​This·​can·​be·​extremely23 ······​length·​of·​the·​list·​being·​parsed.​··​This·​can·​be·​extremely
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-tips.html
Offset 1, 18 lines modifiedOffset 1, 18 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 8.​ Tips</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​info-​files.​html"·​title="Chapter 7.​ Info·​Files"><link·​rel="next"·​href="sec-​compilation-​time.​html"·​title="8.​2.​ Compilation-​Time·​Tips"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 8.​ Tips</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​info-​files.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​compilation-​time.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="chapter"·​title="Chapter 8.​ Tips">·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 8.​ Tips</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​info-​files.​html"·​title="Chapter 7.​ Info·​Files"><link·​rel="next"·​href="sec-​compilation-​time.​html"·​title="8.​2.​ Compilation-​Time·​Tips"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 8.​ Tips</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​info-​files.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​compilation-​time.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="chapter"·​title="Chapter 8.​ Tips">·​✂
2 ····​<span·​class="application">H​appy</​span>.​</​p><div·​class="sect1"·​title="8.​1.​ Performance·​Tips"><div·​class="titlepage"><di​v><div><h2·​class="title"·​style="clear:​·​both"><a·​name="sec-​performance-​tips"></​a>8.​1.​ Performance·​Tips</​h2></​div></​div></​div><p>How·​to·​make·​your·​parser·​go·​faster:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><a·​class="indexterm"·​name="idp63977144"></​a><p>·​If·​you·​are·​using·​GHC,​·​generate·​parsers·​using·​the2 ····​<span·​class="application">H​appy</​span>.​</​p><div·​class="sect1"·​title="8.​1.​ Performance·​Tips"><div·​class="titlepage"><di​v><div><h2·​class="title"·​style="clear:​·​both"><a·​name="sec-​performance-​tips"></​a>8.​1.​ Performance·​Tips</​h2></​div></​div></​div><p>How·​to·​make·​your·​parser·​go·​faster:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><a·​class="indexterm"·​name="idp64042680"></​a><p>·​If·​you·​are·​using·​GHC,​·​generate·​parsers·​using·​the
3 ··········​<code·​class="literal">-​a·​-​g·​-​c</​code>·​options,​·​and·​compile·​them·​using·​GHC·​with3 ··········​<code·​class="literal">-​a·​-​g·​-​c</​code>·​options,​·​and·​compile·​them·​using·​GHC·​with
4 ··········​the·​<code·​class="literal">-​fglasgow-​exts</​code>·​option.​··​This·​is·​worth·​a4 ··········​the·​<code·​class="literal">-​fglasgow-​exts</​code>·​option.​··​This·​is·​worth·​a
5 ··········​<span·​class="emphasis"><em>​lot</​em></​span>,​·​in·​terms·​of·​compile-​time,​5 ··········​<span·​class="emphasis"><em>​lot</​em></​span>,​·​in·​terms·​of·​compile-​time,​
6 ··········​execution·​speed·​and·​binary·​size·​<sup>[<a·​name="idp63983800"·​href="#ftn.​idp63983800"·​class="footnote">4</​a>]</​sup>.​</​p></​li><li·​class="listitem"><p>·​The·​lexical·​analyser·​is·​usually·​the·​most·​performance6 ··········​execution·​speed·​and·​binary·​size·​<sup>[<a·​name="idp64049336"·​href="#ftn.​idp64049336"·​class="footnote">4</​a>]</​sup>.​</​p></​li><li·​class="listitem"><p>·​The·​lexical·​analyser·​is·​usually·​the·​most·​performance
7 ··········​critical·​part·​of·​a·​parser,​·​so·​it's·​worth·​spending·​some·​time7 ··········​critical·​part·​of·​a·​parser,​·​so·​it's·​worth·​spending·​some·​time
8 ··········​optimising·​this.​··​Profiling·​tools·​are·​essential·​here.​··​In8 ··········​optimising·​this.​··​Profiling·​tools·​are·​essential·​here.​··​In
9 ··········​really·​dire·​circumstances,​·​resort·​to·​some·​of·​the·​hacks·​that9 ··········​really·​dire·​circumstances,​·​resort·​to·​some·​of·​the·​hacks·​that
10 ··········​are·​used·​in·​the·​Glasgow·​Haskell·​Compiler's·​interface-​file10 ··········​are·​used·​in·​the·​Glasgow·​Haskell·​Compiler's·​interface-​file
11 ··········​lexer.​</​p></​li><li·​class="listitem"><p>·​Simplify·​the·​grammar·​as·​much·​as·​possible,​·​as·​this11 ··········​lexer.​</​p></​li><li·​class="listitem"><p>·​Simplify·​the·​grammar·​as·​much·​as·​possible,​·​as·​this
12 ··········​reduces·​the·​number·​of·​states·​and·​reduction·​rules·​that·​need12 ··········​reduces·​the·​number·​of·​states·​and·​reduction·​rules·​that·​need
13 ··········​to·​be·​applied.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp63986872"></​a><p>·​Use·​left·​recursion·​rather·​than·​right·​recursion13 ··········​to·​be·​applied.​</​p></​li><li·​class="listitem"><a·​class="indexterm"·​name="idp64052408"></​a><p>·​Use·​left·​recursion·​rather·​than·​right·​recursion
14 ··········​wherever·​possible.​··​While·​not·​strictly·​a·​performance·​issue,​14 ··········​wherever·​possible.​··​While·​not·​strictly·​a·​performance·​issue,​
15 ··········​this·​affects·​the·​size·​of·​the·​parser·​stack,​·​which·​is·​kept·​on15 ··········​this·​affects·​the·​size·​of·​the·​parser·​stack,​·​which·​is·​kept·​on
16 ··········​the·​heap·​and·​thus·​needs·​to·​be·​garbage·​collected.​</​p></​li></​ul></​div></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63983800"·​href="#idp63983800"·​class="para">4</​a>]·​</​sup>omitting·​the16 ··········​the·​heap·​and·​thus·​needs·​to·​be·​garbage·​collected.​</​p></​li></​ul></​div></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp64049336"·​href="#idp64049336"·​class="para">4</​a>]·​</​sup>omitting·​the
17 ··········​<code·​class="literal">-​a</​code>·​may·​generate·​slightly·​faster·​parsers,​17 ··········​<code·​class="literal">-​a</​code>·​may·​generate·​slightly·​faster·​parsers,​
18 ··········​but·​they·​will·​be·​much·​bigger.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="sec-​info-​files.​html">Prev</​a> </​td><td·​width="20%"·​align="center"> </​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="sec-​compilation-​time.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">Chapter ​7.​ Info·​Files </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> 8.​2.​ Compilation-​Time·​Tips</​td></​tr></​table></​div></​body></​html>18 ··········​but·​they·​will·​be·​much·​bigger.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="sec-​info-​files.​html">Prev</​a> </​td><td·​width="20%"·​align="center"> </​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="sec-​compilation-​time.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">Chapter ​7.​ Info·​Files </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> 8.​2.​ Compilation-​Time·​Tips</​td></​tr></​table></​div></​body></​html>
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-type-signatures.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​4.​ Type·​Signatures</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​Precedences.​html"·​title="2.​3.​ Using·​Precedences"><link·​rel="next"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​4.​ Type·​Signatures</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​Precedences.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​monads.​html">Next</​a></​td></​tr></​table><hr>·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>2.​4.​ Type·​Signatures</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="sec-​using.​html"·​title="Chapter 2.​ Using·​Happy"><link·​rel="prev"·​href="sec-​Precedences.​html"·​title="2.​3.​ Using·​Precedences"><link·​rel="next"·​href="sec-​monads.​html"·​title="2.​5.​ Monadic·​Parsers"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">2.​4.​ Type·​Signatures</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​Precedences.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​monads.​html">Next</​a></​td></​tr></​table><hr>·​✂
2 ······​in·​the·​grammar·​file·​itself,​·​to·​indicate·​the·​type·​of·​each2 ······​in·​the·​grammar·​file·​itself,​·​to·​indicate·​the·​type·​of·​each
3 ······​production.​··​This·​has·​several·​benefits:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>·​Documentation:​·​including·​types·​in·​the·​grammar·​helps3 ······​production.​··​This·​has·​several·​benefits:​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>·​Documentation:​·​including·​types·​in·​the·​grammar·​helps
4 ··········​to·​document·​the·​grammar·​for·​someone·​else·​(and·​indeed4 ··········​to·​document·​the·​grammar·​for·​someone·​else·​(and·​indeed
5 ··········​yourself)​·​reading·​the·​code.​</​p></​li><li·​class="listitem"><p>·​Fixing·​type·​errors·​in·​the·​generated·​module·​can·​become5 ··········​yourself)​·​reading·​the·​code.​</​p></​li><li·​class="listitem"><p>·​Fixing·​type·​errors·​in·​the·​generated·​module·​can·​become
6 ··········​slightly·​easier·​if·​<span·​class="application">H​appy</​span>·​has·​inserted·​type6 ··········​slightly·​easier·​if·​<span·​class="application">H​appy</​span>·​has·​inserted·​type
7 ··········​signatures·​for·​you.​··​This·​is·​a·​slightly·​dubious·​benefit,​7 ··········​signatures·​for·​you.​··​This·​is·​a·​slightly·​dubious·​benefit,​
8 ··········​since·​type·​errors·​in·​the·​generated·​module·​are·​still·​somewhat8 ··········​since·​type·​errors·​in·​the·​generated·​module·​are·​still·​somewhat
/usr/local/share/doc/cabal/ghc-7.10.2/happy-1.19.5/html/sec-using.html
Offset 1, 8 lines modifiedOffset 1, 8 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 2.​ Using·​Happy</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​obtaining.​html"·​title="1.​4.​ Obtaining·​Happy"><link·​rel="next"·​href="sec-​sequences.​html"·​title="2.​2.​ Parsing·​sequences"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​obtaining.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​sequences.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="chapter·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 2.​ Using·​Happy</​title><link·​rel="stylesheet"·​type="text/​css"·​href="fptools.​css"><meta·​name="generator"·​content="DocBook·​XSL·​Stylesheets·​V1.​76.​1"><link·​rel="home"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Happy·​User·​Guide"><link·​rel="prev"·​href="sec-​obtaining.​html"·​title="1.​4.​ Obtaining·​Happy"><link·​rel="next"·​href="sec-​sequences.​html"·​title="2.​2.​ Parsing·​sequences"></​head><body·​bgcolor="white"·​text="black"·​link="#0000FF"·​vlink="#840084"·​alink="#0000FF"><div·​class="navheader"><ta​ble·​width="100%"·​summary="Navigation·​header"><tr><th·​colspan="3"·​align="center">Chapte​r 2.​ Using·​<span·​class="application">H​appy</​span></​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="sec-​obtaining.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="sec-​sequences.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="chapter·​✂
2 ··​<span·​class="application">H​appy</​span>·​quite·​familiar.​··​The·​basic·​idea·​is2 ··​<span·​class="application">H​appy</​span>·​quite·​familiar.​··​The·​basic·​idea·​is
3 ··​as·​follows:​·​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>D​efine·​the·​grammar·​you·​want·​to·​parse·​in·​a3 ··​as·​follows:​·​</​p><div·​class="itemizedlist">​<ul·​class="itemizedlist"·​type="disc"><li·​class="listitem"><p>D​efine·​the·​grammar·​you·​want·​to·​parse·​in·​a
4 ······​<span·​class="application">H​appy</​span>·​grammar·​file.​·​</​p></​li><li·​class="listitem"><p>·​Run·​the·​grammar·​through·​<span·​class="application">H​appy</​span>,​·​to·​generate4 ······​<span·​class="application">H​appy</​span>·​grammar·​file.​·​</​p></​li><li·​class="listitem"><p>·​Run·​the·​grammar·​through·​<span·​class="application">H​appy</​span>,​·​to·​generate
5 ······​a·​compilable·​Haskell·​module.​</​p></​li><li·​class="listitem"><p>·​Use·​this·​module·​as·​part·​of·​your·​Haskell·​program,​·​usually5 ······​a·​compilable·​Haskell·​module.​</​p></​li><li·​class="listitem"><p>·​Use·​this·​module·​as·​part·​of·​your·​Haskell·​program,​·​usually
6 ······​in·​conjunction·​with·​a·​lexical·​analyser·​(a·​function·​that·​splits6 ······​in·​conjunction·​with·​a·​lexical·​analyser·​(a·​function·​that·​splits
7 ······​the·​input·​into·​``tokens'',​·​the·​basic·​unit·​of·​parsing)​.​</​p></​li></​ul></​div><p>·​Let's·​run·​through·​an·​example.​··​We'll·​implement·​a·​parser·​for·​a7 ······​the·​input·​into·​``tokens'',​·​the·​basic·​unit·​of·​parsing)​.​</​p></​li></​ul></​div><p>·​Let's·​run·​through·​an·​example.​··​We'll·​implement·​a·​parser·​for·​a
8 ··​simple·​expression·​syntax,​·​consisting·​of·​integers,​·​variables,​·​the8 ··​simple·​expression·​syntax,​·​consisting·​of·​integers,​·​variables,​·​the
Offset 10, 25 lines modifiedOffset 10, 25 lines modified
10 ··​<code·​class="literal">/​</​code>,​·​and·​the·​form·​<code·​class="literal">let·​var·​=·​exp·​in·​exp</​code>.​10 ··​<code·​class="literal">/​</​code>,​·​and·​the·​form·​<code·​class="literal">let·​var·​=·​exp·​in·​exp</​code>.​
11 ··​The·​grammar·​file·​starts·​off·​like·​this:​</​p><pre·​class="programlisting​">11 ··​The·​grammar·​file·​starts·​off·​like·​this:​</​p><pre·​class="programlisting​">
12 {12 {
13 module·​Main·​where13 module·​Main·​where
14 }14 }
15 </​pre><p>At·​the·​top·​of·​the·​file·​is·​an·​optional·​<em·​class="firstterm">mod​ule15 </​pre><p>At·​the·​top·​of·​the·​file·​is·​an·​optional·​<em·​class="firstterm">mod​ule
16 ····​header</​em>,​16 ····​header</​em>,​
17 ······​<a·​class="indexterm"·​name="idp63189304"></​a>17 ······​<a·​class="indexterm"·​name="idp63254840"></​a>
18 ····​which·​is·​just·​a·​Haskell·​module·​header·​enclosed·​in·​braces.​··​This18 ····​which·​is·​just·​a·​Haskell·​module·​header·​enclosed·​in·​braces.​··​This
19 ····​code·​is·​emitted·​verbatim·​into·​the·​generated·​module,​·​so·​you·​can·​put19 ····​code·​is·​emitted·​verbatim·​into·​the·​generated·​module,​·​so·​you·​can·​put
20 ····​any·​Haskell·​code·​here·​at·​all.​··​In·​a·​grammar·​file,​·​Haskell·​code·​is20 ····​any·​Haskell·​code·​here·​at·​all.​··​In·​a·​grammar·​file,​·​Haskell·​code·​is
21 ····​always·​contained·​between·​curly·​braces·​to·​distinguish·​it·​from·​the21 ····​always·​contained·​between·​curly·​braces·​to·​distinguish·​it·​from·​the
22 ····​grammar.​</​p><p>In·​this·​case,​·​the·​parser·​will·​be·​a·​standalone·​program·​so22 ····​grammar.​</​p><p>In·​this·​case,​·​the·​parser·​will·​be·​a·​standalone·​program·​so
23 ····​we'll·​call·​the·​module·​<code·​class="literal">Main<​/​code>.​</​p><p>Next·​comes·​a·​couple·​of·​declarations:​</​p><pre·​class="programlisting​">23 ····​we'll·​call·​the·​module·​<code·​class="literal">Main<​/​code>.​</​p><p>Next·​comes·​a·​couple·​of·​declarations:​</​p><pre·​class="programlisting​">
24 %name·​calc24 %name·​calc
25 %tokentype·​{·​Token·​}25 %tokentype·​{·​Token·​}
26 %error·​{·​parseError·​}26 %error·​{·​parseError·​}
27 </​pre><a·​class="indexterm"·​name="idp63192504"></​a><a·​class="indexterm"·​name="idp63193656"></​a><a·​class="indexterm"·​name="idp63194808"></​a><p>The·​first·​line·​declares·​the·​name·​of·​the·​parsing·​function27 </​pre><a·​class="indexterm"·​name="idp63258040"></​a><a·​class="indexterm"·​name="idp63259192"></​a><a·​class="indexterm"·​name="idp63260344"></​a><p>The·​first·​line·​declares·​the·​name·​of·​the·​parsing·​function
28 ····​that·​<span·​class="application">H​appy</​span>·​will·​generate,​·​in·​this·​case28 ····​that·​<span·​class="application">H​appy</​span>·​will·​generate,​·​in·​this·​case
29 ····​<code·​class="literal">calc<​/​code>.​··​In·​many·​cases,​·​this·​is·​the·​only·​symbol·​you·​need29 ····​<code·​class="literal">calc<​/​code>.​··​In·​many·​cases,​·​this·​is·​the·​only·​symbol·​you·​need
30 ····​to·​export·​from·​the·​module.​</​p><p>The·​second·​line·​declares·​the·​type·​of·​tokens·​that·​the·​parser30 ····​to·​export·​from·​the·​module.​</​p><p>The·​second·​line·​declares·​the·​type·​of·​tokens·​that·​the·​parser
31 ····​will·​accept.​··​The·​parser·​(i.​e.​·​the·​function31 ····​will·​accept.​··​The·​parser·​(i.​e.​·​the·​function
32 ····​<code·​class="function">calc​</​code>)​·​will·​be·​of·​type·​<code·​class="literal">[Toke​n]·​-​&gt;​32 ····​<code·​class="function">calc​</​code>)​·​will·​be·​of·​type·​<code·​class="literal">[Toke​n]·​-​&gt;​
33 ····​T</​code>,​·​where·​<code·​class="literal">T</​code>·​is·​the·​return·​type·​of·​the33 ····​T</​code>,​·​where·​<code·​class="literal">T</​code>·​is·​the·​return·​type·​of·​the
34 ····​parser,​·​determined·​by·​the·​production·​rules·​below.​</​p><p>The·​<code·​class="literal">%erro​r</​code>·​directive·​tells·​Happy·​the·​name34 ····​parser,​·​determined·​by·​the·​production·​rules·​below.​</​p><p>The·​<code·​class="literal">%erro​r</​code>·​directive·​tells·​Happy·​the·​name
Offset 42, 24 lines modifiedOffset 42, 24 lines modified
42 ······​'='·············​{·​TokenEq·​}42 ······​'='·············​{·​TokenEq·​}
43 ······​'+'·············​{·​TokenPlus·​}43 ······​'+'·············​{·​TokenPlus·​}
44 ······​'-​'·············​{·​TokenMinus·​}44 ······​'-​'·············​{·​TokenMinus·​}
45 ······​'*'·············​{·​TokenTimes·​}45 ······​'*'·············​{·​TokenTimes·​}
46 ······​'/​'·············​{·​TokenDiv·​}46 ······​'/​'·············​{·​TokenDiv·​}
47 ······​'('·············​{·​TokenOB·​}47 ······​'('·············​{·​TokenOB·​}
48 ······​')​'·············​{·​TokenCB·​}48 ······​')​'·············​{·​TokenCB·​}
49 </​pre><a·​class="indexterm"·​name="idp63201336"></​a><p>The·​symbols·​on·​the·​left·​are·​the·​tokens·​as·​they·​will·​be49 </​pre><a·​class="indexterm"·​name="idp63266872"></​a><p>The·​symbols·​on·​the·​left·​are·​the·​tokens·​as·​they·​will·​be
50 ····​referred·​to·​in·​the·​rest·​of·​the·​grammar,​·​and·​to·​the·​right·​of·​each50 ····​referred·​to·​in·​the·​rest·​of·​the·​grammar,​·​and·​to·​the·​right·​of·​each
51 ····​token·​enclosed·​in·​braces·​is·​a·​Haskell·​pattern·​that·​matches·​the51 ····​token·​enclosed·​in·​braces·​is·​a·​Haskell·​pattern·​that·​matches·​the
52 ····​token.​··​The·​parser·​will·​expect·​to·​receive·​a·​stream·​of·​tokens,​·​each52 ····​token.​··​The·​parser·​will·​expect·​to·​receive·​a·​stream·​of·​tokens,​·​each
53 ····​of·​which·​will·​match·​one·​of·​the·​given·​patterns·​(the·​definition·​of53 ····​of·​which·​will·​match·​one·​of·​the·​given·​patterns·​(the·​definition·​of
54 ····​the·​<code·​class="literal">Token​</​code>·​datatype·​is·​given·​later)​.​</​p><p>The·​<code·​class="literal">$$</​code>·​symbol·​is·​a·​placeholder·​that54 ····​the·​<code·​class="literal">Token​</​code>·​datatype·​is·​given·​later)​.​</​p><p>The·​<code·​class="literal">$$</​code>·​symbol·​is·​a·​placeholder·​that
55 ····​represents·​the·​<span·​class="emphasis"><em>​value</​em></​span>·​of·​this·​token.​··​Normally·​the·​value55 ····​represents·​the·​<span·​class="emphasis"><em>​value</​em></​span>·​of·​this·​token.​··​Normally·​the·​value
56 ····​of·​a·​token·​is·​the·​token·​itself,​·​but·​by·​using·​the56 ····​of·​a·​token·​is·​the·​token·​itself,​·​but·​by·​using·​the
57 ····​<code·​class="literal">$$</​code>·​symbol·​you·​can·​specify·​some·​component57 ····​<code·​class="literal">$$</​code>·​symbol·​you·​can·​specify·​some·​component
58 ····​of·​the·​token·​object·​to·​be·​the·​value.​·​</​p><a·​class="indexterm"·​name="idp63205304"></​a><p>Like·​yacc,​·​we·​include·​<code·​class="literal">%%</​code>·​here,​·​for·​no·​real58 ····​of·​the·​token·​object·​to·​be·​the·​value.​·​</​p><a·​class="indexterm"·​name="idp63270840"></​a><p>Like·​yacc,​·​we·​include·​<code·​class="literal">%%</​code>·​here,​·​for·​no·​real
59 ····​reason.​</​p><pre·​class="programlisting​">59 ····​reason.​</​p><pre·​class="programlisting​">
60 %%60 %%
61 </​pre><p>Now·​we·​have·​the·​production·​rules·​for·​the·​grammar.​</​p><pre·​class="programlisting​">61 </​pre><p>Now·​we·​have·​the·​production·​rules·​for·​the·​grammar.​</​p><pre·​class="programlisting​">
62 Exp···​:​·​let·​var·​'='·​Exp·​in·​Exp··​{·​Let·​$2·​$4·​$6·​}62 Exp···​:​·​let·​var·​'='·​Exp·​in·​Exp··​{·​Let·​$2·​$4·​$6·​}
63 ······​|·​Exp1····················​{·​Exp1·​$1·​}63 ······​|·​Exp1····················​{·​Exp1·​$1·​}
  
64 Exp1··​:​·​Exp1·​'+'·​Term···········​{·​Plus·​$1·​$3·​}64 Exp1··​:​·​Exp1·​'+'·​Term···········​{·​Plus·​$1·​$3·​}
Offset 70, 15 lines modifiedOffset 70, 15 lines modified
70 ······​|·​Term·​'/​'·​Factor·········​{·​Div·​$1·​$3·​}70 ······​|·​Term·​'/​'·​Factor·········​{·​Div·​$1·​$3·​}
71 ······​|·​Factor··················​{·​Factor·​$1·​}71 ······​|·​Factor··················​{·​Factor·​$1·​}
  
72 Factor72 Factor
73 ······​:​·​int·····················​{·​Int·​$1·​}73 ······​:​·​int·····················​{·​Int·​$1·​}
74 ······​|·​var·····················​{·​Var·​$1·​}74 ······​|·​var·····················​{·​Var·​$1·​}
75 ······​|·​'('·​Exp·​')​'·············​{·​Brack·​$2·​}75 ······​|·​'('·​Exp·​')​'·············​{·​Brack·​$2·​}
76 </​pre><a·​class="indexterm"·​name="idp63212856"></​a><p>Each·​production·​consists·​of·​a·​<em·​class="firstterm">non​-​terminal</​em>76 </​pre><a·​class="indexterm"·​name="idp63278392"></​a><p>Each·​production·​consists·​of·​a·​<em·​class="firstterm">non​-​terminal</​em>
77 ····​symbol·​on·​the·​left,​·​followed·​by·​a·​colon,​·​followed·​by·​one·​or·​more77 ····​symbol·​on·​the·​left,​·​followed·​by·​a·​colon,​·​followed·​by·​one·​or·​more
78 ····​expansions·​on·​the·​right,​·​separated·​by·​<code·​class="literal">|</​code>.​··​Each·​expansion78 ····​expansions·​on·​the·​right,​·​separated·​by·​<code·​class="literal">|</​code>.​··​Each·​expansion
79 ····​has·​some·​Haskell·​code·​associated·​with·​it,​·​enclosed·​in·​braces·​as79 ····​has·​some·​Haskell·​code·​associated·​with·​it,​·​enclosed·​in·​braces·​as
80 ····​usual.​</​p><p>The·​way·​to·​think·​about·​a·​parser·​is·​with·​each·​symbol·​having·​a80 ····​usual.​</​p><p>The·​way·​to·​think·​about·​a·​parser·​is·​with·​each·​symbol·​having·​a
81 ····​`value':​·​we·​defined·​the·​values·​of·​the·​tokens·​above,​·​and·​the81 ····​`value':​·​we·​defined·​the·​values·​of·​the·​tokens·​above,​·​and·​the
82 ····​grammar·​defines·​the·​values·​of·​non-​terminal·​symbols·​in·​terms·​of82 ····​grammar·​defines·​the·​values·​of·​non-​terminal·​symbols·​in·​terms·​of
83 ····​sequences·​of·​other·​symbols·​(either·​tokens·​or·​non-​terminals)​.​··​In·​a83 ····​sequences·​of·​other·​symbols·​(either·​tokens·​or·​non-​terminals)​.​··​In·​a
Offset 169, 15 lines modifiedOffset 169, 15 lines modified
169 </​pre><p>And·​finally·​a·​top-​level·​function·​to·​take·​some·​input,​·​parse169 </​pre><p>And·​finally·​a·​top-​level·​function·​to·​take·​some·​input,​·​parse
170 ····​it,​·​and·​print·​out·​the·​result.​</​p><pre·​class="programlisting​">170 ····​it,​·​and·​print·​out·​the·​result.​</​p><pre·​class="programlisting​">
171 main·​=·​getContents·​&gt;​&gt;​=·​print·​.​·​calc·​.​·​lexer171 main·​=·​getContents·​&gt;​&gt;​=·​print·​.​·​calc·​.​·​lexer
172 }172 }
173 </​pre><p>And·​that's·​it!·​A·​whole·​lexer,​·​parser·​and·​grammar·​in·​a·​few173 </​pre><p>And·​that's·​it!·​A·​whole·​lexer,​·​parser·​and·​grammar·​in·​a·​few
174 ····​dozen·​lines.​··​Another·​good·​example·​is·​<span·​class="application">H​appy</​span>'s·​own174 ····​dozen·​lines.​··​Another·​good·​example·​is·​<span·​class="application">H​appy</​span>'s·​own
175 ····​parser.​·​Several·​features·​in·​<span·​class="application">H​appy</​span>·​were·​developed175 ····​parser.​·​Several·​features·​in·​<span·​class="application">H​appy</​span>·​were·​developed
176 ····​using·​this·​as·​an·​example.​</​p><a·​class="indexterm"·​name="idp63234488"></​a><p>To·​generate·​the·​Haskell·​module·​for·​this·​parser,​·​type·​the176 ····​using·​this·​as·​an·​example.​</​p><a·​class="indexterm"·​name="idp63300024"></​a><p>To·​generate·​the·​Haskell·​module·​for·​this·​parser,​·​type·​the
177 ····​command·​<span·​class="command"><stro​ng>happy·​example.​y</​strong></​span>·​(where177 ····​command·​<span·​class="command"><stro​ng>happy·​example.​y</​strong></​span>·​(where
178 ····​<code·​class="filename">exam​ple.​y</​code>·​is·​the·​name·​of·​the·​grammar·​file)​.​178 ····​<code·​class="filename">exam​ple.​y</​code>·​is·​the·​name·​of·​the·​grammar·​file)​.​
179 ····​The·​Haskell·​module·​will·​be·​placed·​in·​a·​file·​named179 ····​The·​Haskell·​module·​will·​be·​placed·​in·​a·​file·​named
180 ····​<code·​class="filename">exam​ple.​hs</​code>.​··​Additionally,​·​invoking·​the180 ····​<code·​class="filename">exam​ple.​hs</​code>.​··​Additionally,​·​invoking·​the
181 ····​command·​<span·​class="command"><stro​ng>happy·​example.​y·​-​i</​strong></​span>·​will·​produce·​the181 ····​command·​<span·​class="command"><stro​ng>happy·​example.​y·​-​i</​strong></​span>·​will·​produce·​the
182 ····​file·​<code·​class="filename">exam​ple.​info</​code>·​which·​contains·​detailed·​information182 ····​file·​<code·​class="filename">exam​ple.​info</​code>·​which·​contains·​detailed·​information
183 ····​about·​the·​parser,​·​including·​states·​and·​reduction·​rules·​(see·​<a·​class="xref"·​href="sec-​info-​files.​html"·​title="Chapter 7.​ Info·​Files">Chapter 7,​·​<i>Info·​Files</​i></​a>)​.​··​This·​can·​be·​invaluable·​for·​debugging183 ····​about·​the·​parser,​·​including·​states·​and·​reduction·​rules·​(see·​<a·​class="xref"·​href="sec-​info-​files.​html"·​title="Chapter 7.​ Info·​Files">Chapter 7,​·​<i>Info·​Files</​i></​a>)​.​··​This·​can·​be·​invaluable·​for·​debugging