X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent19%2FMain.hs;h=1a05fa56498bc328229fc03f66e95fc979bab8ae;hb=14a708ee545a9bd6d81205177ab9baabd29d1894;hp=eed9e357c5fc0726c9cdd47db7ce5b7ffca9fd0a;hpb=1945dfe5e07195d9988073ef884838e47007d068;p=advent-of-code-23.git diff --git a/advent19/Main.hs b/advent19/Main.hs index eed9e35..1a05fa5 100644 --- a/advent19/Main.hs +++ b/advent19/Main.hs @@ -217,13 +217,13 @@ partP :: Parser (Part Int) rulePartP = (,) <$> (rulesP <* endOfLine <* endOfLine) <*> partsP rulesP = M.fromList <$> ruleP `sepBy` endOfLine -ruleP = (,) <$> (nameP <* "{") <*> (ruleBodyP <* "}") +ruleP = (,) <$> nameP <* "{" <*> ruleBodyP <* "}" nameP = unpack <$> AT.takeWhile (inClass "a-z") -- many1 letter ruleBodyP = ruleElementP `sepBy` "," ruleElementP = withTestP <|> withoutTestP -withTestP = WithTest <$> (testP <* ":") <*> destinationP +withTestP = WithTest <$> testP <* ":" <*> destinationP withoutTestP = WithoutTest <$> destinationP testP = Test <$> registerP <*> comparatorP <*> decimal