swift-parsing for AdventOfCode 2022 #270
lukeredpath
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Thanks for sharing @lukeredpath, this is very cool! We hope to soon explore "parser bodies", much like reducer bodies, and that will allow you to drop the type erasure from your recursive parsers. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I see a few others are sharing their parsers - I started using swift-parsing on last year's and am continuing to do so this year. I've used it for most puzzles this year apart from a few relatively straightforward inputs.
My solutions are here if you would like to explore - my parsers are wrapped inside a
Parsers
namespace in each solution - spoilers!https://github.com/lukeredpath/AdventOfCode2022/tree/main/AOC2022/Sources/AOC2022Lib/Solutions
In today's (day 13) I even got to take advantage of parser/printers to print my sorted output back to a string so I could more easily compare it to the string output example in my tests:
https://github.com/lukeredpath/AdventOfCode2022/blob/6b20bfeeb5e19eaba672f8d61ca643525dea8336/AOC2022/Sources/AOC2022Lib/Solutions/Day_13.swift#L123-L158
https://github.com/lukeredpath/AdventOfCode2022/blob/6b20bfeeb5e19eaba672f8d61ca643525dea8336/AOC2022/Tests/AOC2022Tests/Day13Tests.swift#L144-L171]]
My biggest struggle, as mentioned in a question I posted here the other day, has been dealing with trailing new lines on the input - last year I created my inputs as constant strings in my Swift file but this year I'm reading them from disk.
Beta Was this translation helpful? Give feedback.
All reactions