trifecta 1.6 → 1.6.1
raw patch · 4 files changed
+71/−19 lines, 4 filesdep ~basenew-uploader
Dependency ranges changed: base
Files
- .travis.yml +12/−13
- src/Text/Trifecta/Combinators.hs +3/−3
- src/Text/Trifecta/Parser.hs +55/−2
- trifecta.cabal +1/−1
.travis.yml view
@@ -12,21 +12,21 @@ matrix: include:- - env: CABALVER=1.16 GHCVER=7.4.2+ - env: CABALVER=1.24 GHCVER=7.4.2 compiler: ": #GHC 7.4.2"- addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}- - env: CABALVER=1.16 GHCVER=7.6.3+ addons: {apt: {packages: [cabal-install-1.24,ghc-7.4.2,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.24 GHCVER=7.6.3 compiler: ": #GHC 7.6.3"- addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}- - env: CABALVER=1.18 GHCVER=7.8.4+ addons: {apt: {packages: [cabal-install-1.24,ghc-7.6.3,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.24 GHCVER=7.8.4 compiler: ": #GHC 7.8.4"- addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}- - env: CABALVER=1.22 GHCVER=7.10.1- compiler: ": #GHC 7.10.1"- addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}- - env: CABALVER=1.22 GHCVER=7.10.2- compiler: ": #GHC 7.10.2"- addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}+ addons: {apt: {packages: [cabal-install-1.24,ghc-7.8.4,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.24 GHCVER=7.10.3+ compiler: ": #GHC 7.10.3"+ addons: {apt: {packages: [cabal-install-1.24,ghc-7.10.3,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.24 GHCVER=8.0.2+ compiler: ": #GHC 8.0.2"+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}} before_install: - unset CC@@ -59,7 +59,6 @@ rm -rf $HOME/.cabsnap; mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin; cabal install --only-dependencies --enable-tests --enable-benchmarks;- if [ "$GHCVER" = "7.10.1" ]; then cabal install Cabal-1.22.4.0; fi; fi # snapshot package-db on cache miss
src/Text/Trifecta/Combinators.hs view
@@ -56,14 +56,14 @@ -- | Run a parser, grabbing all of the text between its start and end points slicedWith :: (a -> Strict.ByteString -> r) -> m a -> m r - -- | Retrieve a 'Rendering' of the current linem noting this position, but not+ -- | Retrieve a 'Rendering' of the current line noting this position, but not -- placing a 'Caret' there.- rend :: DeltaParsing m => m Rendering+ rend :: m Rendering rend = rendered <$> position <*> line {-# INLINE rend #-} -- | Grab the remainder of the current line- restOfLine :: DeltaParsing m => m ByteString+ restOfLine :: m ByteString restOfLine = Strict.drop . fromIntegral . columnByte <$> position <*> line {-# INLINE restOfLine #-}
src/Text/Trifecta/Parser.hs view
@@ -60,6 +60,40 @@ import Text.Trifecta.Delta as Delta import Text.Trifecta.Util.It +-- | The type of a trifecta parser+--+-- The first four arguments are behavior continuations:+--+-- * epsilon success: the parser has consumed no input and has a result+-- as well as a possible Err; the position and chunk are unchanged+-- (see `pure`)+--+-- * epsilon failure: the parser has consumed no input and is failing+-- with the given Err; the position and chunk are unchanged (see+-- `empty`)+--+-- * committed success: the parser has consumed input and is yielding+-- the result, set of expected strings that would have permitted this+-- parse to continue, new position, and residual chunk to the+-- continuation.+--+-- * committed failure: the parser has consumed input and is failing with+-- a given ErrInfo (user-facing error message)+--+-- The remaining two arguments are+--+-- * the current position+--+-- * the chunk of input currently under analysis+--+-- `Parser` is an `Alternative`; trifecta's backtracking behavior encoded as+-- `<|>` is to behave as the leftmost parser which yields a value+-- (regardless of any input being consumed) or which consumes input and+-- fails. That is, a choice of parsers will only yield an epsilon failure+-- if *all* parsers in the choice do. If that is not the desired behavior,+-- see `try`, which turns a committed parser failure into an epsilon failure+-- (at the cost of error information).+-- newtype Parser a = Parser { unparser :: forall r. (a -> Err -> It Rope r) ->@@ -105,15 +139,34 @@ return a = Parser $ \ eo _ _ _ _ _ -> eo a mempty {-# INLINE return #-} Parser m >>= k = Parser $ \ eo ee co ce d bs ->- m (\a e -> unparser (k a) (\b e' -> eo b (e <> e')) (\e' -> ee (e <> e')) co ce d bs) ee+ m -- epsilon result: feed result to monadic continutaion; committed+ -- continuations as they were given to us; epsilon callbacks merge+ -- error information with `<>`+ (\a e -> unparser (k a) (\b e' -> eo b (e <> e')) (\e' -> ee (e <> e')) co ce d bs)+ -- epsilon error: as given+ ee+ -- committed result: feed result to monadic continuation and... (\a es d' bs' -> unparser (k a)+ -- epsilon results are now committed results due to m consuming.+ --+ -- epsilon success is now committed success at the new position+ -- (after m), yielding the result from (k a) and merging the+ -- expected sets (i.e. things that could have resulted in a longer+ -- parse) (\b e' -> co b (es <> _expected e') d' bs')+ -- epsilon failure is now a committed failure at the new position+ -- (after m); compute the error to display to the user (\e -> let errDoc = explain (renderingCaret d' bs') e { _expected = _expected e <> es } errDelta = _finalDeltas e in ce $ ErrInfo errDoc (d' : errDelta) )- co ce d' bs') ce d bs+ -- committed behaviors as given; nothing exciting here+ co ce+ -- new position and remaining chunk after m+ d' bs')+ -- committed error, delta, and bytestring: as given+ ce d bs {-# INLINE (>>=) #-} (>>) = (*>) {-# INLINE (>>) #-}
trifecta.cabal view
@@ -1,6 +1,6 @@ name: trifecta category: Text, Parsing, Diagnostics, Pretty Printer, Logging-version: 1.6+version: 1.6.1 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE