Skip to content

Parsing.String.Replace #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2022
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Breaking changes:
New features:

- Add the `anyTill` primitive `String` combinator. (#186 by @jamesdbrock)
- Add the `Parsing.String.Replace` module, copied from
https://github.com/jamesdbrock/purescript-parsing-replace (#188 by @jamesdbrock)

Bugfixes:

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ There are lots of other great monadic parsing tutorials on the internet.
## Related Packages

- [__`parsing-dataview`__](https://pursuit.purescript.org/packages/purescript-parsing-dataview) primitive parsers for binary parsing of `ArrayBuffer`.
- [__`parsing-replace`__](https://pursuit.purescript.org/packages/purescript-parsing-replace) for finding text patterns, and also replacing or splitting on the found patterns.
- [__`datetime-parsing`__](https://pursuit.purescript.org/packages/purescript-datetime-parsing) for parsing dates and times.

## Documentation
Expand Down
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"purescript-maybe": "master",
"purescript-newtype": "master",
"purescript-numbers": "master",
"purescript-nullable": "main",
"purescript-prelude": "master",
"purescript-strings": "master",
"purescript-tailrec": "master",
Expand All @@ -34,6 +35,8 @@
"purescript-unsafe-coerce": "master"
},
"devDependencies": {
"purescript-assert": "master"
"purescript-assert": "master",
"purescript-effect": "master",
"purescript-node-process": "master"
}
}
3 changes: 3 additions & 0 deletions spago-dev.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ in conf //
{ sources = [ "src/**/*.purs", "test/**/*.purs", "bench/**/*.purs" ]
, dependencies = conf.dependencies #
[ "assert"
, "bifunctors"
, "console"
, "enums"
, "effect"
, "minibench"
, "node-process"
, "nonempty"
, "exceptions"
, "string-parsers"
, "partial"
Expand Down
4 changes: 4 additions & 0 deletions spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, dependencies =
[ "arrays"
, "control"
, "effect"
, "either"
, "enums"
, "foldable-traversable"
Expand All @@ -15,14 +16,17 @@
, "maybe"
, "newtype"
, "numbers"
, "nullable"
, "partial"
, "prelude"
, "st"
, "strings"
, "tailrec"
, "transformers"
, "tuples"
, "unfoldable"
, "unicode"
, "unsafe-coerce"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs" ]
Expand Down
12 changes: 11 additions & 1 deletion src/Parsing/String.purs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ anyChar :: forall m. ParserT String m Char
anyChar = satisfy (const true)

-- | Match any Unicode character.
-- | Always succeeds.
-- | Always succeeds when any input remains.
anyCodePoint :: forall m. ParserT String m CodePoint
anyCodePoint = satisfyCodePoint (const true)

Expand Down Expand Up @@ -290,9 +290,19 @@ consumeWith f = ParserT
-- | Will fail if no section of the input is parseable. To backtrack the input
-- | stream on failure, combine with `tryRethrow`.
-- |
-- | This combinator works like
-- | [Data.String.takeWhile](https://pursuit.purescript.org/packages/purescript-strings/docs/Data.String#v:takeWhile)
-- | or
-- | [Data.String.Regex.search](https://pursuit.purescript.org/packages/purescript-strings/docs/Data.String.Regex#v:search)
-- | and it allows using a parser for the pattern search.
-- |
-- | This combinator is equivalent to `manyTill_ anyCodePoint`, but it will be
-- | faster because it returns a slice of the input `String` for the
-- | section preceding the parse instead of a `List CodePoint`.
-- |
-- | Be careful not to look too far
-- | ahead; if the phrase parser looks to the end of the input then `anyTill`
-- | could be *O(n²)*.
anyTill
:: forall m a
. Monad m
Expand Down
Loading