-
Notifications
You must be signed in to change notification settings - Fork 10
/
FPStateful.hs
30 lines (25 loc) · 822 Bytes
/
FPStateful.hs
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
{-
module FPStateful (
runSexp
, runLongws
, runNumcsv) where
import FlatParse.Stateful
ws, open, close, ident, sexp, src :: Parser () () ()
ws = many_ $(switch [| case _ of " " -> pure (); "\n" -> pure () |])
open = $(char '(') >> ws
close = $(char ')') >> ws
ident = some_ (satisfyASCII_ isLatinLetter) >> ws
sexp = branch open (some_ sexp >> close) ident
src = sexp >> eof
runSexp = runParser src () 0
longw, longws :: Parser () () ()
longw = $(string "thisisalongkeyword")
longws = some_ (longw >> ws) >> eof
runLongws = runParser longws () 0
numeral, comma, numcsv :: Parser () () ()
numeral = some_ (satisfyASCII_ isDigit) >> ws
comma = $(char ',') >> ws
numcsv = numeral >> many_ (comma >> numeral) >> eof
runNumcsv = runParser numcsv () 0
-}
module FPStateful where