/usr/local/poudriere/data/packages/e24a8cae34360705d022f17584bb6b4507b8eb89-build1/All/hs-alex-3.1.4.txz vs.
/usr/local/poudriere/data/packages/e24a8cae34360705d022f17584bb6b4507b8eb89-build2/All/hs-alex-3.1.4.txz
hs-alex-3.1.4.txz-content
+MANIFEST
Offset 1, 1 lines modifiedOffset 1, 1 lines modified
1 {"name":​"hs-​alex",​"origin":​"devel/​hs-​alex",​"version":​"3.​1.​4",​"comment":​"Tool·​for·​generating·​lexical·​analysers·​in·​Haskell",​"maintainer":​"haskell@FreeBSD.​org",​"www":​"http:​/​/​www.​haskell.​org/​alex/​",​"abi":​"FreeBSD:​11:​amd64",​"arch":​"freebsd:​11:​x86:​64",​"prefix":​"/​usr/​local",​"flatsize":​819460,​"licenselogic":​"single",​"licenses":​["BSD3CLAUSE"],​"desc":​"Alex·​is·​a·​tool·​for·​generating·​lexical·​analysers·​in·​Haskell.​··​It·​takes·​a\ndescription·​of·​tokens·​based·​on·​regular·​expressions·​and·​generates·​a\nHaskell·​module·​containing·​code·​for·​scanning·​text·​efficiently.​··​It·​is\nsimilar·​to·​the·​tool·​lex·​or·​flex·​for·​C/​C++.​\n\nWWW:​·​http:​/​/​www.​haskell.​org/​alex/​",​"deps":​{"gmp":​{"origin":​"math/​gmp",​"version":​"5.​1.​3_3"},​"ghc":​{"origin":​"lang/​ghc",​"version":​"7.​10.​2"},​"hs-​QuickCheck":​{"origin":​"devel/​hs-​QuickCheck",​"version":​"2.​8.​1"},​"gcc":​{"origin":​"lang/​gcc",​"version":​"4.​8.​5_2"}},​"categories":​["devel",​"haskell"],​"shlibs_required":​["libHSarray-​0.​5.​1.​0-​E0sTtauuKsGDLZoT7lTbg​Z-​ghc7.​10.​2.​so",​"libHSfilepath-​1.​4.​0.​0-​KsGE6pHE5eZHSN90ZVax6​A-​ghc7.​10.​2.​so",​·​✂1 {"name":​"hs-​alex",​"origin":​"devel/​hs-​alex",​"version":​"3.​1.​4",​"comment":​"Tool·​for·​generating·​lexical·​analysers·​in·​Haskell",​"maintainer":​"haskell@FreeBSD.​org",​"www":​"http:​/​/​www.​haskell.​org/​alex/​",​"abi":​"FreeBSD:​11:​amd64",​"arch":​"freebsd:​11:​x86:​64",​"prefix":​"/​usr/​local",​"flatsize":​819460,​"licenselogic":​"single",​"licenses":​["BSD3CLAUSE"],​"desc":​"Alex·​is·​a·​tool·​for·​generating·​lexical·​analysers·​in·​Haskell.​··​It·​takes·​a\ndescription·​of·​tokens·​based·​on·​regular·​expressions·​and·​generates·​a\nHaskell·​module·​containing·​code·​for·​scanning·​text·​efficiently.​··​It·​is\nsimilar·​to·​the·​tool·​lex·​or·​flex·​for·​C/​C++.​\n\nWWW:​·​http:​/​/​www.​haskell.​org/​alex/​",​"deps":​{"gmp":​{"origin":​"math/​gmp",​"version":​"5.​1.​3_3"},​"ghc":​{"origin":​"lang/​ghc",​"version":​"7.​10.​2"},​"hs-​QuickCheck":​{"origin":​"devel/​hs-​QuickCheck",​"version":​"2.​8.​1"},​"gcc":​{"origin":​"lang/​gcc",​"version":​"4.​8.​5_2"}},​"categories":​["devel",​"haskell"],​"shlibs_required":​["libHSarray-​0.​5.​1.​0-​E0sTtauuKsGDLZoT7lTbg​Z-​ghc7.​10.​2.​so",​"libHSfilepath-​1.​4.​0.​0-​KsGE6pHE5eZHSN90ZVax6​A-​ghc7.​10.​2.​so",​·​✂
/usr/local/share/doc/cabal/ghc-7.10.2/alex-3.1.4/html/alex-files.html
Offset 2, 15 lines modifiedOffset 2, 15 lines modified
2 ······​extended·​form·​of·​BNF,​·​where·​optional·​phrases·​are·​enclosed·​in2 ······​extended·​form·​of·​BNF,​·​where·​optional·​phrases·​are·​enclosed·​in
3 ······​square·​brackets·​(<code·​class="literal">[·​.​.​.​·​]</​code>)​,​·​and·​phrases·​which3 ······​square·​brackets·​(<code·​class="literal">[·​.​.​.​·​]</​code>)​,​·​and·​phrases·​which
4 ······​may·​be·​repeated·​zero·​or·​more·​times·​are·​enclosed·​in·​braces4 ······​may·​be·​repeated·​zero·​or·​more·​times·​are·​enclosed·​in·​braces
5 ······​(<code·​class="literal">{·​.​.​.​·​}</​code>)​.​··​Literal·​text·​is·​enclosed·​in5 ······​(<code·​class="literal">{·​.​.​.​·​}</​code>)​.​··​Literal·​text·​is·​enclosed·​in
6 ······​single·​quotes.​</​p><p>An·​Alex·​lexical·​specification·​is·​normally·​placed·​in·​a·​file6 ······​single·​quotes.​</​p><p>An·​Alex·​lexical·​specification·​is·​normally·​placed·​in·​a·​file
7 ········​with·​a·​<code·​class="literal">.​x</​code>·​extension.​··​Alex·​source·​files·​are7 ········​with·​a·​<code·​class="literal">.​x</​code>·​extension.​··​Alex·​source·​files·​are
8 ········​encoded·​in·​UTF-​8,​·​just·​like·​Haskell·​source8 ········​encoded·​in·​UTF-​8,​·​just·​like·​Haskell·​source
9 ········​files<sup>[<a·​name="idp63267640"·​href="#ftn.​idp63267640"·​class="footnote">2</​a>]</​sup>.​9 ········​files<sup>[<a·​name="idp63234872"·​href="#ftn.​idp63234872"·​class="footnote">2</​a>]</​sup>.​
10 ······​</​p><p>The·​overall·​layout·​of·​an·​Alex·​file·​is:​</​p><pre·​class="programlisting​">alex·​:​=·​[·​@code·​]·​[·​wrapper·​]·​{·​macrodef·​}·​@id·​':​-​'·​{·​rule·​}·​[·​@code·​]</​pre><p>The·​file·​begins·​and·​ends·​with·​optional·​code·​fragments.​10 ······​</​p><p>The·​overall·​layout·​of·​an·​Alex·​file·​is:​</​p><pre·​class="programlisting​">alex·​:​=·​[·​@code·​]·​[·​wrapper·​]·​{·​macrodef·​}·​@id·​':​-​'·​{·​rule·​}·​[·​@code·​]</​pre><p>The·​file·​begins·​and·​ends·​with·​optional·​code·​fragments.​
11 ······​These·​code·​fragments·​are·​copied·​verbatim·​into·​the·​generated11 ······​These·​code·​fragments·​are·​copied·​verbatim·​into·​the·​generated
12 ······​source·​file.​</​p><p>At·​the·​top·​of·​the·​file,​·​the·​code·​fragment·​is·​normally·​used12 ······​source·​file.​</​p><p>At·​the·​top·​of·​the·​file,​·​the·​code·​fragment·​is·​normally·​used
13 ······​to·​declare·​the·​module·​name·​and·​some·​imports,​·​and·​that·​is·​all·​it13 ······​to·​declare·​the·​module·​name·​and·​some·​imports,​·​and·​that·​is·​all·​it
14 ······​should·​do:​·​don't·​declare·​any·​functions·​or·​types·​in·​the·​top·​code14 ······​should·​do:​·​don't·​declare·​any·​functions·​or·​types·​in·​the·​top·​code
15 ······​fragment,​·​because·​Alex·​may·​need·​to·​inject·​some·​imports·​of·​its15 ······​fragment,​·​because·​Alex·​may·​need·​to·​inject·​some·​imports·​of·​its
16 ······​own·​into·​the·​generated·​lexer·​code,​·​and·​it·​does·​this·​by·​adding16 ······​own·​into·​the·​generated·​lexer·​code,​·​and·​it·​does·​this·​by·​adding
Offset 130, 9 lines modifiedOffset 130, 9 lines modified
130 »       ​··​in.​··​In·​order·​to·​actually·​use·​it·​as·​a·​state,​·​you·​must·​have130 »       ​··​in.​··​In·​order·​to·​actually·​use·​it·​as·​a·​state,​·​you·​must·​have
131 »       ​··​some·​way·​for·​the·​token·​actions·​to·​specify·​new·​start·​codes·​-​131 »       ​··​some·​way·​for·​the·​token·​actions·​to·​specify·​new·​start·​codes·​-​
132 »       ​··​<a·​class="xref"·​href="api.​html"·​title="Chapter 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer">Chapter 5,​·​<i>The·​Interface·​to·​an·​Alex-​generated·​lexer</​i></​a>·​describes·​some·​ways·​this·​can·​be·​done.​132 »       ​··​<a·​class="xref"·​href="api.​html"·​title="Chapter 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer">Chapter 5,​·​<i>The·​Interface·​to·​an·​Alex-​generated·​lexer</​i></​a>·​describes·​some·​ways·​this·​can·​be·​done.​
133 »       ​··​In·​some·​applications,​·​it·​might·​be·​necessary·​to·​keep·​a133 »       ​··​In·​some·​applications,​·​it·​might·​be·​necessary·​to·​keep·​a
134 »       ​··​<span·​class="emphasis"><em>​stack</​em></​span>·​of·​start·​codes,​·​where·​at·​the·​end134 »       ​··​<span·​class="emphasis"><em>​stack</​em></​span>·​of·​start·​codes,​·​where·​at·​the·​end
135 »       ​··​of·​a·​state·​we·​pop·​the·​stack·​and·​resume·​parsing·​in·​the135 »       ​··​of·​a·​state·​we·​pop·​the·​stack·​and·​resume·​parsing·​in·​the
136 »       ​··​previous·​state.​··​If·​you·​want·​this·​functionality,​·​you·​have·​to136 »       ​··​previous·​state.​··​If·​you·​want·​this·​functionality,​·​you·​have·​to
137 »       ​··​program·​it·​yourself.​</​p></​div></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63267640"·​href="#idp63267640"·​class="para">2</​a>]·​</​sup>Strictly·​speaking,​·​GHC·​source137 »       ​··​program·​it·​yourself.​</​p></​div></​div><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63234872"·​href="#idp63234872"·​class="para">2</​a>]·​</​sup>Strictly·​speaking,​·​GHC·​source
138 ········​files.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="syntax.​html">Prev</​a> </​td><td·​width="20%"·​align="center"><a·​accesskey="u"·​href="syntax.​html">Up</​a></​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="regexps.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">Chapter ​3.​ Alex·​Files </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> Chapter​ 4.​ Regular·​Expression</​td></​tr></​table></​div></​body></​html>138 ········​files.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="syntax.​html">Prev</​a> </​td><td·​width="20%"·​align="center"><a·​accesskey="u"·​href="syntax.​html">Up</​a></​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="regexps.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">Chapter ​3.​ Alex·​Files </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> Chapter​ 4.​ Regular·​Expression</​td></​tr></​table></​div></​body></​html>
/usr/local/share/doc/cabal/ghc-7.10.2/alex-3.1.4/html/api.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 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer</​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="Alex·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Alex·​User·​Guide"><link·​rel="prev"·​href="charsets.​html"·​title="4.​2.​ Syntax·​of·​character·​sets"><link·​rel="next"·​href="basic-​api.​html"·​title="5.​2.​ Basic·​interface"></​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 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="charsets.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="basic-​api.​html">Next</​a></​td></​tr></​table><hr></​div><div·​cl·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Chapter 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer</​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="Alex·​User·​Guide"><link·​rel="up"·​href="index.​html"·​title="Alex·​User·​Guide"><link·​rel="prev"·​href="charsets.​html"·​title="4.​2.​ Syntax·​of·​character·​sets"><link·​rel="next"·​href="basic-​api.​html"·​title="5.​2.​ Basic·​interface"></​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 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="charsets.​html">Prev</​a> </​td><th·​width="60%"·​align="center"> </​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="basic-​api.​html">Next</​a></​td></​tr></​table><hr></​div><div·​cl·​✂
2 ····​Alex·​lexer·​in·​my·​program?"</​p><p>Alex·​provides·​for·​a·​great·​deal·​of·​flexibility·​in·​how·​the2 ····​Alex·​lexer·​in·​my·​program?"</​p><p>Alex·​provides·​for·​a·​great·​deal·​of·​flexibility·​in·​how·​the
3 ····​lexer·​is·​exposed·​to·​the·​rest·​of·​the·​program.​··​For·​instance,​3 ····​lexer·​is·​exposed·​to·​the·​rest·​of·​the·​program.​··​For·​instance,​
4 ····​there's·​no·​need·​to·​parse·​a·​<code·​class="literal">Strin​g</​code>·​directly·​if4 ····​there's·​no·​need·​to·​parse·​a·​<code·​class="literal">Strin​g</​code>·​directly·​if
5 ····​you·​have·​some·​special·​character-​buffer·​operations·​that·​avoid·​the5 ····​you·​have·​some·​special·​character-​buffer·​operations·​that·​avoid·​the
6 ····​overheads·​of·​ordinary·​Haskell·​<code·​class="literal">Strin​g</​code>s.​··​You6 ····​overheads·​of·​ordinary·​Haskell·​<code·​class="literal">Strin​g</​code>s.​··​You
7 ····​might·​want·​Alex·​to·​keep·​track·​of·​the·​line·​and·​column·​number·​in·​the7 ····​might·​want·​Alex·​to·​keep·​track·​of·​the·​line·​and·​column·​number·​in·​the
8 ····​input·​text,​·​or·​you·​might·​wish·​to·​do·​it·​yourself·​(perhaps·​you·​use·​a8 ····​input·​text,​·​or·​you·​might·​wish·​to·​do·​it·​yourself·​(perhaps·​you·​use·​a
/usr/local/share/doc/cabal/ghc-7.10.2/alex-3.1.4/html/index.html
Offset 1, 4 lines modifiedOffset 1, 4 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Alex·​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="Alex·​is·​a·​tool·​for·​generating·​lexical·​analysers·​in·​Haskell,​·​given·​a·​description·​of·​the·​tokens·​to·​be·​recognised·​in·​the·​form·​of·​regular·​expressions.​·​It·​is·​similar·​to·​the·​tool·​lex·​or·​flex·​for·​C/​C++.​"><link·​rel="home"·​href="index.​html"·​title="Alex·​User·​Guide"><link·​rel="next"·​href="about.​html"·​title="Chapter 1.​ About·​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">Alex·​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="about.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="book"·​title="Alex·​User·​✂1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>Alex·​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="Alex·​is·​a·​tool·​for·​generating·​lexical·​analysers·​in·​Haskell,​·​given·​a·​description·​of·​the·​tokens·​to·​be·​recognised·​in·​the·​form·​of·​regular·​expressions.​·​It·​is·​similar·​to·​the·​tool·​lex·​or·​flex·​for·​C/​C++.​"><link·​rel="home"·​href="index.​html"·​title="Alex·​User·​Guide"><link·​rel="next"·​href="about.​html"·​title="Chapter 1.​ About·​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">Alex·​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="about.​html">Next</​a></​td></​tr></​table><hr></​div><div·​class="book"·​title="Alex·​User·​✂
2 ······​Haskell,​·​given·​a·​description·​of·​the·​tokens·​to·​be·​recognised·​in2 ······​Haskell,​·​given·​a·​description·​of·​the·​tokens·​to·​be·​recognised·​in
3 ······​the·​form·​of·​regular·​expressions.​··​It·​is·​similar·​to·​the·​tool3 ······​the·​form·​of·​regular·​expressions.​··​It·​is·​similar·​to·​the·​tool
4 ······​<span·​class="quote">&#8220;​<span·​class="quote">lex</​span>&#8221;​</​span>·​or·​<span·​class="quote">&#8220;​<span·​class="quote">flex</​span>&#8221;​</​span>·​for·​C/​C++.​</​p></​div></​div></​div><hr></​div><div·​class="toc"><p><b>Tab​le·​of·​Contents</​b></​p><dl><dt><span·​class="chapter"><a·​href="about.​html">1.​·​About·​Alex</​a></​span></​dt><dd><dl><dt><span·​class="section"><a·​href="about.​html#relnotes-​30">1.​1.​·​Release·​Notes·​for·​version·​3.​0</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​22.​html">1.​2.​·​Release·​Notes·​for·​version·​2.​2</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​210.​html">1.​3.​·​Release·​Notes·​for·​version·​2.​1.​0</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​20.​html">1.​4.​·​Release·​Notes·​for·​version·​2.​0</​a></​span></​dt><dd><dl><dt><span·​class="section"><a·​href="relnotes-​20.​html#changes-​syntax">1.​4.​1.​·​Syntax·​changes</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​20.​html#changes-​files">1.​4.​2.​·​Changes·​in·​the·​form·​of·​an·​Alex·​file</​a></​span></​dt><dt><span·​class="section"><a·​href·​✂4 ······​<span·​class="quote">&#8220;​<span·​class="quote">lex</​span>&#8221;​</​span>·​or·​<span·​class="quote">&#8220;​<span·​class="quote">flex</​span>&#8221;​</​span>·​for·​C/​C++.​</​p></​div></​div></​div><hr></​div><div·​class="toc"><p><b>Tab​le·​of·​Contents</​b></​p><dl><dt><span·​class="chapter"><a·​href="about.​html">1.​·​About·​Alex</​a></​span></​dt><dd><dl><dt><span·​class="section"><a·​href="about.​html#relnotes-​30">1.​1.​·​Release·​Notes·​for·​version·​3.​0</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​22.​html">1.​2.​·​Release·​Notes·​for·​version·​2.​2</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​210.​html">1.​3.​·​Release·​Notes·​for·​version·​2.​1.​0</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​20.​html">1.​4.​·​Release·​Notes·​for·​version·​2.​0</​a></​span></​dt><dd><dl><dt><span·​class="section"><a·​href="relnotes-​20.​html#changes-​syntax">1.​4.​1.​·​Syntax·​changes</​a></​span></​dt><dt><span·​class="section"><a·​href="relnotes-​20.​html#changes-​files">1.​4.​2.​·​Changes·​in·​the·​form·​of·​an·​Alex·​file</​a></​span></​dt><dt><span·​class="section"><a·​href·​✂
/usr/local/share/doc/cabal/ghc-7.10.2/alex-3.1.4/html/introduction.html
Offset 68, 18 lines modifiedOffset 68, 18 lines modified
68 ····​<code·​class="literal">main<​/​code>·​function·​that·​we·​can·​use·​for·​testing·​it;​68 ····​<code·​class="literal">main<​/​code>·​function·​that·​we·​can·​use·​for·​testing·​it;​
69 ····​the·​<code·​class="literal">main<​/​code>·​function·​just·​tokenises·​the·​input·​and69 ····​the·​<code·​class="literal">main<​/​code>·​function·​just·​tokenises·​the·​input·​and
70 ····​prints·​the·​results·​to·​standard·​output.​</​p><p>Alex·​has·​kindly·​provided·​the·​following·​function·​which·​we·​can70 ····​prints·​the·​results·​to·​standard·​output.​</​p><p>Alex·​has·​kindly·​provided·​the·​following·​function·​which·​we·​can
71 ····​use·​to·​invoke·​the·​scanner:​</​p><pre·​class="programlisting​">alexScanTokens·​:​:​·​String·​-​&gt;​·​[Token]</​pre><p>Alex·​arranges·​for·​the·​input·​stream·​to·​be·​tokenised,​·​each·​of71 ····​use·​to·​invoke·​the·​scanner:​</​p><pre·​class="programlisting​">alexScanTokens·​:​:​·​String·​-​&gt;​·​[Token]</​pre><p>Alex·​arranges·​for·​the·​input·​stream·​to·​be·​tokenised,​·​each·​of
72 ····​the·​action·​functions·​to·​be·​passed·​the·​appropriate72 ····​the·​action·​functions·​to·​be·​passed·​the·​appropriate
73 ····​<code·​class="literal">Strin​g</​code>,​·​and·​a·​list·​of·​<code·​class="literal">Token​</​code>s73 ····​<code·​class="literal">Strin​g</​code>,​·​and·​a·​list·​of·​<code·​class="literal">Token​</​code>s
74 ····​returned·​as·​the·​result.​··​If·​the·​input·​stream·​is·​lazy,​·​the·​output74 ····​returned·​as·​the·​result.​··​If·​the·​input·​stream·​is·​lazy,​·​the·​output
75 ····​stream·​will·​also·​be·​produced·​lazily<sup>[<a·​name="idp63253944"·​href="#ftn.​idp63253944"·​class="footnote">1</​a>]</​sup>.​</​p><p>We·​have·​demonstrated·​the·​simplest·​form·​of·​scanner·​here,​75 ····​stream·​will·​also·​be·​produced·​lazily<sup>[<a·​name="idp63221176"·​href="#ftn.​idp63221176"·​class="footnote">1</​a>]</​sup>.​</​p><p>We·​have·​demonstrated·​the·​simplest·​form·​of·​scanner·​here,​
76 ····​which·​was·​selected·​by·​the·​<code·​class="literal">%wrap​per·​"basic"</​code>·​line76 ····​which·​was·​selected·​by·​the·​<code·​class="literal">%wrap​per·​"basic"</​code>·​line
77 ····​near·​the·​top·​of·​the·​file.​··​In·​general,​·​actions·​do·​not·​have·​to·​have77 ····​near·​the·​top·​of·​the·​file.​··​In·​general,​·​actions·​do·​not·​have·​to·​have
78 ····​type·​<code·​class="literal">Strin​g-​&gt;​Token</​code>,​·​and·​there's·​no·​requirement78 ····​type·​<code·​class="literal">Strin​g-​&gt;​Token</​code>,​·​and·​there's·​no·​requirement
79 ····​for·​the·​scanner·​to·​return·​a·​list·​of·​tokens.​</​p><p>With·​this·​specification·​in·​the·​file79 ····​for·​the·​scanner·​to·​return·​a·​list·​of·​tokens.​</​p><p>With·​this·​specification·​in·​the·​file
80 ····​<code·​class="literal">Token​s.​x</​code>,​·​Alex·​can·​be·​used·​to·​generate80 ····​<code·​class="literal">Token​s.​x</​code>,​·​Alex·​can·​be·​used·​to·​generate
81 ····​<code·​class="literal">Token​s.​hs</​code>:​</​p><pre·​class="screen">$·​alex·​Tokens.​x</​pre><p>If·​the·​module·​needed·​to·​be·​placed·​in·​different·​file,​81 ····​<code·​class="literal">Token​s.​hs</​code>:​</​p><pre·​class="screen">$·​alex·​Tokens.​x</​pre><p>If·​the·​module·​needed·​to·​be·​placed·​in·​different·​file,​
82 ····​<code·​class="literal">Main.​hs</​code>·​for·​example,​·​then·​the·​output·​filename82 ····​<code·​class="literal">Main.​hs</​code>·​for·​example,​·​then·​the·​output·​filename
83 ····​can·​be·​specified·​using·​the·​<code·​class="option">-​o</​code>·​option:​</​p><pre·​class="screen">$·​alex·​Tokens.​x·​-​o·​Main.​hs</​pre><p>The·​resulting·​module·​is·​Haskell 98·​compatible.​··​It·​can·​also83 ····​can·​be·​specified·​using·​the·​<code·​class="option">-​o</​code>·​option:​</​p><pre·​class="screen">$·​alex·​Tokens.​x·​-​o·​Main.​hs</​pre><p>The·​resulting·​module·​is·​Haskell 98·​compatible.​··​It·​can·​also
84 ····​be·​readily·​used·​with·​a·​<a·​class="ulink"·​href="http:​/​/​www.​haskell.​org/​happy/​"·​target="_top">Happy</​a>·​parser.​</​p><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63253944"·​href="#idp63253944"·​class="para">1</​a>]·​</​sup>that·​is,​·​unless·​you84 ····​be·​readily·​used·​with·​a·​<a·​class="ulink"·​href="http:​/​/​www.​haskell.​org/​happy/​"·​target="_top">Happy</​a>·​parser.​</​p><div·​class="footnotes"><br​><hr·​width="100"·​align="left"><div·​class="footnote"><p><​sup>[<a·​id="ftn.​idp63221176"·​href="#idp63221176"·​class="para">1</​a>]·​</​sup>that·​is,​·​unless·​you
85 ····​have·​any·​patterns·​that·​require·​a·​long·​lookahead.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="license.​html">Prev</​a> </​td><td·​width="20%"·​align="center"> </​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="syntax.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">1.​6.​ License </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> Chapter​ 3.​ Alex·​Files</​td></​tr></​table></​div></​body></​html>85 ····​have·​any·​patterns·​that·​require·​a·​long·​lookahead.​</​p></​div></​div></​div><div·​class="navfooter"><hr​><table·​width="100%"·​summary="Navigation·​footer"><tr><td·​width="40%"·​align="left"><a·​accesskey="p"·​href="license.​html">Prev</​a> </​td><td·​width="20%"·​align="center"> </​td><td·​width="40%"·​align="right"> <a·​accesskey="n"·​href="syntax.​html">Next</​a></​td></​tr><tr><td·​width="40%"·​align="left"·​valign="top">1.​6.​ License </​td><td·​width="20%"·​align="center"><a·​accesskey="h"·​href="index.​html">Home</​a></​td><td·​width="40%"·​align="right"·​valign="top"> Chapter​ 3.​ Alex·​Files</​td></​tr></​table></​div></​body></​html>
/usr/local/share/doc/cabal/ghc-7.10.2/alex-3.1.4/html/wrappers.html
Offset 1, 11 lines modifiedOffset 1, 11 lines modified
1 <html><head><meta·​http-​equiv="Content-​Type"·​content="text/​html;​·​charset=ISO-​8859-​1"><title>5.​3.​ Wrappers</​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="Alex·​User·​Guide"><link·​rel="up"·​href="api.​html"·​title="Chapter 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer"><link·​rel="prev"·​href="basic-​api.​html"·​title="5.​2.​ Basic·​interface"><link·​rel="next"·​href="invoking.​html"·​title="Chapter 6.​ Invoking·​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">5.​3.​ Wrappers</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="basic-​api.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="invoking.​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>5.​3.​ Wrappers</​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="Alex·​User·​Guide"><link·​rel="up"·​href="api.​html"·​title="Chapter 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer"><link·​rel="prev"·​href="basic-​api.​html"·​title="5.​2.​ Basic·​interface"><link·​rel="next"·​href="invoking.​html"·​title="Chapter 6.​ Invoking·​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">5.​3.​ Wrappers</​th></​tr><tr><td·​width="20%"·​align="left"><a·​accesskey="p"·​href="basic-​api.​html">Prev</​a> </​td><th·​width="60%"·​align="center">Chapte​r 5.​ The·​Interface·​to·​an·​Alex-​generated·​lexer</​th><td·​width="20%"·​align="right"> <a·​accesskey="n"·​href="invoking.​html">Next</​a></​td></​tr></​table><hr></​div><div·​✂
2 ······​declaration·​in·​your·​file:​</​p><pre·​class="programlisting​">%wrapper·​"<em·​class="replaceable"><​code>name</​code></​em>"</​pre><p>where·​<em·​class="replaceable"><​code>name</​code></​em>·​is·​the·​name·​of·​the2 ······​declaration·​in·​your·​file:​</​p><pre·​class="programlisting​">%wrapper·​"<em·​class="replaceable"><​code>name</​code></​em>"</​pre><p>where·​<em·​class="replaceable"><​code>name</​code></​em>·​is·​the·​name·​of·​the
3 ······​wrapper,​·​eg.​·​<code·​class="literal">basic​</​code>.​··​The·​following·​sections3 ······​wrapper,​·​eg.​·​<code·​class="literal">basic​</​code>.​··​The·​following·​sections
4 ······​describe·​each·​of·​the·​wrappers·​that·​come·​with·​Alex.​</​p><div·​class="section"·​title='5.​3.​1.​ The·​"basic"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63428152"></​a>5.​3.​1.​ The·​"basic"·​wrapper</​h3></​div></​div></​div><p>The·​basic·​wrapper·​is·​a·​good·​way·​to·​obtain·​a·​function·​of4 ······​describe·​each·​of·​the·​wrappers·​that·​come·​with·​Alex.​</​p><div·​class="section"·​title='5.​3.​1.​ The·​"basic"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63395384"></​a>5.​3.​1.​ The·​"basic"·​wrapper</​h3></​div></​div></​div><p>The·​basic·​wrapper·​is·​a·​good·​way·​to·​obtain·​a·​function·​of
5 »       ​type·​<code·​class="literal">Strin​g·​-​&gt;​·​[token]</​code>·​from·​a·​lexer5 »       ​type·​<code·​class="literal">Strin​g·​-​&gt;​·​[token]</​code>·​from·​a·​lexer
6 »       ​specification,​·​with·​little·​fuss.​</​p><p>It·​provides·​definitions·​for6 »       ​specification,​·​with·​little·​fuss.​</​p><p>It·​provides·​definitions·​for
7 ········​<code·​class="literal">AlexI​nput</​code>,​·​<code·​class="literal">alexG​etByte</​code>7 ········​<code·​class="literal">AlexI​nput</​code>,​·​<code·​class="literal">alexG​etByte</​code>
8 »       ​and·​<code·​class="literal">alexI​nputPrevChar</​code>·​that·​are·​suitable·​for8 »       ​and·​<code·​class="literal">alexI​nputPrevChar</​code>·​that·​are·​suitable·​for
9 »       ​lexing·​a·​<code·​class="literal">Strin​g</​code>·​input.​··​It·​also·​provides·​a9 »       ​lexing·​a·​<code·​class="literal">Strin​g</​code>·​input.​··​It·​also·​provides·​a
10 »       ​function·​<code·​class="literal">alexS​canTokens</​code>·​which·​takes·​a10 »       ​function·​<code·​class="literal">alexS​canTokens</​code>·​which·​takes·​a
11 »       ​<code·​class="literal">Strin​g</​code>·​input·​and·​returns·​a·​list·​of·​the11 »       ​<code·​class="literal">Strin​g</​code>·​input·​and·​returns·​a·​list·​of·​the
Offset 35, 15 lines modifiedOffset 35, 15 lines modified
35 ················​AlexSkip··​inp'·​len·····​-​&gt;​·​go·​inp'35 ················​AlexSkip··​inp'·​len·····​-​&gt;​·​go·​inp'
36 ················​AlexToken·​inp'·​len·​act·​-​&gt;​·​act·​(take·​len·​str)​·​:​·​go·​inp'36 ················​AlexToken·​inp'·​len·​act·​-​&gt;​·​act·​(take·​len·​str)​·​:​·​go·​inp'
37 </​pre><p>The·​type·​signature·​for·​<code·​class="literal">alexS​canTokens</​code>37 </​pre><p>The·​type·​signature·​for·​<code·​class="literal">alexS​canTokens</​code>
38 ········​is·​commented·​out,​·​because·​the·​<code·​class="literal">token​</​code>·​type·​is38 ········​is·​commented·​out,​·​because·​the·​<code·​class="literal">token​</​code>·​type·​is
39 ········​unknown.​··​All·​of·​the·​actions·​in·​your·​lexical·​specification39 ········​unknown.​··​All·​of·​the·​actions·​in·​your·​lexical·​specification
40 ········​should·​have·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​String·​-​&gt;​·​token</​pre><p>for·​some·​type·​<code·​class="literal">token​</​code>.​</​p><p>For·​an·​example·​of·​the·​use·​of·​the·​basic·​wrapper,​·​see·​the40 ········​should·​have·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​String·​-​&gt;​·​token</​pre><p>for·​some·​type·​<code·​class="literal">token​</​code>.​</​p><p>For·​an·​example·​of·​the·​use·​of·​the·​basic·​wrapper,​·​see·​the
41 ········​file·​<code·​class="literal">examp​les/​Tokens.​x</​code>·​in·​the·​Alex41 ········​file·​<code·​class="literal">examp​les/​Tokens.​x</​code>·​in·​the·​Alex
42 »       ​distribution.​</​p></​div><div·​class="section"·​title='5.​3.​2.​ The·​"posn"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63438776"></​a>5.​3.​2.​ The·​"posn"·​wrapper</​h3></​div></​div></​div><p>The·​posn·​wrapper·​provides·​slightly·​more·​functionality42 »       ​distribution.​</​p></​div><div·​class="section"·​title='5.​3.​2.​ The·​"posn"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63406008"></​a>5.​3.​2.​ The·​"posn"·​wrapper</​h3></​div></​div></​div><p>The·​posn·​wrapper·​provides·​slightly·​more·​functionality
43 »       ​than·​the·​basic·​wrapper:​·​it·​keeps·​track·​of·​line·​and·​column43 »       ​than·​the·​basic·​wrapper:​·​it·​keeps·​track·​of·​line·​and·​column
44 »       ​numbers·​of·​tokens·​in·​the·​input·​text.​</​p><p>The·​posn·​wrapper·​provides·​the·​following,​·​in·​addition·​to44 »       ​numbers·​of·​tokens·​in·​the·​input·​text.​</​p><p>The·​posn·​wrapper·​provides·​the·​following,​·​in·​addition·​to
45 »       ​the·​straightforward·​definitions·​of45 »       ​the·​straightforward·​definitions·​of
46 »       ​<code·​class="literal">alexG​etByte</​code>·​and46 »       ​<code·​class="literal">alexG​etByte</​code>·​and
47 »       ​<code·​class="literal">alexI​nputPrevChar</​code>:​</​p><pre·​class="programlisting​">47 »       ​<code·​class="literal">alexI​nputPrevChar</​code>:​</​p><pre·​class="programlisting​">
48 data·​AlexPosn·​=·​AlexPn·​!Int··​-​-​·​absolute·​character·​offset48 data·​AlexPosn·​=·​AlexPn·​!Int··​-​-​·​absolute·​character·​offset
49 ·······················​!Int··​-​-​·​line·​number49 ·······················​!Int··​-​-​·​line·​number
Offset 61, 15 lines modifiedOffset 61, 15 lines modified
61 ················​AlexEOF·​-​&gt;​·​[]61 ················​AlexEOF·​-​&gt;​·​[]
62 ················​AlexError·​((AlexPn·​_·​line·​column)​,​_,​_,​_)​·​-​&gt;​·​error·​$·​"lexical·​error·​at·​"·​++·​(show·​line)​·​++·​"·​line,​·​"·​++·​(show·​column)​·​++·​"·​column"62 ················​AlexError·​((AlexPn·​_·​line·​column)​,​_,​_,​_)​·​-​&gt;​·​error·​$·​"lexical·​error·​at·​"·​++·​(show·​line)​·​++·​"·​line,​·​"·​++·​(show·​column)​·​++·​"·​column"
63 ················​AlexSkip··​inp'·​len·····​-​&gt;​·​go·​inp'63 ················​AlexSkip··​inp'·​len·····​-​&gt;​·​go·​inp'
64 ················​AlexToken·​inp'·​len·​act·​-​&gt;​·​act·​pos·​(take·​len·​str)​·​:​·​go·​inp'64 ················​AlexToken·​inp'·​len·​act·​-​&gt;​·​act·​pos·​(take·​len·​str)​·​:​·​go·​inp'
65 </​pre><p>The·​types·​of·​the·​token·​actions·​should·​be:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​AlexPosn·​-​&gt;​·​String·​-​&gt;​·​token</​pre><p>For·​an·​example·​using·​the·​<code·​class="literal">posn<​/​code>65 </​pre><p>The·​types·​of·​the·​token·​actions·​should·​be:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​AlexPosn·​-​&gt;​·​String·​-​&gt;​·​token</​pre><p>For·​an·​example·​using·​the·​<code·​class="literal">posn<​/​code>
66 »       ​wrapper,​·​see·​the·​file66 »       ​wrapper,​·​see·​the·​file
67 »       ​<code·​class="literal">examp​les/​Tokens_posn.​x</​code>·​in·​the·​Alex67 »       ​<code·​class="literal">examp​les/​Tokens_posn.​x</​code>·​in·​the·​Alex
68 »       ​distribution.​</​p></​div><div·​class="section"·​title='5.​3.​3.​ The·​"monad"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63444152"></​a>5.​3.​3.​ The·​"monad"·​wrapper</​h3></​div></​div></​div><p>The·​<code·​class="literal">monad​</​code>·​wrapper·​is·​the·​most68 »       ​distribution.​</​p></​div><div·​class="section"·​title='5.​3.​3.​ The·​"monad"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63411384"></​a>5.​3.​3.​ The·​"monad"·​wrapper</​h3></​div></​div></​div><p>The·​<code·​class="literal">monad​</​code>·​wrapper·​is·​the·​most
69 »       ​flexible·​of·​the·​wrappers·​provided·​with·​Alex.​··​It·​includes·​a69 »       ​flexible·​of·​the·​wrappers·​provided·​with·​Alex.​··​It·​includes·​a
70 »       ​state·​monad·​which·​keeps·​track·​of·​the·​current·​input·​and·​text70 »       ​state·​monad·​which·​keeps·​track·​of·​the·​current·​input·​and·​text
71 »       ​position,​·​and·​the·​startcode.​··​It·​is·​intended·​to·​be·​a·​template71 »       ​position,​·​and·​the·​startcode.​··​It·​is·​intended·​to·​be·​a·​template
72 »       ​for·​building·​your·​own·​monads·​-​·​feel·​free·​to·​copy·​the·​code·​and72 »       ​for·​building·​your·​own·​monads·​-​·​feel·​free·​to·​copy·​the·​code·​and
73 »       ​modify·​it·​to·​build·​a·​monad·​with·​the·​facilities·​you73 »       ​modify·​it·​to·​build·​a·​monad·​with·​the·​facilities·​you
74 »       ​need.​</​p><pre·​class="programlisting​">data·​AlexState·​=·​AlexState·​{74 »       ​need.​</​p><pre·​class="programlisting​">data·​AlexState·​=·​AlexState·​{
75 ········​alex_pos·​:​:​·​!AlexPosn,​··​-​-​·​position·​at·​current·​input·​location75 ········​alex_pos·​:​:​·​!AlexPosn,​··​-​-​·​position·​at·​current·​input·​location
Offset 101, 15 lines modifiedOffset 101, 15 lines modified
101 -​-​·​andBegin·​:​:​·​AlexAction·​result·​-​&gt;​·​Int·​-​&gt;​·​AlexAction·​result101 -​-​·​andBegin·​:​:​·​AlexAction·​result·​-​&gt;​·​Int·​-​&gt;​·​AlexAction·​result
102 (act·​`andBegin`·​code)​·​input·​len·​=·​do·​alexSetStartCode·​code;​·​act·​input·​len102 (act·​`andBegin`·​code)​·​input·​len·​=·​do·​alexSetStartCode·​code;​·​act·​input·​len
  
103 -​-​·​begin·​:​:​·​Int·​-​&gt;​·​AlexAction·​result103 -​-​·​begin·​:​:​·​Int·​-​&gt;​·​AlexAction·​result
104 begin·​code·​=·​skip·​`andBegin`·​code104 begin·​code·​=·​skip·​`andBegin`·​code
  
105 -​-​·​token·​:​:​·​(String·​-​&gt;​·​Int·​-​&gt;​·​token)​·​-​&gt;​·​AlexAction·​token105 -​-​·​token·​:​:​·​(String·​-​&gt;​·​Int·​-​&gt;​·​token)​·​-​&gt;​·​AlexAction·​token
106 token·​t·​input·​len·​=·​return·​(t·​input·​len)​</​pre></​div><div·​class="section"·​title='5.​3.​4.​ The·​"monadUserState"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63451960"></​a>5.​3.​4.​ The·​"monadUserState"·​wrapper</​h3></​div></​div></​div><p>The·​<code·​class="literal">monad​UserState</​code>·​wrapper·​is·​built·106 token·​t·​input·​len·​=·​return·​(t·​input·​len)​</​pre></​div><div·​class="section"·​title='5.​3.​4.​ The·​"monadUserState"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63423288"></​a>5.​3.​4.​ The·​"monadUserState"·​wrapper</​h3></​div></​div></​div><p>The·​<code·​class="literal">monad​UserState</​code>·​wrapper·​is·​built·
107 ····​upon·​the·​<code·​class="literal">monad​</​code>·​wrapper.​·​It·​includes·​a·​reference107 ····​upon·​the·​<code·​class="literal">monad​</​code>·​wrapper.​·​It·​includes·​a·​reference
108 ····​to·​a·​type·​which·​must·​be·​defined·​in·​the·​user's·​program,​·108 ····​to·​a·​type·​which·​must·​be·​defined·​in·​the·​user's·​program,​·
109 ····​<code·​class="literal">AlexU​serState</​code>,​·​and·​a·​call·​to·​an·​initialization109 ····​<code·​class="literal">AlexU​serState</​code>,​·​and·​a·​call·​to·​an·​initialization
110 ····​function·​which·​must·​also·​be·​defined·​in·​the·​user's·​program,​110 ····​function·​which·​must·​also·​be·​defined·​in·​the·​user's·​program,​
111 ····​<code·​class="literal">alexI​nitUserState</​code>.​·​It·​gives·​great·​flexibility111 ····​<code·​class="literal">alexI​nitUserState</​code>.​·​It·​gives·​great·​flexibility
112 ····​because·​it·​is·​now·​possible·​to·​add·​any·​needed·​information·​and·​carry112 ····​because·​it·​is·​now·​possible·​to·​add·​any·​needed·​information·​and·​carry
113 ····​it·​during·​the·​whole·​lexing·​phase.​</​p><p>The·​generated·​code·​is·​the·​same·​as·​in·​the·​<code·​class="literal">monad​</​code>·113 ····​it·​during·​the·​whole·​lexing·​phase.​</​p><p>The·​generated·​code·​is·​the·​same·​as·​in·​the·​<code·​class="literal">monad​</​code>·
Offset 162, 28 lines modifiedOffset 162, 28 lines modified
162 getLexerStringValue·​=·​do·​ust·​&lt;​-​·​alexGetUserState;​·​return·​(lexerStringValue·​ust)​162 getLexerStringValue·​=·​do·​ust·​&lt;​-​·​alexGetUserState;​·​return·​(lexerStringValue·​ust)​
  
163 setLexerStringValue·​:​:​·​String·​-​&gt;​·​Alex·​()​163 setLexerStringValue·​:​:​·​String·​-​&gt;​·​Alex·​()​
164 setLexerStringValue·​ss·​=·​do·​ust·​&lt;​-​·​alexGetUserState;​·​alexSetUserState·​ust{lexerStringValue=​ss}164 setLexerStringValue·​ss·​=·​do·​ust·​&lt;​-​·​alexGetUserState;​·​alexSetUserState·​ust{lexerStringValue=​ss}
  
165 addCharToLexerStringV​alue·​:​:​·​Char·​-​&gt;​·​Alex·​()​165 addCharToLexerStringV​alue·​:​:​·​Char·​-​&gt;​·​Alex·​()​
166 addCharToLexerStringV​alue·​c·​=·​do·​ust·​&lt;​-​·​alexGetUserState;​·​alexSetUserState·​ust{lexerStringValue=​c:​(lexerStringValue·​ust)​}166 addCharToLexerStringV​alue·​c·​=·​do·​ust·​&lt;​-​·​alexGetUserState;​·​alexSetUserState·​ust{lexerStringValue=​c:​(lexerStringValue·​ust)​}
167 </​pre></​div><div·​class="section"·​title='5.​3.​5.​ The·​"gscan"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63461688"></​a>5.​3.​5.​ The·​"gscan"·​wrapper</​h3></​div></​div></​div><p>The·​<code·​class="literal">gscan​</​code>·​wrapper·​is·​provided·​mainly167 </​pre></​div><div·​class="section"·​title='5.​3.​5.​ The·​"gscan"·​wrapper'><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63433016"></​a>5.​3.​5.​ The·​"gscan"·​wrapper</​h3></​div></​div></​div><p>The·​<code·​class="literal">gscan​</​code>·​wrapper·​is·​provided·​mainly
168 »       ​for·​historical·​reasons:​·​it·​exposes·​an·​interface·​which·​is·​very168 »       ​for·​historical·​reasons:​·​it·​exposes·​an·​interface·​which·​is·​very
169 »       ​similar·​to·​that·​provided·​by·​Alex·​version·​1.​x.​··​The·​interface169 »       ​similar·​to·​that·​provided·​by·​Alex·​version·​1.​x.​··​The·​interface
170 »       ​is·​intended·​to·​be·​very·​general,​·​allowing·​actions·​to·​modify·​the170 »       ​is·​intended·​to·​be·​very·​general,​·​allowing·​actions·​to·​modify·​the
171 »       ​startcode,​·​and·​pass·​around·​an·​arbitrary·​state·​value.​</​p><pre·​class="programlisting​">alexGScan·​:​:​·​StopAction·​state·​result·​-​&gt;​·​state·​-​&gt;​·​String·​-​&gt;​·​result171 »       ​startcode,​·​and·​pass·​around·​an·​arbitrary·​state·​value.​</​p><pre·​class="programlisting​">alexGScan·​:​:​·​StopAction·​state·​result·​-​&gt;​·​state·​-​&gt;​·​String·​-​&gt;​·​result
  
172 type·​StopAction·​state·​result·172 type·​StopAction·​state·​result·
173 ·········​=·​AlexPosn·​-​&gt;​·​Char·​-​&gt;​·​String·​-​&gt;​·​(Int,​state)​·​-​&gt;​·​result</​pre><p>The·​token·​actions·​should·​all·​have·​this·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}······​:​:​·​AlexPosn················​-​-​·​token·​position173 ·········​=·​AlexPosn·​-​&gt;​·​Char·​-​&gt;​·​String·​-​&gt;​·​(Int,​state)​·​-​&gt;​·​result</​pre><p>The·​token·​actions·​should·​all·​have·​this·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}······​:​:​·​AlexPosn················​-​-​·​token·​position
174 ·············​-​&gt;​·​Char····················​-​-​·​previous·​character174 ·············​-​&gt;​·​Char····················​-​-​·​previous·​character
175 ·············​-​&gt;​·​String··················​-​-​·​input·​string·​at·​token175 ·············​-​&gt;​·​String··················​-​-​·​input·​string·​at·​token
176 ·············​-​&gt;​·​Int·····················​-​-​·​length·​of·​token176 ·············​-​&gt;​·​Int·····················​-​-​·​length·​of·​token
177 ·············​-​&gt;​·​((Int,​state)​·​-​&gt;​·​result)​·​-​-​·​continuation177 ·············​-​&gt;​·​((Int,​state)​·​-​&gt;​·​result)​·​-​-​·​continuation
178 ·············​-​&gt;​·​(Int,​state)​·············​-​-​·​current·​(startcode,​state)​178 ·············​-​&gt;​·​(Int,​state)​·············​-​-​·​current·​(startcode,​state)​
179 ·············​-​&gt;​·​result</​pre></​div><div·​class="section"·​title="5.​3.​6.​ The·​bytestring·​wrappers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63464760"></​a>5.​3.​6.​ The·​bytestring·​wrappers</​h3></​div></​div></​div><p>The·​<code·​class="literal">basic​-​bytestring</​code>,​179 ·············​-​&gt;​·​result</​pre></​div><div·​class="section"·​title="5.​3.​6.​ The·​bytestring·​wrappers"><div·​class="titlepage"><di​v><div><h3·​class="title"><a·​name="idp63440184"></​a>5.​3.​6.​ The·​bytestring·​wrappers</​h3></​div></​div></​div><p>The·​<code·​class="literal">basic​-​bytestring</​code>,​
180 »       ​<code·​class="literal">posn-​bytestring</​code>·​and180 »       ​<code·​class="literal">posn-​bytestring</​code>·​and
181 »       ​<code·​class="literal">monad​-​bytestring</​code>·​wrappers·​are·​variations·​on·​the181 »       ​<code·​class="literal">monad​-​bytestring</​code>·​wrappers·​are·​variations·​on·​the
182 »       ​<code·​class="literal">basic​</​code>,​·​<code·​class="literal">posn<​/​code>·​and182 »       ​<code·​class="literal">basic​</​code>,​·​<code·​class="literal">posn<​/​code>·​and
183 »       ​<code·​class="literal">monad​</​code>·​wrappers·​that·​use·​lazy183 »       ​<code·​class="literal">monad​</​code>·​wrappers·​that·​use·​lazy
184 »       ​<code·​class="literal">ByteS​tring</​code>s·​as·​the·​input·​and·​token·​types·​instead·​of184 »       ​<code·​class="literal">ByteS​tring</​code>s·​as·​the·​input·​and·​token·​types·​instead·​of
185 »       ​an·​ordinary·​<code·​class="literal">Strin​g</​code>.​</​p><p>The·​point·​of·​using·​these·​wrappers·​is·​that185 »       ​an·​ordinary·​<code·​class="literal">Strin​g</​code>.​</​p><p>The·​point·​of·​using·​these·​wrappers·​is·​that
186 »       ​<code·​class="literal">ByteS​tring</​code>s·​provide·​a·​more·​memory·​efficient186 »       ​<code·​class="literal">ByteS​tring</​code>s·​provide·​a·​more·​memory·​efficient
Offset 203, 40 lines modifiedOffset 203, 40 lines modified
203 »       ​convert·​to·​a·​strict·​<code·​class="literal">ByteS​tring</​code>·​or·​perhaps·​something203 »       ​convert·​to·​a·​strict·​<code·​class="literal">ByteS​tring</​code>·​or·​perhaps·​something
204 »       ​more·​compact·​still.​·​Note·​also·​that·​by·​default·​tokens·​share·​space·​with204 »       ​more·​compact·​still.​·​Note·​also·​that·​by·​default·​tokens·​share·​space·​with
205 »       ​the·​input·​<code·​class="literal">ByteS​tring</​code>·​which·​has·​the·​advantage·​that·​it205 »       ​the·​input·​<code·​class="literal">ByteS​tring</​code>·​which·​has·​the·​advantage·​that·​it
206 »       ​does·​not·​need·​to·​make·​a·​copy·​but·​it·​also·​prevents·​the·​input·​from·​being206 »       ​does·​not·​need·​to·​make·​a·​copy·​but·​it·​also·​prevents·​the·​input·​from·​being
207 »       ​garbage·​collected.​·​It·​may·​make·​sense·​in·​some·​applications·​to·​use207 »       ​garbage·​collected.​·​It·​may·​make·​sense·​in·​some·​applications·​to·​use
208 »       ​<code·​class="literal">ByteS​tring</​code>'s·​<code·​class="literal">copy<​/​code>·​function·​to208 »       ​<code·​class="literal">ByteS​tring</​code>'s·​<code·​class="literal">copy<​/​code>·​function·​to
209 »       ​unshare·​tokens·​that·​will·​be·​kept·​for·​a·​long·​time,​·​to·​allow·​the·​original209 »       ​unshare·​tokens·​that·​will·​be·​kept·​for·​a·​long·​time,​·​to·​allow·​the·​original
210 »       ​input·​to·​be·​collected.​</​p><div·​class="section"·​title='5.​3.​6.​1.​ The·​"basic-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63478456"></​a>5.​3.​6.​1.​ The·​"basic-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">basic​-​bytestring</​code>·​wrapper·​is·​the·​same·​as210 »       ​input·​to·​be·​collected.​</​p><div·​class="section"·​title='5.​3.​6.​1.​ The·​"basic-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63453880"></​a>5.​3.​6.​1.​ The·​"basic-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">basic​-​bytestring</​code>·​wrapper·​is·​the·​same·​as
211 »       ​the·​<code·​class="literal">basic​</​code>·​wrapper·​but·​with·​lazy211 »       ​the·​<code·​class="literal">basic​</​code>·​wrapper·​but·​with·​lazy
212 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">212 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">
213 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString213 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString
  
214 type·​AlexInput·​=·​(Char,​·······​-​-​·​previous·​char214 type·​AlexInput·​=·​(Char,​·······​-​-​·​previous·​char
215 ··················​ByteString.​ByteString)​·​-​-​·​current·​input·​string215 ··················​ByteString.​ByteString)​·​-​-​·​current·​input·​string
  
216 alexGetByte·​:​:​·​AlexInput·​-​&gt;​·​Maybe·​(Char,​AlexInput)​216 alexGetByte·​:​:​·​AlexInput·​-​&gt;​·​Maybe·​(Char,​AlexInput)​
  
217 alexInputPrevChar·​:​:​·​AlexInput·​-​&gt;​·​Char217 alexInputPrevChar·​:​:​·​AlexInput·​-​&gt;​·​Char
  
218 -​-​·​alexScanTokens·​:​:​·​String·​-​&gt;​·​[token]218 -​-​·​alexScanTokens·​:​:​·​String·​-​&gt;​·​[token]
219 </​pre><p>All·​of·​the·​actions·​in·​your·​lexical·​specification219 </​pre><p>All·​of·​the·​actions·​in·​your·​lexical·​specification
220 ········​should·​have·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​ByteString.​ByteString·​-​&gt;​·​token</​pre><p>for·​some·​type·​<code·​class="literal">token​</​code>.​</​p></​div><div·​class="section"·​title='5.​3.​6.​2.​ The·​"posn-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63500344"></​a>5.​3.​6.​2.​ The·​"posn-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">posn-​bytestring</​code>·​wrapper·​is·​the·​same·​as220 ········​should·​have·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​ByteString.​ByteString·​-​&gt;​·​token</​pre><p>for·​some·​type·​<code·​class="literal">token​</​code>.​</​p></​div><div·​class="section"·​title='5.​3.​6.​2.​ The·​"posn-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63504440"></​a>5.​3.​6.​2.​ The·​"posn-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">posn-​bytestring</​code>·​wrapper·​is·​the·​same·​as
221 »       ​the·​<code·​class="literal">posn<​/​code>·​wrapper·​but·​with·​lazy221 »       ​the·​<code·​class="literal">posn<​/​code>·​wrapper·​but·​with·​lazy
222 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">222 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">
223 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString223 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString
  
224 type·​AlexInput·​=·​(AlexPosn,​···​-​-​·​current·​position,​224 type·​AlexInput·​=·​(AlexPosn,​···​-​-​·​current·​position,​
225 ··················​Char,​·······​-​-​·​previous·​char225 ··················​Char,​·······​-​-​·​previous·​char
226 ··················​ByteString.​ByteString)​·​-​-​·​current·​input·​string226 ··················​ByteString.​ByteString)​·​-​-​·​current·​input·​string
  
227 -​-​·​alexScanTokens·​:​:​·​ByteString.​ByteString·​-​&gt;​·​[token]227 -​-​·​alexScanTokens·​:​:​·​ByteString.​ByteString·​-​&gt;​·​[token]
228 </​pre><p>All·​of·​the·​actions·​in·​your·​lexical·​specification228 </​pre><p>All·​of·​the·​actions·​in·​your·​lexical·​specification
229 ········​should·​have·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​AlexPosn·​-​&gt;​·​ByteString.​ByteString·​-​&gt;​·​token</​pre><p>for·​some·​type·​<code·​class="literal">token​</​code>.​</​p></​div><div·​class="section"·​title='5.​3.​6.​3.​ The·​"monad-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63505848"></​a>5.​3.​6.​3.​ The·​"monad-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">monad​-​bytestring</​code>·​wrapper·​is·​the·​same·​as229 ········​should·​have·​type:​</​p><pre·​class="programlisting​">{·​.​.​.​·​}·​:​:​·​AlexPosn·​-​&gt;​·​ByteString.​ByteString·​-​&gt;​·​token</​pre><p>for·​some·​type·​<code·​class="literal">token​</​code>.​</​p></​div><div·​class="section"·​title='5.​3.​6.​3.​ The·​"monad-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63514040"></​a>5.​3.​6.​3.​ The·​"monad-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">monad​-​bytestring</​code>·​wrapper·​is·​the·​same·​as
230 »       ​the·​<code·​class="literal">monad​</​code>·​wrapper·​but·​with·​lazy230 »       ​the·​<code·​class="literal">monad​</​code>·​wrapper·​but·​with·​lazy
231 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">231 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">
232 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString232 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString
  
233 data·​AlexState·​=·​AlexState·​{233 data·​AlexState·​=·​AlexState·​{
234 ········​alex_pos·​:​:​·​!AlexPosn,​··​-​-​·​position·​at·​current·​input·​location234 ········​alex_pos·​:​:​·​!AlexPosn,​··​-​-​·​position·​at·​current·​input·​location
235 ········​alex_inp·​:​:​·​ByteString.​ByteString,​·​-​-​·​the·​current·​input235 ········​alex_inp·​:​:​·​ByteString.​ByteString,​·​-​-​·​the·​current·​input
Offset 249, 15 lines modifiedOffset 249, 15 lines modified
  
249 runAlex··········​:​:​·​ByteString.​ByteString·​-​&gt;​·​Alex·​a·​-​&gt;​·​Either·​String·​a249 runAlex··········​:​:​·​ByteString.​ByteString·​-​&gt;​·​Alex·​a·​-​&gt;​·​Either·​String·​a
  
250 -​-​·​token·​:​:​·​(ByteString.​ByteString·​-​&gt;​·​Int·​-​&gt;​·​token)​·​-​&gt;​·​AlexAction·​token250 -​-​·​token·​:​:​·​(ByteString.​ByteString·​-​&gt;​·​Int·​-​&gt;​·​token)​·​-​&gt;​·​AlexAction·​token
251 </​pre><p>All·​of·​the·​actions·​in·​your·​lexical·​specification251 </​pre><p>All·​of·​the·​actions·​in·​your·​lexical·​specification
252 ········​have·​the·​same·​type·​as·​in·​the·​<code·​class="literal">monad​</​code>·​wrapper.​·​It·​is252 ········​have·​the·​same·​type·​as·​in·​the·​<code·​class="literal">monad​</​code>·​wrapper.​·​It·​is
253 »       ​only·​the·​types·​of·​the·​function·​to·​run·​the·​monad·​and·​the·​type·​of·​the253 »       ​only·​the·​types·​of·​the·​function·​to·​run·​the·​monad·​and·​the·​type·​of·​the
254 »       ​<code·​class="literal">token​</​code>·​function·​that·​change.​</​p></​div><div·​class="section"·​title='5.​3.​6.​4.​ The·​"monadUserState-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63515064"></​a>5.​3.​6.​4.​ The·​"monadUserState-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">monad​UserState-​bytestring</​code>·​wrapper·​is·​the·​same·​as254 »       ​<code·​class="literal">token​</​code>·​function·​that·​change.​</​p></​div><div·​class="section"·​title='5.​3.​6.​4.​ The·​"monadUserState-​bytestring"·​wrapper'><div·​class="titlepage"><di​v><div><h4·​class="title"><a·​name="idp63519160"></​a>5.​3.​6.​4.​ The·​"monadUserState-​bytestring"·​wrapper</​h4></​div></​div></​div><p>The·​<code·​class="literal">monad​UserState-​bytestring</​code>·​wrapper·​is·​the·​same·​as
255 »       ​the·​<code·​class="literal">monad​UserState</​code>·​wrapper·​but·​with·​lazy255 »       ​the·​<code·​class="literal">monad​UserState</​code>·​wrapper·​but·​with·​lazy
256 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">256 »       ​<code·​class="literal">ByteS​tring</​code>·​instead·​of·​<code·​class="literal">Strin​g</​code>:​</​p><pre·​class="programlisting​">
257 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString257 import·​qualified·​Data.​ByteString.​Lazy·​as·​ByteString
  
258 ata·​AlexState·​=·​AlexState·​{258 ata·​AlexState·​=·​AlexState·​{
259 ········​alex_pos·​:​:​·​!AlexPosn,​··​-​-​·​position·​at·​current·​input·​location259 ········​alex_pos·​:​:​·​!AlexPosn,​··​-​-​·​position·​at·​current·​input·​location
260 ········​alex_inp·​:​:​·​ByteString.​ByteString,​·​-​-​·​the·​current·​input260 ········​alex_inp·​:​:​·​ByteString.​ByteString,​·​-​-​·​the·​current·​input