flatparse-0.3.1.0: bench/FPBasic.hs
module FPBasic (
runSexp
, runLongws
, runNumcsv) where
import FlatParse.Basic
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
longw = $(string "thisisalongkeyword")
longws = some_ (longw >> ws) >> eof
runLongws = runParser longws
numeral = some_ (satisfyASCII_ isDigit) >> ws
comma = $(char ',') >> ws
numcsv = numeral >> many_ (comma >> numeral) >> eof
runNumcsv = runParser numcsv