Skip to content

Commit 856c70c

Browse files
committed
Module Parsing.String.Replace
Copied from https://github.com/jamesdbrock/purescript-parsing-replace
1 parent ed85e62 commit 856c70c

File tree

8 files changed

+796
-56
lines changed

8 files changed

+796
-56
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Breaking changes:
4646
New features:
4747

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

5052
Bugfixes:
5153

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ There are lots of other great monadic parsing tutorials on the internet.
130130
## Related Packages
131131

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

136135
## Documentation

bower.json

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
{
2-
"name": "purescript-parsing",
3-
"license": [
4-
"BSD-2-Clause"
5-
],
6-
"repository": {
7-
"type": "git",
8-
"url": "https://github.com/purescript-contrib/purescript-parsing.git"
9-
},
10-
"ignore": [
11-
"**/.*",
12-
"node_modules",
13-
"bower_components",
14-
"output"
15-
],
16-
"dependencies": {
17-
"purescript-arrays": "master",
18-
"purescript-control": "master",
19-
"purescript-either": "master",
20-
"purescript-foldable-traversable": "master",
21-
"purescript-identity": "master",
22-
"purescript-integers": "master",
23-
"purescript-lists": "master",
24-
"purescript-maybe": "master",
25-
"purescript-newtype": "master",
26-
"purescript-numbers": "master",
27-
"purescript-prelude": "master",
28-
"purescript-record": "master",
29-
"purescript-strings": "master",
30-
"purescript-tailrec": "master",
31-
"purescript-transformers": "master",
32-
"purescript-tuples": "master",
33-
"purescript-unfoldable": "master",
34-
"purescript-unicode": "main",
35-
"purescript-unsafe-coerce": "master"
36-
},
37-
"devDependencies": {
38-
"purescript-assert": "master"
39-
}
2+
"name": "purescript-parsing",
3+
"license": [
4+
"BSD-2-Clause"
5+
],
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/purescript-contrib/purescript-parsing.git"
9+
},
10+
"ignore": [
11+
"**/.*",
12+
"node_modules",
13+
"bower_components",
14+
"output"
15+
],
16+
"dependencies": {
17+
"purescript-arrays": "https://github.com/purescript/purescript-arrays.git#master",
18+
"purescript-control": "https://github.com/purescript/purescript-control.git#master",
19+
"purescript-either": "https://github.com/purescript/purescript-either.git#master",
20+
"purescript-enums": "https://github.com/purescript/purescript-enums.git#master",
21+
"purescript-foldable-traversable": "https://github.com/purescript/purescript-foldable-traversable.git#master",
22+
"purescript-functions": "https://github.com/purescript/purescript-functions.git#master",
23+
"purescript-identity": "https://github.com/purescript/purescript-identity.git#master",
24+
"purescript-integers": "https://github.com/purescript/purescript-integers.git#master",
25+
"purescript-lazy": "https://github.com/purescript/purescript-lazy.git#master",
26+
"purescript-lists": "https://github.com/purescript/purescript-lists.git#master",
27+
"purescript-maybe": "https://github.com/purescript/purescript-maybe.git#master",
28+
"purescript-newtype": "https://github.com/purescript/purescript-newtype.git#master",
29+
"purescript-nonempty": "https://github.com/purescript/purescript-nonempty.git#master",
30+
"purescript-nullable": "https://github.com/purescript-contrib/purescript-nullable.git#main",
31+
"purescript-numbers": "https://github.com/purescript/purescript-numbers.git#master",
32+
"purescript-partial": "https://github.com/purescript/purescript-partial.git#master",
33+
"purescript-prelude": "https://github.com/purescript/purescript-prelude.git#master",
34+
"purescript-st": "https://github.com/purescript/purescript-st.git#master",
35+
"purescript-strings": "https://github.com/purescript/purescript-strings.git#master",
36+
"purescript-tailrec": "https://github.com/purescript/purescript-tailrec.git#master",
37+
"purescript-transformers": "https://github.com/purescript/purescript-transformers.git#master",
38+
"purescript-tuples": "https://github.com/purescript/purescript-tuples.git#master",
39+
"purescript-unfoldable": "https://github.com/purescript/purescript-unfoldable.git#master",
40+
"purescript-unicode": "https://github.com/purescript-contrib/purescript-unicode.git#main",
41+
"purescript-unsafe-coerce": "https://github.com/purescript/purescript-unsafe-coerce.git#master"
42+
}
4043
}

spago-dev.dhall

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ in conf //
1111
{ sources = [ "src/**/*.purs", "test/**/*.purs", "bench/**/*.purs" ]
1212
, dependencies = conf.dependencies #
1313
[ "assert"
14+
, "bifunctors"
1415
, "console"
1516
, "enums"
1617
, "effect"
1718
, "psci-support"
1819
, "minibench"
20+
, "node-process"
1921
, "exceptions"
2022
, "string-parsers"
2123
, "partial"

spago.dhall

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414
, "lists"
1515
, "maybe"
1616
, "newtype"
17+
, "nonempty"
1718
, "numbers"
19+
, "nullable"
1820
, "partial"
1921
, "prelude"
22+
, "st"
2023
, "strings"
2124
, "tailrec"
2225
, "transformers"
2326
, "tuples"
2427
, "unfoldable"
2528
, "unicode"
29+
, "unsafe-coerce"
2630
]
2731
, packages = ./packages.dhall
2832
, sources = [ "src/**/*.purs" ]

src/Parsing/String.purs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ anyChar :: forall m. ParserT String m Char
9898
anyChar = satisfy (const true)
9999

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

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

0 commit comments

Comments
 (0)