/
String.purs
89 lines (59 loc) · 2.48 KB
/
String.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module Bookhound.Parsers.String where
import Bookhound.FatPrelude
import Bookhound.Parser (Parser)
import Bookhound.Parsers.Char (alpha, alphaNum, char, closeAngle, closeCurly, closeParens, closeSquare, digit, doubleQuote, letter, lower, newLine, openAngle, openCurly, openParens, openSquare, quote, space, spaceOrTab, tab, upper, whiteSpace)
import Bookhound.ParserCombinators (inverse, maybeWithin, maybeWithinBoth, within, withinBoth, (->>-), (|+), (|?), (||*), (||+))
string :: Parser String
string = (||*) char
word :: Parser String
word = (||+) (inverse whiteSpace)
digits :: Parser String
digits = (||+) digit
uppers :: Parser String
uppers = (||+) upper
lowers :: Parser String
lowers = (||+) lower
letters :: Parser String
letters = (||+) letter
alphas :: Parser String
alphas = (||+) alpha
alphaNums :: Parser String
alphaNums = (||+) alphaNum
spaces :: Parser String
spaces = (||+) space
tabs :: Parser String
tabs = (||+) tab
newLines :: Parser String
newLines = (||+) newLine
spacesOrTabs :: Parser String
spacesOrTabs = (||+) spaceOrTab
spacing :: Parser String
spacing = (||+) whiteSpace
blankLine :: Parser String
blankLine = (|?) spacesOrTabs ->>- newLine
blankLines :: Parser String
blankLines = fold <$> (|+) blankLine
withinQuotes :: forall b. Parser b -> Parser b
withinQuotes = within quote
withinDoubleQuotes :: forall b. Parser b -> Parser b
withinDoubleQuotes = within doubleQuote
withinParens :: forall b. Parser b -> Parser b
withinParens = withinBoth openParens closeParens
withinSquareBrackets :: forall b. Parser b -> Parser b
withinSquareBrackets = withinBoth openSquare closeSquare
withinCurlyBrackets :: forall b. Parser b -> Parser b
withinCurlyBrackets = withinBoth openCurly closeCurly
withinAngleBrackets :: forall b. Parser b -> Parser b
withinAngleBrackets = withinBoth openAngle closeAngle
maybeWithinQuotes :: forall b. Parser b -> Parser b
maybeWithinQuotes = maybeWithin quote
maybeWithinDoubleQuotes :: forall b. Parser b -> Parser b
maybeWithinDoubleQuotes = maybeWithin doubleQuote
maybeWithinParens :: forall b. Parser b -> Parser b
maybeWithinParens = maybeWithinBoth openParens closeParens
maybeWithinSquareBrackets :: forall b. Parser b -> Parser b
maybeWithinSquareBrackets = maybeWithinBoth openSquare closeSquare
maybeWithinCurlyBrackets :: forall b. Parser b -> Parser b
maybeWithinCurlyBrackets = maybeWithinBoth openCurly closeCurly
maybeWithinAngleBrackets :: forall b. Parser b -> Parser b
maybeWithinAngleBrackets = maybeWithinBoth openAngle closeAngle