-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * don't backtrack * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * rank one of errors * rank errors by most processed * nested * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * from * wip * wip * wip * Update benches * wip * idiomatic * wip * wip * wip * truncate * wip * wip * wip * wip * clean up * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Some docs and update tests to use public conversion * removed testable imports * lots of docs * wip * wip * wip * many terminator failure * wip * add loop error * force MapConversion to work only on printers * bye bye exactly * wip * wip * Added reversion to original if any parsers in `Zip` variations throw an error (#107) * Added reversion to original if any parsers in `Zip` variations throw an error. * Updated ParserBuilderTests to check correct consumption of the input * wip * fix * wip * wip * wip * wip * wip * wip * fix * wip * wip * wip * wip * Bump package tools version * wip * fix * backtrack printing * wip * wip * wip * wip * wip * New VoidMap parser and updated race parser. * wip * pullback * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * docs * wip * wip * wip * wip * wip * wip * wiop * print tests for PrefixUpTo/Through * Printer prepending instead of appending (#145) * Pointing `swift-custom-dump` to the "main" branch, since `0.4.0` hasn't been released publicly yet. * Switched printing to `prepend` rather than `append` Consequentially, all parsers that compose multiple parsers work backwards through provided parsers, and the `input` is built up from the back to the front. This allows print to check that the output is correct for cases like `Rest`, `Prefix`, `Not`, and `Peek`. * Added `Many` tests, fixed terminator bug * Whitespace cleanup * Fixed typo in test name. * Updated `End` to check input when printing. Added related tests. * Switched `Literal` printing to append rather than insert They now append into a copy of themselves, then append the `input`. * Updated `PrependableCollection` to use `append` internally * Improved error output for OneOfMany * Adds backtracking to `Optionally` * Added unit test to check backtracking * Updated the `testBacktracking` case Makes it clearer under what circumstances it will fail without backtracking. * Added backtracking to Optionally Also updated documentation about backtracking in general. * Removed incorrectly merged test case. * Added `Expect` Which can be both parsed and printed. * Made the unexpected `Peek` success a passing test Added notes about why it doesn't throw an error. * wip * wip * wip * wip * wip * Update README.md Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com> * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fixes Co-authored-by: Stephen Celis <stephen@stephencelis.com> Co-authored-by: Stephen Celis <stephen.celis@gmail.com> Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com> * wip * wip * Updates Optionally to throw any internal `wrapped.print(...)` error (#167) * Pointing `swift-custom-dump` to the "main" branch, since `0.4.0` hasn't been released publicly yet. * Made Optionally fail if the wrapped parser fails Added test cases for printing, and example of failing an invalid print. * Remove `.map` overload on Always * wip * wip * Make Rest.print fail on empty output. * roundtripping doc * wip * struct conversion docs * rename .struct to .memberwise * fixes * lots of docs * docs * wip * wip * Revert "wip" This reverts commit cde658d. * Printer -> ParserPrinter * wip * wip * wip * wip * wip * wip * wip * basic errors * wip * wip * fix * Simplify `Consumed` * wip * wip * wip * decumulator * wip * wip * wip * wip * wip * wip * clean up * wip * wip * wip * wip * wip * wip * fix * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix docc warnings * wip * wip * wip * wip * wip * wip * wip * fix Co-authored-by: Stephen Celis <stephen@stephencelis.com> Co-authored-by: David Peterson <david@randombits.org> Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
- Loading branch information
1 parent
23842d3
commit edb72e8
Showing
151 changed files
with
21,704 additions
and
1,604 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
.swiftpm/xcode/xcshareddata/xcschemes/_URLRouting.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1330" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "_URLRouting" | ||
BuildableName = "_URLRouting" | ||
BlueprintName = "_URLRouting" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "_URLRoutingTests" | ||
BuildableName = "_URLRoutingTests" | ||
BlueprintName = "_URLRoutingTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "_URLRouting" | ||
BuildableName = "_URLRouting" | ||
BlueprintName = "_URLRouting" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,89 @@ | ||
import Parsing | ||
|
||
struct Color { | ||
let red, green, blue: UInt8 | ||
/* | ||
This playground builds a parser for [day 13][AoC13] of the Advent of Code 2021 challenge. | ||
[AoC13]: https://adventofcode.com/2021/day/13 | ||
*/ | ||
|
||
/// Sample input to be parsed. | ||
let input = """ | ||
6,10 | ||
0,14 | ||
9,10 | ||
0,3 | ||
10,4 | ||
4,11 | ||
6,0 | ||
6,12 | ||
4,1 | ||
0,13 | ||
10,12 | ||
3,4 | ||
3,0 | ||
8,4 | ||
1,10 | ||
2,14 | ||
8,10 | ||
9,0 | ||
fold along y=7 | ||
fold along x=5 | ||
""" | ||
|
||
// MARK: - Models | ||
|
||
struct Dot { | ||
let x, y: Int | ||
} | ||
|
||
enum Direction: String, CaseIterable { | ||
case x, y | ||
} | ||
|
||
let hexPrimary = Prefix(2) | ||
.compactMap { UInt8($0, radix: 16) } | ||
struct Fold { | ||
let direction: Direction | ||
let position: Int | ||
} | ||
|
||
let hexColor = Parse(Color.init(red:green:blue:)) { | ||
"#" | ||
hexPrimary | ||
hexPrimary | ||
hexPrimary | ||
struct Instructions { | ||
let dots: [Dot] | ||
let folds: [Fold] | ||
} | ||
|
||
do { | ||
var hex = "#000000"[...] | ||
print(hex.debugDescription, "->", try hexColor.parse(&hex), terminator: "\n ...\n\n") | ||
// MARK: - Parsers | ||
|
||
let dot = ParsePrint(.memberwise(Dot.init)) { | ||
Digits() | ||
"," | ||
Digits() | ||
} | ||
|
||
do { | ||
var hex = "#FF0000"[...] | ||
print(hex.debugDescription, "->", try hexColor.parse(&hex), terminator: "\n ...\n\n") | ||
let fold = ParsePrint(.memberwise(Fold.init)) { | ||
"fold along " | ||
Direction.parser() | ||
"=" | ||
Digits() | ||
} | ||
|
||
do { | ||
var bad = "#BADHEX"[...] | ||
try hexColor.parse(&bad) | ||
} catch { | ||
print(error) | ||
let instructions = ParsePrint(.memberwise(Instructions.init)) { | ||
Many { | ||
dot | ||
} separator: { | ||
"\n" | ||
} terminator: { | ||
"\n\n" | ||
} | ||
Many { | ||
fold | ||
} separator: { | ||
"\n" | ||
} | ||
} | ||
|
||
// MARK: Round-trip | ||
|
||
let parsed = try instructions.parse(input) | ||
let printed = try instructions.print(parsed) | ||
|
||
input == printed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<playground version='5.0' target-platform='macos' buildActiveScheme='true'> | ||
<timeline fileName='timeline.xctimeline'/> | ||
</playground> | ||
<playground version='6.0' target-platform='macos' buildActiveScheme='true'/> |
Oops, something went wrong.