[hs] Solve 2020_03
This commit is contained in:
parent
7183f49a6b
commit
23636d3fc0
4 changed files with 56 additions and 6 deletions
|
|
@ -4,12 +4,11 @@ module Aoc.Parse
|
|||
, module Text.Megaparsec.Char.Lexer
|
||||
, Parser
|
||||
, manyLines
|
||||
, word
|
||||
, untilEol
|
||||
, lineChar
|
||||
) where
|
||||
|
||||
import Data.Void
|
||||
import Data.Char
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Text.Megaparsec
|
||||
|
|
@ -21,10 +20,10 @@ import Text.Megaparsec.Char.Lexer (binary, decimal, float,
|
|||
type Parser = Parsec Void T.Text
|
||||
|
||||
manyLines :: Parser a -> Parser [a]
|
||||
manyLines p = sepEndBy (try p) newline
|
||||
|
||||
word :: Parser T.Text
|
||||
word = takeWhileP Nothing (not . isSeparator)
|
||||
manyLines p = endBy (try p) newline
|
||||
|
||||
untilEol :: Parser T.Text
|
||||
untilEol = takeWhileP Nothing (/= '\n')
|
||||
|
||||
lineChar :: Parser Char
|
||||
lineChar = satisfy (/= '\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue