Skip to content

Commit 18a26dc

Browse files
committed
add missing files
1 parent 2b88bb9 commit 18a26dc

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed

src/Text/Parsec/String/Char.hs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module Text.Parsec.String.Char where
2+
3+
{-
4+
5+
Wrappers for the Text.Parsec.Char module with the types fixed to
6+
'Text.Parsec.String.Parser a', i.e. the stream is String, no user
7+
state, Identity monad.
8+
9+
-}
10+
11+
import qualified Text.Parsec.Char as C
12+
import Text.Parsec.String (Parser)
13+
14+
spaces :: Parser ()
15+
spaces = C.spaces
16+
17+
space :: Parser Char
18+
space = C.space
19+
20+
newline :: Parser Char
21+
newline = C.newline
22+
23+
tab :: Parser Char
24+
tab = C.tab
25+
26+
upper :: Parser Char
27+
upper = C.upper
28+
29+
lower :: Parser Char
30+
lower = C.lower
31+
32+
alphaNum :: Parser Char
33+
alphaNum = C.alphaNum
34+
35+
letter :: Parser Char
36+
letter = C.letter
37+
38+
digit :: Parser Char
39+
digit = C.digit
40+
41+
hexDigit :: Parser Char
42+
hexDigit = C.hexDigit
43+
44+
octDigit :: Parser Char
45+
octDigit = C.octDigit
46+
47+
char :: Char -> Parser Char
48+
char = C.char
49+
50+
string :: String -> Parser String
51+
string = C.string
52+
53+
anyChar :: Parser Char
54+
anyChar = C.anyChar
55+
56+
oneOf :: [Char] -> Parser Char
57+
oneOf = C.oneOf
58+
59+
noneOf :: [Char] -> Parser Char
60+
noneOf = C.noneOf
61+
62+
satisfy :: (Char -> Bool) -> Parser Char
63+
satisfy = C.satisfy
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
module Text.Parsec.String.Combinator where
3+
4+
{-
5+
6+
Wrappers for the Text.Parsec.Combinator module with the types fixed to
7+
'Text.Parsec.String.Parser a', i.e. the stream is String, no user
8+
state, Identity monad.
9+
10+
-}
11+
12+
import qualified Text.Parsec.Combinator as C
13+
import Text.Parsec.String (Parser)
14+
15+
choice :: [Parser a] -> Parser a
16+
choice = C.choice
17+
18+
19+
count :: Int -> Parser a -> Parser [a]
20+
count = C.count
21+
22+
between :: Parser open -> Parser close -> Parser a -> Parser a
23+
between = C.between
24+
25+
26+
option :: a -> Parser a -> Parser a
27+
option = C.option
28+
29+
optionMaybe :: Parser a -> Parser (Maybe a)
30+
optionMaybe = C.optionMaybe
31+
32+
optional :: Parser a -> Parser ()
33+
optional = C.optional
34+
35+
skipMany1 :: Parser a -> Parser ()
36+
skipMany1 = C.skipMany1
37+
38+
many1 :: Parser a -> Parser [a]
39+
many1 = C.many1
40+
41+
sepBy :: Parser a -> Parser sep -> Parser [a]
42+
sepBy = C.sepBy
43+
44+
sepBy1 :: Parser a -> Parser sep -> Parser [a]
45+
sepBy1 = C.sepBy1
46+
47+
endBy :: Parser a -> Parser sep -> Parser [a]
48+
endBy = C.endBy
49+
50+
endBy1 :: Parser a -> Parser sep -> Parser [a]
51+
endBy1 = C.endBy1
52+
53+
sepEndBy :: Parser a -> Parser sep -> Parser [a]
54+
sepEndBy = C.sepEndBy
55+
56+
sepEndBy1 :: Parser a -> Parser sep -> Parser [a]
57+
sepEndBy1 = C.sepEndBy1
58+
59+
chainl :: Parser a -> Parser (a -> a -> a) -> a -> Parser a
60+
chainl = C.chainl
61+
62+
chainl1 :: Parser a -> Parser (a -> a -> a) -> Parser a
63+
chainl1 = C.chainl1
64+
65+
chainr :: Parser a -> Parser (a -> a -> a) -> a -> Parser a
66+
chainr = C.chainr
67+
68+
chainr1 :: Parser a -> Parser (a -> a -> a) -> Parser a
69+
chainr1 = C.chainr1
70+
71+
eof :: Parser ()
72+
eof = C.eof
73+
74+
notFollowedBy :: Show a => Parser a -> Parser ()
75+
notFollowedBy = C.notFollowedBy
76+
77+
manyTill :: Parser a -> Parser end -> Parser [a]
78+
manyTill = C.manyTill
79+
80+
lookAhead :: Parser a -> Parser a
81+
lookAhead = C.lookAhead
82+
83+
anyToken :: Parser Char
84+
anyToken = C.anyToken

src/Text/Parsec/String/Expr.hs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
module Text.Parsec.String.Expr (buildExpressionParser
3+
,Operator(..)
4+
,OperatorTable
5+
,E.Assoc(..)
6+
)where
7+
8+
{-
9+
10+
Wrappers for the Text.Parsec.Expr module with simplified types.
11+
12+
-}
13+
14+
import Text.Parsec.String (Parser)
15+
import qualified Text.Parsec.Expr as E
16+
17+
-- not sure if this is neccessary, or a type alias would be good
18+
-- enough
19+
data Operator a = Infix (Parser (a -> a -> a)) E.Assoc
20+
| Prefix (Parser (a -> a))
21+
| Postfix (Parser (a -> a))
22+
23+
type OperatorTable a = [[Operator a]]
24+
25+
buildExpressionParser :: OperatorTable a -> Parser a -> Parser a
26+
buildExpressionParser t = E.buildExpressionParser (map (map f) t)
27+
where
28+
f (Infix p a) = E.Infix p a
29+
f (Prefix p) = E.Prefix p
30+
f (Postfix p) = E.Postfix p

src/Text/Parsec/String/Parsec.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
module Text.Parsec.String.Parsec where
3+
4+
{-
5+
6+
wrapper for some Text.Parsec functions which use a simplified type
7+
8+
-}
9+
10+
import Text.Parsec.String (Parser)
11+
import qualified Text.Parsec as P
12+
13+
14+
try :: Parser a -> Parser a
15+
try = P.try
16+
17+
parse :: Parser a -> P.SourceName -> String -> Either P.ParseError a
18+
parse = P.parse

0 commit comments

Comments
 (0)