Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ Icon
.VolumeIcon.icns
.com.apple.timemachine.donotpresent


# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


# Coveralls

/shc
/shc-*
65 changes: 22 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,58 +36,38 @@ matrix:
# We grab the appropriate GHC and cabal-install versions from hvr's PPA. See:
# https://github.com/hvr/multi-ghc-travis

# - env: BUILD=cabal GHCVER=7.6.3 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.6.3"
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
- env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 7.8.4"
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
- env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 7.10.3"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
- env: BUILD=cabal GHCVER=8.0.1 CABALVER=1.24 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 8.0.1"
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}

# Build with the newest GHC and cabal-install. This is an accepted failure,
# see below.
# - env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC HEAD"
# addons: {apt: {packages: [cabal-install-head,ghc-head,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}

# The Stack builds. We can pass in arbitrary Stack arguments via the ARGS
# For the Stack builds we can pass in arbitrary Stack arguments via the ARGS
# variable, such as using --stack-yaml to point to a different file.

# - env: BUILD=stack ARGS=""
# compiler: ": #stack default"
# addons: {apt: {packages: [libgmp-dev]}}

- env: BUILD=stack GHCVER=7.8.4 STACK_YAML=stack-7.8.yaml
compiler: ": #stack 7.8.4"
addons: {apt: {packages: [libgmp-dev]}}
# Linux/stack

- env: BUILD=stack GHCVER=7.10.3 STACK_YAML=stack-7.10.yaml
compiler: ": #stack 7.10.3"
addons: {apt: {packages: [libgmp-dev]}}

- env: BUILD=stack GHCVER=7.8.4 STACK_YAML=stack-7.8.yaml
compiler: ": #stack 7.8.4"
addons: {apt: {packages: [libgmp-dev]}}

- env: BUILD=stack GHCVER=8.0.1 STACK_YAML=stack-8.0.yaml
compiler: ": #stack 8.0.1"
addons: {apt: {packages: [libgmp-dev]}}

# Nightly builds are allowed to fail
# - env: BUILD=stack ARGS="--resolver nightly"
# compiler: ": #stack nightly"
# addons: {apt: {packages: [libgmp-dev]}}
# Linux/cabal

- env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 7.10.3"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
- env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 7.8.4"
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
- env: BUILD=cabal GHCVER=8.0.1 CABALVER=1.24 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 8.0.1"
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}

# Build on macOS in addition to Linux
# - env: BUILD=stack ARGS=""
# compiler: ": #stack default osx"
# os: osx

# Travis includes an macOS which is incompatible with GHC 7.8.4
#- env: BUILD=stack ARGS="--resolver lts-2"
# compiler: ": #stack 7.8.4 osx"
# os: osx
# macOS (stack)

- env: BUILD=stack STACK_YAML=stack-7.10.yaml
compiler: ": #stack 7.10.3 osx"
Expand All @@ -97,14 +77,11 @@ matrix:
compiler: ": #stack 8.0.1 osx"
os: osx

# - env: BUILD=stack ARGS="--resolver nightly"
# compiler: ": #stack nightly osx"
# os: osx

allow_failures:
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
- env: BUILD=stack ARGS="--resolver nightly"


before_install:
# Using compiler above sets CC to an invalid value, so unset it
- unset CC
Expand Down Expand Up @@ -183,6 +160,8 @@ script:
;;
esac
set +ex

after_script:
- travis_retry curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.4.0/shc-linux-x64-$GHCVER.tar.bz2 | tar -xj
- ./shc regex re-tests
- |
[ "$BUILD" == stack -a "$GHCVER" == 7.10.3 ] && ./shc --partial-coverage regex re-gen-modules-test re-include-test re-nginx-log-processor-test re-pp-test re-tests re-tutorial-test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Hackage](https://img.shields.io/hackage/v/regex.svg)](https://hackage.haskell.org/package/regex)
[![BSD3 License](http://img.shields.io/badge/license-BSD3-brightgreen.svg)](https://tldrlegal.com/license/bsd-3-clause-license-%28revised%29)
[![Un*x build](https://img.shields.io/travis/iconnect/regex.svg?label=Linux%2FmacOS)](https://hackage.haskell.org/package/regex)
[![Un*x build](https://img.shields.io/travis/iconnect/regex.svg?label=Linux%2FmacOS)](https://travis-ci.org/iconnect/regex)
[![Windows build](https://img.shields.io/appveyor/ci/engineerirngirisconnectcouk/regex.svg?label=Windows)](https://ci.appveyor.com/project/engineerirngirisconnectcouk/regex/branch/master)
[![Coverage](https://img.shields.io/coveralls/iconnect/regex.svg)](https://coveralls.io/github/iconnect/regex?branch=master)

Expand Down
45 changes: 21 additions & 24 deletions Text/RE/Internal/PreludeMacros.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Text.RE.Internal.PreludeMacros
, MacroDescriptor(..)
, RegexSource(..)
, PreludeMacro(..)
, presentPreludeMacro
, preludeMacros
, preludeMacroTable
, preludeMacroSummary
Expand Down Expand Up @@ -142,7 +143,7 @@ natural_macro rty env pm = Just $ run_tests rty parseInteger samples env pm
{ _md_source = "[0-9]+"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseInteger"
, _md_description = "a string of one or more decimal digits"
}
Expand Down Expand Up @@ -170,7 +171,7 @@ natural_hex_macro rty env pm = Just $ run_tests rty parseHex samples env pm
{ _md_source = "[0-9a-fA-F]+"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseHex"
, _md_description = "a string of one or more hexadecimal digits"
}
Expand Down Expand Up @@ -198,7 +199,7 @@ integer_macro rty env pm = Just $ run_tests rty parseInteger samples env pm
{ _md_source = "-?[0-9]+"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseInteger"
, _md_description = "a decimal integer"
}
Expand Down Expand Up @@ -226,7 +227,7 @@ decimal_macro rty env pm = Just $ run_tests rty parseDouble samples env pm
{ _md_source = "-?[0-9]+(?:\\.[0-9]+)?"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseInteger"
, _md_description = "a decimal integer"
}
Expand Down Expand Up @@ -267,7 +268,7 @@ string_macro rty@TDFA env pm =
{ _md_source = "\"(?:[^\"\\]+|\\\\[\\\"])*\""
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseString"
, _md_description = "a double-quote string, with simple \\ escapes for \\s and \"s"
}
Expand Down Expand Up @@ -298,7 +299,7 @@ string_simple_macro rty env pm =
{ _md_source = "\"[^\"[:cntrl:]]*\""
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseSimpleString"
, _md_description = "a decimal integer"
}
Expand Down Expand Up @@ -331,7 +332,7 @@ id_macro rty env pm =
{ _md_source = "_*[a-zA-Z][a-zA-Z0-9_]*"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Nothing
, _md_description = "a standard C-style alphanumeric identifier (with _s)"
}
Expand Down Expand Up @@ -369,7 +370,7 @@ id'_macro rty env pm =
{ _md_source = "_*[a-zA-Z][a-zA-Z0-9_']*"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Nothing
, _md_description = "a standard Haskell-style alphanumeric identifier (with '_'s and '''s)"
}
Expand Down Expand Up @@ -410,7 +411,7 @@ date_macro rty env pm =
{ _md_source = "[0-9]{4}-[0-9]{2}-[0-9]{2}"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseDate"
, _md_description = "a YYYY-MM-DD format date"
}
Expand Down Expand Up @@ -442,7 +443,7 @@ date_slashes_macro rty env pm =
{ _md_source = "[0-9]{4}/[0-9]{2}/[0-9]{2}"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseSlashesDate"
, _md_description = "a YYYY/MM/DD format date"
}
Expand Down Expand Up @@ -474,7 +475,7 @@ time_macro rty env pm =
{ _md_source = "[0-9]{2}:[0-9]{2}:[0-9]{2}(?:[.][0-9]+)?"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseTimeOfDay"
, _md_description = "a HH:MM:SS[.Q+]"
}
Expand Down Expand Up @@ -507,7 +508,7 @@ timezone_macro rty env pm =
{ _md_source = "(?:Z|[+-][0-9]{2}:?[0-9]{2})"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseTimeZone"
, _md_description = "an IOS-8601 TZ specification"
}
Expand Down Expand Up @@ -538,7 +539,7 @@ datetime_macro rty env pm = Just $ run_tests rty parseDateTime samples env pm
{ _md_source = "@{%date}[ T]@{%time}(?:@{%timezone}| UTC)?"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseDateTime"
, _md_description = "ISO-8601 format date and time + simple variants"
}
Expand Down Expand Up @@ -572,7 +573,7 @@ datetime_8601_macro rty env pm =
{ _md_source = "@{%date}T@{%time}@{%timezone}"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseDateTime8601"
, _md_description = "YYYY-MM-DDTHH:MM:SS[.Q*](Z|[+-]HHMM) format date and time"
}
Expand All @@ -599,7 +600,7 @@ datetime_clf_macro rty env pm =
{ _md_source = re
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseDateTimeCLF"
, _md_description = "Common Log Format date+time: %d/%b/%Y:%H:%M:%S %z"
}
Expand Down Expand Up @@ -638,7 +639,7 @@ shortmonth_macro rty env pm =
intercalate "|" $ elems shortMonthArray
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseShortMonth"
, _md_description = "three letter month name: Jan-Dec"
}
Expand Down Expand Up @@ -671,7 +672,7 @@ address_ipv4_macros rty env pm =
{ _md_source = "[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseSeverity"
, _md_description = "an a.b.c.d IPv4 address"
}
Expand Down Expand Up @@ -707,7 +708,7 @@ syslog_severity_macro rty env pm =
{ _md_source = re
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Just "parseSeverity"
, _md_description = "syslog severity keyword (debug-emerg)"
}
Expand Down Expand Up @@ -764,7 +765,7 @@ email_simple_macro rty env pm =
{ _md_source = "[a-zA-Z0-9%_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9.-]+"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Nothing
, _md_description = "an email address"
}
Expand Down Expand Up @@ -793,7 +794,7 @@ url_macro rty env pm =
{ _md_source = "([hH][tT][tT][pP][sS]?|[fF][tT][pP])://[^[:space:]/$.?#].[^[:space:]]*"
, _md_samples = map fst samples
, _md_counter_samples = counter_samples
, _md_test_results = test_stub pm
, _md_test_results = []
, _md_parser = Nothing
, _md_description = "a URL"
}
Expand Down Expand Up @@ -829,10 +830,6 @@ url_macro rty env pm =
, "http://##/"
]

test_stub :: PreludeMacro -> [TestResult]
test_stub pm =
error $ "test_stub: tests missing: " ++ presentPreludeMacro pm

run_tests :: (Eq a,Show a)
=> RegexType
-> (String->Maybe a)
Expand Down
31 changes: 18 additions & 13 deletions Text/RE/Internal/QQ.hs
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{-# LANGUAGE DeriveDataTypeable #-}

module Text.RE.Internal.QQ where

import Control.Exception
import Data.Typeable
import Language.Haskell.TH.Quote


data QQFailure =
QQFailure
{ _qqf_context :: String
, _qqf_component :: String
}
deriving (Show,Typeable)

instance Exception QQFailure where

qq0 :: String -> QuasiQuoter
qq0 nm =
qq0 ctx =
QuasiQuoter
{ quoteExp = const $ error $ oops "an expression"
, quotePat = const $ error $ oops "a pattern"
, quoteType = const $ error $ oops "a type"
, quoteDec = const $ error $ oops "a declaration"
{ quoteExp = const $ throw $ QQFailure ctx "expression"
, quotePat = const $ throw $ QQFailure ctx "pattern"
, quoteType = const $ throw $ QQFailure ctx "type"
, quoteDec = const $ throw $ QQFailure ctx "declaration"
}
where
oops sc = unwords
[ "`"
, nm
, "` QuasiQuoter has been used in"
, sc
, "context but it should be used in an expresion context."
]
8 changes: 4 additions & 4 deletions Text/RE/Options.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import Language.Haskell.TH.Syntax
\begin{code}
data Options_ r c e =
Options
{ _options_mode :: Mode
, _options_macs :: Macros r
, _options_comp :: c
, _options_exec :: e
{ _options_mode :: !Mode
, _options_macs :: !(Macros r)
, _options_comp :: !c
, _options_exec :: !e
}
deriving (Show)
\end{code}
Expand Down
Loading