Skip to content

Commit

Permalink
Sort out the cabal file
Browse files Browse the repository at this point in the history
The cabal file is now generated from a template in
'lib/regex-master.cabal' using a new sed-based tool in
'examples/re-gen-cabals.lhs'. The template abstracts
away a great deal of repetition caused by

  * the need to repeat each of the example expecuatbles
    with almost identical test targest;

  * the need to repeat constraints on the dependent
    packages in each of these targets.
  • Loading branch information
cdornan committed Feb 5, 2017
1 parent 05511df commit 751198d
Show file tree
Hide file tree
Showing 34 changed files with 1,026 additions and 261 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.ghci
.hub
.ghci
tmp
stack.yaml
tmp


Expand Down
55 changes: 54 additions & 1 deletion Text/RE/Internal/PreludeMacros.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ preludeMacroDescriptor rty env pm = case pm of
PM_string_simple -> string_simple_macro rty env pm
PM_id -> id_macro rty env pm
PM_id' -> id'_macro rty env pm
PM_id_ -> id__macro rty env pm
PM_date -> date_macro rty env pm
PM_date_slashes -> date_slashes_macro rty env pm
PM_time -> time_macro rty env pm
Expand All @@ -111,6 +112,7 @@ data PreludeMacro
-- identifiers
| PM_id
| PM_id'
| PM_id_
-- dates & times
| PM_date
| PM_date_slashes
Expand All @@ -130,8 +132,12 @@ data PreludeMacro

-- | naming the macros
presentPreludeMacro :: PreludeMacro -> String
presentPreludeMacro = (prelude_prefix++) . map tr . drop 3 . show
presentPreludeMacro pm = case pm of
PM_id_ -> prelude_prefix++"id-"
_ -> fmt pm
where
fmt = (prelude_prefix++) . map tr . drop 3 . show

tr '_' = '.'
tr c = c

Expand Down Expand Up @@ -409,6 +415,53 @@ id'_macro rty env pm =
, "_1'"
]

id__macro :: RegexType
-> MacroEnv
-> PreludeMacro
-> Maybe MacroDescriptor
id__macro rty env pm =
Just $ run_tests rty Just samples env pm
MacroDescriptor
{ _md_source = "_*[a-zA-Z][a-zA-Z0-9_'-]*"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = []
, _md_parser = Nothing
, _md_description = "an identifier with -s"
}
where
samples :: [(String,String)]
samples =
[ f "a"
, f "A"
, f "A1"
, f "a_"
, f "a1_B2"
, f "_abc"
, f "__abc"
, f "a'"
, f "_a'"
, f "a'b"
, f "a-"
, f "a1-B2"
, f "a1-B2-"
]
where
f s = (s,s)

counter_samples =
[ ""
, "1"
, "_"
, "__"
, "__1"
, "1a"
, "'"
, "'a"
, "_'"
, "_1'"
]

date_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
date_macro rty env pm =
Just $ run_tests rty parseDate samples env pm
Expand Down
2 changes: 1 addition & 1 deletion docs/Capture.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Capture.lhs'>RE/Capture</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Capture.lhs'>RE/Capture</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE RecordWildCards #-}</span>
<span class="ot">{-# LANGUAGE FlexibleInstances #-}</span>
<span class="ot">{-# LANGUAGE UndecidableInstances #-}</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/Edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Edit.lhs'>RE/Edit</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Edit.lhs'>RE/Edit</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE NoImplicitPrelude #-}</span>
<span class="ot">{-# LANGUAGE RecordWildCards #-}</span>
<span class="ot">{-# LANGUAGE CPP #-}</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/Grep.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Tools/Grep.lhs'>RE/Tools/Grep</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Tools/Grep.lhs'>RE/Tools/Grep</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE NoImplicitPrelude #-}</span>
<span class="ot">{-# LANGUAGE RecordWildCards #-}</span>
<span class="ot">{-# LANGUAGE FlexibleContexts #-}</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/IsRegex.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/IsRegex.lhs'>RE/IsRegex</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/IsRegex.lhs'>RE/IsRegex</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE MultiParamTypeClasses #-}</span>
<span class="ot">{-# LANGUAGE AllowAmbiguousTypes #-}</span>

Expand Down
2 changes: 1 addition & 1 deletion docs/Lex.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Tools/Lex.lhs'>RE/Tools/Lex</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Tools/Lex.lhs'>RE/Tools/Lex</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE NoImplicitPrelude #-}</span>

<span class="kw">module</span> <span class="dt">Text.RE.Tools.Lex</span> <span class="kw">where</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/NamedCaptures.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Internal/NamedCaptures.lhs'>RE/Internal/NamedCaptures</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Internal/NamedCaptures.lhs'>RE/Internal/NamedCaptures</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE QuasiQuotes #-}</span>
<span class="ot">{-# LANGUAGE TemplateHaskell #-}</span>
<span class="ot">{-# LANGUAGE FlexibleInstances #-}</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/Options.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Options.lhs'>RE/Options</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Options.lhs'>RE/Options</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE GeneralizedNewtypeDeriving #-}</span>
<span class="ot">{-# LANGUAGE TemplateHaskell #-}</span>
<span class="ot">{-# LANGUAGE QuasiQuotes #-}</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/Replace.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Replace.lhs'>RE/Replace</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Replace.lhs'>RE/Replace</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE NoImplicitPrelude #-}</span>
<span class="ot">{-# LANGUAGE QuasiQuotes #-}</span>
<span class="ot">{-# LANGUAGE OverloadedStrings #-}</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/Sed.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/Tools/Sed.lhs'>RE/Tools/Sed</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/Tools/Sed.lhs'>RE/Tools/Sed</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE NoImplicitPrelude #-}</span>
<span class="ot">{-# LANGUAGE RecordWildCards #-}</span>
<span class="ot">{-# LANGUAGE FlexibleContexts #-}</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/TestBench.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<link rel="stylesheet" href="lib/bs.css" type="text/css" />
</head>
<body>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/src/Text/RE/TestBench.lhs'>RE/TestBench</a></ol><div class='content'>
<ol class='breadcrumb'><li><a href='.' title='Home'>Home</a></li> &gt; <a title='source file' href='https://github.com/iconnect/regex/blob/master/Text/RE/TestBench.lhs'>RE/TestBench</a></ol><div class='content'>
<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">{-# LANGUAGE NoImplicitPrelude #-}</span>
<span class="ot">{-# LANGUAGE RecordWildCards #-}</span>
<span class="ot">{-# LANGUAGE GeneralizedNewtypeDeriving #-}</span>
Expand Down
1 change: 1 addition & 0 deletions docs/TestKit.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
, runTests
, checkThis
, test_pp
, cmp
) <span class="kw">where</span>

<span class="kw">import </span><span class="dt">Control.Exception</span>
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ provides an extended example of large-scale RE development with the regex test b
is the starting point for the preprocessor that we use to generate the tutorial
HTML and its derived test suite.

### The Cabal Processor Example [examples/re-gen-cabals.lhs](re-gen-cabals.html)
is the Sed preprocessor we use to generate our cabal file from the template
in [lib/regex-master.cabal](https://github.com/iconnect/regex/blob/master/lib/regex-master.cabal).

### The Library Tests [examples/re-tests.lhs](re-tests.html)
contains various test suites for exercising various components of the library.

Expand Down

0 comments on commit 751198d

Please sign in to comment.