mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Merge pull request #33 from github/sourcekitten
[WIP] Extract Swift document structure using SourceKitten.
This commit is contained in:
commit
a90e508a8e
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "prototype/External/SourceKitten"]
|
||||
path = prototype/External/SourceKitten
|
||||
url = https://github.com/jpsim/SourceKitten.git
|
@ -7,16 +7,24 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
D40024EE1BAC819000A110B8 /* SwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D40024ED1BAC819000A110B8 /* SwiftTests.swift */; };
|
||||
D432D4711BA9AC0B00F3FABC /* DiffTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D432D4701BA9AC0B00F3FABC /* DiffTests.swift */; };
|
||||
D432D4731BA9C55300F3FABC /* Stream.swift in Sources */ = {isa = PBXBuildFile; fileRef = D432D4721BA9C55300F3FABC /* Stream.swift */; };
|
||||
D432D4751BA9D6A400F3FABC /* Memo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D432D4741BA9D6A400F3FABC /* Memo.swift */; };
|
||||
D432D4771BA9FE6A00F3FABC /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D432D4761BA9FE6A00F3FABC /* Comparable.swift */; };
|
||||
D4413FDD1BB0559400E3C3C1 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FDA1BB0536700E3C3C1 /* Result.framework */; };
|
||||
D4413FDE1BB0559400E3C3C1 /* SwiftXPC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD61BB0531E00E3C3C1 /* SwiftXPC.framework */; };
|
||||
D4413FE51BB055A600E3C3C1 /* SourceKittenFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD41BB052ED00E3C3C1 /* SourceKittenFramework.framework */; };
|
||||
D4413FE61BB055A800E3C3C1 /* SWXMLHash.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD81BB0534000E3C3C1 /* SWXMLHash.framework */; };
|
||||
D4413FE91BB055B500E3C3C1 /* Commandant.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FE71BB055AE00E3C3C1 /* Commandant.framework */; };
|
||||
D4413FEF1BB06D4C00E3C3C1 /* Dictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4413FEE1BB06D4C00E3C3C1 /* Dictionary.swift */; };
|
||||
D4413FF11BB08FDC00E3C3C1 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4413FF01BB08FDC00E3C3C1 /* JSON.swift */; };
|
||||
D4A71DC51BB45B850051416D /* Vertex.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A71DC41BB45B850051416D /* Vertex.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D4A71DC71BB4AC9E0051416D /* VertexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A71DC61BB4AC9E0051416D /* VertexTests.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D4AAE50E1B5AE22E004E581F /* Doubt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4AAE4FD1B5AE22E004E581F /* Doubt.framework */; };
|
||||
D4AAE5131B5AE22E004E581F /* DoubtTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE5121B5AE22E004E581F /* DoubtTests.swift */; };
|
||||
D4AAE5401B5AE2D0004E581F /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE5351B5AE2D0004E581F /* Array.swift */; };
|
||||
D4AAE5411B5AE2D0004E581F /* Diff.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE5361B5AE2D0004E581F /* Diff.swift */; };
|
||||
D4AAE5421B5AE2D0004E581F /* Doc.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE5371B5AE2D0004E581F /* Doc.swift */; };
|
||||
D4AAE5441B5AE2D0004E581F /* Lambda.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE5391B5AE2D0004E581F /* Lambda.swift */; };
|
||||
D4AAE5451B5AE2D0004E581F /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE53A1B5AE2D0004E581F /* Operators.swift */; };
|
||||
D4AAE5461B5AE2D0004E581F /* Parse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE53B1B5AE2D0004E581F /* Parse.swift */; };
|
||||
D4AAE5471B5AE2D0004E581F /* Prelude.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE53C1B5AE2D0004E581F /* Prelude.swift */; };
|
||||
@ -24,6 +32,20 @@
|
||||
D4AAE5491B5AE2D0004E581F /* StringLiteralConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE53E1B5AE2D0004E581F /* StringLiteralConvertible.swift */; };
|
||||
D4AAE54A1B5AE2D0004E581F /* Syntax.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE53F1B5AE2D0004E581F /* Syntax.swift */; };
|
||||
D4AAE54C1B5AE42D004E581F /* Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AAE54B1B5AE42D004E581F /* Equatable.swift */; };
|
||||
D4C2B12E1BB33CEC0096F92A /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = D435B7471BB31949000902F6 /* main.swift */; };
|
||||
D4C2B12F1BB33D050096F92A /* Doubt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4AAE4FD1B5AE22E004E581F /* Doubt.framework */; };
|
||||
D4C2B1301BB33D080096F92A /* Commandant.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FE71BB055AE00E3C3C1 /* Commandant.framework */; };
|
||||
D4C2B1311BB33D080096F92A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FDA1BB0536700E3C3C1 /* Result.framework */; };
|
||||
D4C2B1321BB33D080096F92A /* SWXMLHash.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD81BB0534000E3C3C1 /* SWXMLHash.framework */; };
|
||||
D4C2B1331BB33D080096F92A /* SwiftXPC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD61BB0531E00E3C3C1 /* SwiftXPC.framework */; };
|
||||
D4C2B1341BB33D080096F92A /* SourceKittenFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD41BB052ED00E3C3C1 /* SourceKittenFramework.framework */; };
|
||||
D4C2B1351BB33D1D0096F92A /* BoundsCheckedArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = D435B7521BB31BBC000902F6 /* BoundsCheckedArray.swift */; };
|
||||
D4C2B13F1BB3474C0096F92A /* Commandant.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FE71BB055AE00E3C3C1 /* Commandant.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D4C2B1401BB3474C0096F92A /* Result.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FDA1BB0536700E3C3C1 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D4C2B1411BB3474C0096F92A /* SWXMLHash.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD81BB0534000E3C3C1 /* SWXMLHash.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D4C2B1421BB3474C0096F92A /* SwiftXPC.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD61BB0531E00E3C3C1 /* SwiftXPC.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D4C2B1431BB3474C0096F92A /* SourceKittenFramework.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D4413FD41BB052ED00E3C3C1 /* SourceKittenFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D4C2B1441BB347500096F92A /* Doubt.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D4AAE4FD1B5AE22E004E581F /* Doubt.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -36,20 +58,50 @@
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
D4C2B1381BB346C80096F92A /* Copy Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
D4C2B1441BB347500096F92A /* Doubt.framework in Copy Frameworks */,
|
||||
D4C2B13F1BB3474C0096F92A /* Commandant.framework in Copy Frameworks */,
|
||||
D4C2B1401BB3474C0096F92A /* Result.framework in Copy Frameworks */,
|
||||
D4C2B1411BB3474C0096F92A /* SWXMLHash.framework in Copy Frameworks */,
|
||||
D4C2B1421BB3474C0096F92A /* SwiftXPC.framework in Copy Frameworks */,
|
||||
D4C2B1431BB3474C0096F92A /* SourceKittenFramework.framework in Copy Frameworks */,
|
||||
);
|
||||
name = "Copy Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
D40024ED1BAC819000A110B8 /* SwiftTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftTests.swift; sourceTree = "<group>"; };
|
||||
D432D4701BA9AC0B00F3FABC /* DiffTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiffTests.swift; sourceTree = "<group>"; };
|
||||
D432D4721BA9C55300F3FABC /* Stream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stream.swift; sourceTree = "<group>"; };
|
||||
D432D4741BA9D6A400F3FABC /* Memo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Memo.swift; sourceTree = "<group>"; };
|
||||
D432D4761BA9FE6A00F3FABC /* Comparable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Comparable.swift; sourceTree = "<group>"; };
|
||||
D435B7471BB31949000902F6 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
||||
D435B7521BB31BBC000902F6 /* BoundsCheckedArray.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoundsCheckedArray.swift; sourceTree = "<group>"; };
|
||||
D435B7581BB32117000902F6 /* doubt-swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "doubt-swift.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4413FD41BB052ED00E3C3C1 /* SourceKittenFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SourceKittenFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4413FD61BB0531E00E3C3C1 /* SwiftXPC.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SwiftXPC.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4413FD81BB0534000E3C3C1 /* SWXMLHash.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SWXMLHash.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4413FDA1BB0536700E3C3C1 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Result.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4413FE71BB055AE00E3C3C1 /* Commandant.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Commandant.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4413FEE1BB06D4C00E3C3C1 /* Dictionary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dictionary.swift; sourceTree = "<group>"; };
|
||||
D4413FF01BB08FDC00E3C3C1 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
|
||||
D4A71DC41BB45B850051416D /* Vertex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vertex.swift; sourceTree = "<group>"; };
|
||||
D4A71DC61BB4AC9E0051416D /* VertexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VertexTests.swift; sourceTree = "<group>"; };
|
||||
D4AAE4FD1B5AE22E004E581F /* Doubt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Doubt.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4AAE5011B5AE22E004E581F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D4AAE50D1B5AE22E004E581F /* DoubtTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DoubtTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4AAE5121B5AE22E004E581F /* DoubtTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoubtTests.swift; sourceTree = "<group>"; };
|
||||
D4AAE5141B5AE22E004E581F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D4AAE5351B5AE2D0004E581F /* Array.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
|
||||
D4AAE5361B5AE2D0004E581F /* Diff.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Diff.swift; sourceTree = "<group>"; };
|
||||
D4AAE5371B5AE2D0004E581F /* Doc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Doc.swift; sourceTree = "<group>"; };
|
||||
D4AAE5391B5AE2D0004E581F /* Lambda.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Lambda.swift; sourceTree = "<group>"; };
|
||||
D4AAE53A1B5AE2D0004E581F /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = "<group>"; };
|
||||
D4AAE53B1B5AE2D0004E581F /* Parse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Parse.swift; sourceTree = "<group>"; };
|
||||
D4AAE53C1B5AE2D0004E581F /* Prelude.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Prelude.swift; sourceTree = "<group>"; };
|
||||
@ -60,6 +112,19 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
D435B7551BB32117000902F6 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D4C2B12F1BB33D050096F92A /* Doubt.framework in Frameworks */,
|
||||
D4C2B1301BB33D080096F92A /* Commandant.framework in Frameworks */,
|
||||
D4C2B1311BB33D080096F92A /* Result.framework in Frameworks */,
|
||||
D4C2B1321BB33D080096F92A /* SWXMLHash.framework in Frameworks */,
|
||||
D4C2B1331BB33D080096F92A /* SwiftXPC.framework in Frameworks */,
|
||||
D4C2B1341BB33D080096F92A /* SourceKittenFramework.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
D4AAE4F91B5AE22E004E581F /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -71,18 +136,33 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D4413FE91BB055B500E3C3C1 /* Commandant.framework in Frameworks */,
|
||||
D4413FDD1BB0559400E3C3C1 /* Result.framework in Frameworks */,
|
||||
D4413FDE1BB0559400E3C3C1 /* SwiftXPC.framework in Frameworks */,
|
||||
D4AAE50E1B5AE22E004E581F /* Doubt.framework in Frameworks */,
|
||||
D4413FE61BB055A800E3C3C1 /* SWXMLHash.framework in Frameworks */,
|
||||
D4413FE51BB055A600E3C3C1 /* SourceKittenFramework.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
D435B7461BB31949000902F6 /* doubt-swift */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D435B7471BB31949000902F6 /* main.swift */,
|
||||
D435B7521BB31BBC000902F6 /* BoundsCheckedArray.swift */,
|
||||
);
|
||||
path = "doubt-swift";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D4AAE4F31B5AE22E004E581F = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D4AAE4FF1B5AE22E004E581F /* Doubt */,
|
||||
D4AAE5111B5AE22E004E581F /* DoubtTests */,
|
||||
D435B7461BB31949000902F6 /* doubt-swift */,
|
||||
D4AAE4FE1B5AE22E004E581F /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
@ -92,6 +172,7 @@
|
||||
children = (
|
||||
D4AAE4FD1B5AE22E004E581F /* Doubt.framework */,
|
||||
D4AAE50D1B5AE22E004E581F /* DoubtTests.xctest */,
|
||||
D435B7581BB32117000902F6 /* doubt-swift.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -102,7 +183,6 @@
|
||||
D4AAE5351B5AE2D0004E581F /* Array.swift */,
|
||||
D4AAE5361B5AE2D0004E581F /* Diff.swift */,
|
||||
D4AAE5371B5AE2D0004E581F /* Doc.swift */,
|
||||
D4AAE5391B5AE2D0004E581F /* Lambda.swift */,
|
||||
D4AAE53A1B5AE2D0004E581F /* Operators.swift */,
|
||||
D4AAE53B1B5AE2D0004E581F /* Parse.swift */,
|
||||
D4AAE53C1B5AE2D0004E581F /* Prelude.swift */,
|
||||
@ -113,6 +193,9 @@
|
||||
D432D4761BA9FE6A00F3FABC /* Comparable.swift */,
|
||||
D432D4721BA9C55300F3FABC /* Stream.swift */,
|
||||
D432D4741BA9D6A400F3FABC /* Memo.swift */,
|
||||
D4413FEE1BB06D4C00E3C3C1 /* Dictionary.swift */,
|
||||
D4413FF01BB08FDC00E3C3C1 /* JSON.swift */,
|
||||
D4A71DC41BB45B850051416D /* Vertex.swift */,
|
||||
D4AAE5001B5AE22E004E581F /* Supporting Files */,
|
||||
);
|
||||
path = Doubt;
|
||||
@ -121,6 +204,11 @@
|
||||
D4AAE5001B5AE22E004E581F /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D4413FE71BB055AE00E3C3C1 /* Commandant.framework */,
|
||||
D4413FDA1BB0536700E3C3C1 /* Result.framework */,
|
||||
D4413FD81BB0534000E3C3C1 /* SWXMLHash.framework */,
|
||||
D4413FD61BB0531E00E3C3C1 /* SwiftXPC.framework */,
|
||||
D4413FD41BB052ED00E3C3C1 /* SourceKittenFramework.framework */,
|
||||
D4AAE5011B5AE22E004E581F /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
@ -129,8 +217,9 @@
|
||||
D4AAE5111B5AE22E004E581F /* DoubtTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D4AAE5121B5AE22E004E581F /* DoubtTests.swift */,
|
||||
D432D4701BA9AC0B00F3FABC /* DiffTests.swift */,
|
||||
D40024ED1BAC819000A110B8 /* SwiftTests.swift */,
|
||||
D4A71DC61BB4AC9E0051416D /* VertexTests.swift */,
|
||||
D4AAE5141B5AE22E004E581F /* Info.plist */,
|
||||
);
|
||||
path = DoubtTests;
|
||||
@ -149,6 +238,24 @@
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
D435B7571BB32117000902F6 /* doubt-swift */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = D435B7621BB32117000902F6 /* Build configuration list for PBXNativeTarget "doubt-swift" */;
|
||||
buildPhases = (
|
||||
D435B7541BB32117000902F6 /* Sources */,
|
||||
D435B7551BB32117000902F6 /* Frameworks */,
|
||||
D435B7561BB32117000902F6 /* Resources */,
|
||||
D4C2B1381BB346C80096F92A /* Copy Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "doubt-swift";
|
||||
productName = "doubt-swift";
|
||||
productReference = D435B7581BB32117000902F6 /* doubt-swift.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
D4AAE4FC1B5AE22E004E581F /* Doubt */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = D4AAE5171B5AE22E004E581F /* Build configuration list for PBXNativeTarget "Doubt" */;
|
||||
@ -195,6 +302,9 @@
|
||||
LastUpgradeCheck = 0710;
|
||||
ORGANIZATIONNAME = GitHub;
|
||||
TargetAttributes = {
|
||||
D435B7571BB32117000902F6 = {
|
||||
CreatedOnToolsVersion = 7.1;
|
||||
};
|
||||
D4AAE4FC1B5AE22E004E581F = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
};
|
||||
@ -209,6 +319,7 @@
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = D4AAE4F31B5AE22E004E581F;
|
||||
productRefGroup = D4AAE4FE1B5AE22E004E581F /* Products */;
|
||||
@ -217,11 +328,19 @@
|
||||
targets = (
|
||||
D4AAE4FC1B5AE22E004E581F /* Doubt */,
|
||||
D4AAE50C1B5AE22E004E581F /* DoubtTests */,
|
||||
D435B7571BB32117000902F6 /* doubt-swift */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
D435B7561BB32117000902F6 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
D4AAE4FB1B5AE22E004E581F /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -239,16 +358,26 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
D435B7541BB32117000902F6 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D4C2B1351BB33D1D0096F92A /* BoundsCheckedArray.swift in Sources */,
|
||||
D4C2B12E1BB33CEC0096F92A /* main.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
D4AAE4F81B5AE22E004E581F /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D4AAE5471B5AE2D0004E581F /* Prelude.swift in Sources */,
|
||||
D4AAE5441B5AE2D0004E581F /* Lambda.swift in Sources */,
|
||||
D4413FEF1BB06D4C00E3C3C1 /* Dictionary.swift in Sources */,
|
||||
D4AAE5481B5AE2D0004E581F /* String.swift in Sources */,
|
||||
D4AAE5411B5AE2D0004E581F /* Diff.swift in Sources */,
|
||||
D4AAE5401B5AE2D0004E581F /* Array.swift in Sources */,
|
||||
D4AAE54C1B5AE42D004E581F /* Equatable.swift in Sources */,
|
||||
D4A71DC51BB45B850051416D /* Vertex.swift in Sources */,
|
||||
D4AAE54A1B5AE2D0004E581F /* Syntax.swift in Sources */,
|
||||
D432D4731BA9C55300F3FABC /* Stream.swift in Sources */,
|
||||
D4AAE5421B5AE2D0004E581F /* Doc.swift in Sources */,
|
||||
@ -256,6 +385,7 @@
|
||||
D4AAE5461B5AE2D0004E581F /* Parse.swift in Sources */,
|
||||
D432D4751BA9D6A400F3FABC /* Memo.swift in Sources */,
|
||||
D4AAE5491B5AE2D0004E581F /* StringLiteralConvertible.swift in Sources */,
|
||||
D4413FF11BB08FDC00E3C3C1 /* JSON.swift in Sources */,
|
||||
D4AAE5451B5AE2D0004E581F /* Operators.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -264,8 +394,9 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D40024EE1BAC819000A110B8 /* SwiftTests.swift in Sources */,
|
||||
D432D4711BA9AC0B00F3FABC /* DiffTests.swift in Sources */,
|
||||
D4AAE5131B5AE22E004E581F /* DoubtTests.swift in Sources */,
|
||||
D4A71DC71BB4AC9E0051416D /* VertexTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -280,6 +411,33 @@
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
D435B7631BB32117000902F6 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = "doubt-swift/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.doubt-swift";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
D435B7641BB32117000902F6 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
INFOPLIST_FILE = "doubt-swift/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.doubt-swift";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
D4AAE5151B5AE22E004E581F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@ -376,6 +534,7 @@
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = Doubt/Info.plist;
|
||||
INSTALL_PATH = "@rpath";
|
||||
@ -396,6 +555,7 @@
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = Doubt/Info.plist;
|
||||
INSTALL_PATH = "@rpath";
|
||||
@ -440,6 +600,15 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
D435B7621BB32117000902F6 /* Build configuration list for PBXNativeTarget "doubt-swift" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
D435B7631BB32117000902F6 /* Debug */,
|
||||
D435B7641BB32117000902F6 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
D4AAE4F71B5AE22E004E581F /* Build configuration list for PBXProject "Doubt" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0710"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D4AAE4FC1B5AE22E004E581F"
|
||||
BuildableName = "Doubt.framework"
|
||||
BlueprintName = "Doubt"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</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 = "D4AAE50C1B5AE22E004E581F"
|
||||
BuildableName = "DoubtTests.xctest"
|
||||
BlueprintName = "DoubtTests"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D4AAE4FC1B5AE22E004E581F"
|
||||
BuildableName = "Doubt.framework"
|
||||
BlueprintName = "Doubt"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</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">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D4AAE4FC1B5AE22E004E581F"
|
||||
BuildableName = "Doubt.framework"
|
||||
BlueprintName = "Doubt"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D4AAE4FC1B5AE22E004E581F"
|
||||
BuildableName = "Doubt.framework"
|
||||
BlueprintName = "Doubt"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0710"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D435B7571BB32117000902F6"
|
||||
BuildableName = "doubt-swift.app"
|
||||
BlueprintName = "doubt-swift"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D435B7571BB32117000902F6"
|
||||
BuildableName = "doubt-swift.app"
|
||||
BlueprintName = "doubt-swift"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</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">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D435B7571BB32117000902F6"
|
||||
BuildableName = "doubt-swift.app"
|
||||
BlueprintName = "doubt-swift"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D435B7571BB32117000902F6"
|
||||
BuildableName = "doubt-swift.app"
|
||||
BlueprintName = "doubt-swift"
|
||||
ReferencedContainer = "container:Doubt.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
15
prototype/Doubt.xcworkspace/contents.xcworkspacedata
generated
15
prototype/Doubt.xcworkspace/contents.xcworkspacedata
generated
@ -4,4 +4,19 @@
|
||||
<FileRef
|
||||
location = "group:Doubt.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:External/SourceKitten/sourcekitten.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:External/SourceKitten/Carthage/Checkouts/Commandant/Commandant.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:External/SourceKitten/Carthage/Checkouts/Result/Result.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:External/SourceKitten/Carthage/Checkouts/SwiftXPC/SwiftXPC.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:External/SourceKitten/Carthage/Checkouts/SWXMLHash/SWXMLHash.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
8
prototype/Doubt/Dictionary.swift
Normal file
8
prototype/Doubt/Dictionary.swift
Normal file
@ -0,0 +1,8 @@
|
||||
extension Dictionary {
|
||||
init<C: CollectionType where C.Generator.Element == (Key, Value)>(elements: C) {
|
||||
self.init(minimumCapacity: Int(elements.count.toIntMax()))
|
||||
for (key, value) in elements {
|
||||
self[key] = value
|
||||
}
|
||||
}
|
||||
}
|
@ -64,11 +64,10 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible
|
||||
case let (.Roll(a), .Roll(b)):
|
||||
switch (a, b) {
|
||||
case let (.Apply(a, aa), .Apply(b, bb)):
|
||||
// fixme: SES
|
||||
self = .Copy(.Apply(Diff(a, b), Diff.diff(aa, bb)))
|
||||
|
||||
case let (.Abstract(p1, b1), .Abstract(p2, b2)):
|
||||
self = .Copy(.Abstract(Diff.diff(p1, p2), Diff(b1, b2)))
|
||||
self = .Copy(.Abstract(Diff.diff(p1, p2), Diff.diff(b1, b2)))
|
||||
|
||||
case let (.Assign(n1, v1), .Assign(n2, v2)) where n1 == n2:
|
||||
self = .Copy(.Assign(n2, Diff(v1, v2)))
|
||||
@ -92,8 +91,9 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible
|
||||
}
|
||||
|
||||
public static func diff<C1: CollectionType, C2: CollectionType where C1.Index : RandomAccessIndexType, C1.Generator.Element == Term, C2.Index : RandomAccessIndexType, C2.Generator.Element == Term>(a: C1, _ b: C2) -> [Diff] {
|
||||
func magnitude(diffs: Stream<Diff>) -> Int {
|
||||
return diffs.map { $0.magnitude }.reduce(0, combine: +)
|
||||
func magnitude(diffs: Stream<(Diff, Int)>) -> Int {
|
||||
// return diffs.first?.magnitude ?? 0
|
||||
return diffs.map { $1 }.reduce(0, combine: +)
|
||||
}
|
||||
|
||||
func min<A>(a: A, _ rest: A..., _ isLessThan: (A, A) -> Bool) -> A {
|
||||
@ -102,24 +102,25 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible
|
||||
})
|
||||
}
|
||||
|
||||
func diff(a: Stream<Term>, _ b: Stream<Term>) -> Stream<Diff> {
|
||||
func diff(a: Stream<Term>, _ b: Stream<Term>) -> Stream<(Diff, Int)> {
|
||||
switch (a, b) {
|
||||
case (.Nil, .Nil):
|
||||
return .Nil
|
||||
case (.Nil, .Cons):
|
||||
return b.map(Diff.Insert)
|
||||
return b.map { (Diff.Insert($0), 1) }
|
||||
case (.Cons, .Nil):
|
||||
return a.map(Diff.Delete)
|
||||
return a.map { (Diff.Delete($0), 1) }
|
||||
case let (.Cons(x, xs), .Cons(y, ys)):
|
||||
let here = Stream.Cons(Diff(x, y), Memo { diff(xs.value, ys.value) })
|
||||
let insert = Stream.Cons(Diff.Insert(y), Memo { diff(a, ys.value) })
|
||||
let delete = Stream.Cons(Diff.Delete(x), Memo { diff(xs.value, b) })
|
||||
let copy = Diff(x, y)
|
||||
let here = Stream.Cons((copy, copy.magnitude), Memo { diff(xs.value, ys.value) })
|
||||
let insert = Stream.Cons((Diff.Insert(y), 1), Memo { diff(a, ys.value) })
|
||||
let delete = Stream.Cons((Diff.Delete(x), 1), Memo { diff(xs.value, b) })
|
||||
return min(here, insert, delete) {
|
||||
magnitude($0) < magnitude($1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array(diff(Stream(sequence: a), Stream(sequence: b)))
|
||||
return Array(diff(Stream(sequence: a), Stream(sequence: b)).map { $0.0 })
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public enum Doc: CustomStringConvertible, Equatable {
|
||||
indirect case Join(Doc, [Doc])
|
||||
|
||||
public init<T>(_ value: T) {
|
||||
self.init((value as? CustomDocConvertible)?.doc ?? .Text(String(value)))
|
||||
self = (value as? CustomDocConvertible)?.doc ?? .Text(String(value))
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
|
@ -60,3 +60,14 @@ public func == (left: Doc, right: Doc) -> Bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public func == <A: Equatable> (left: Vertex<A>, right: Vertex<A>) -> Bool {
|
||||
switch (left, right) {
|
||||
case (.End, .End):
|
||||
return true
|
||||
case let (.XY(a, x1, y1), .XY(b, x2, y2)):
|
||||
return a == b && x1.value == x2.value && y1.value == y2.value
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
70
prototype/Doubt/JSON.swift
Normal file
70
prototype/Doubt/JSON.swift
Normal file
@ -0,0 +1,70 @@
|
||||
public enum JSON {
|
||||
public typealias ArrayType = [JSON]
|
||||
public typealias DictionaryType = [Swift.String:JSON]
|
||||
|
||||
case Number(Double)
|
||||
case Boolean(Bool)
|
||||
case String(Swift.String)
|
||||
case Array(ArrayType)
|
||||
case Dictionary(DictionaryType)
|
||||
case Null
|
||||
|
||||
|
||||
public var number: Double? {
|
||||
if case let .Number(d) = self { return d }
|
||||
return nil
|
||||
}
|
||||
|
||||
public var boolean: Bool? {
|
||||
if case let .Boolean(b) = self { return b }
|
||||
return nil
|
||||
}
|
||||
|
||||
public var string: Swift.String? {
|
||||
if case let .String(s) = self { return s }
|
||||
return nil
|
||||
}
|
||||
|
||||
public var array: ArrayType? {
|
||||
if case let .Array(a) = self { return a }
|
||||
return nil
|
||||
}
|
||||
|
||||
public var dictionary: DictionaryType? {
|
||||
if case let .Dictionary(d) = self { return d }
|
||||
return nil
|
||||
}
|
||||
|
||||
public var isNull: Bool {
|
||||
if case .Null = self { return true }
|
||||
return false
|
||||
}
|
||||
|
||||
public init?(object: AnyObject) {
|
||||
struct E: ErrorType {}
|
||||
func die<T>() throws -> T {
|
||||
throw E()
|
||||
}
|
||||
do {
|
||||
switch object {
|
||||
case let n as Double:
|
||||
self = .Number(n)
|
||||
case let b as Bool:
|
||||
self = .Boolean(b)
|
||||
case let s as Swift.String:
|
||||
self = .String(s)
|
||||
case let a as [AnyObject]:
|
||||
self = .Array(try a.map { try JSON(object: $0) ?? die() })
|
||||
case let d as [Swift.String:AnyObject]:
|
||||
self = .Dictionary(Swift.Dictionary(elements: try d.map { ($0, try JSON(object: $1) ?? die()) }))
|
||||
case is NSNull:
|
||||
self = .Null
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
} catch { return nil }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import Foundation
|
@ -1,9 +0,0 @@
|
||||
let word = ^("abcdefghijklmnopqrstuvwxyz".characters.map { String($0) })
|
||||
let ws = ^" "
|
||||
|
||||
let term: String -> State<Term>? = fix { term in
|
||||
let variable = Syntax<Term>.Variable <^> word
|
||||
let application = Syntax.Apply <^> (^"(" *> ws* *> term <*> (ws *> term)* <* ws* <* ^")")
|
||||
let abstraction = Syntax.Abstract <^> (^"λ" *> ws* *> interpolate(term, ws) <*> (ws* *> ^"." *> term))
|
||||
return Term.init <^> (abstraction <|> application <|> variable)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
public struct Memo<A> {
|
||||
public struct Memo<A>: CustomDebugStringConvertible, CustomStringConvertible {
|
||||
public init(unevaluted: () -> A) {
|
||||
self.init(.Unevaluated(unevaluted))
|
||||
}
|
||||
@ -25,6 +25,15 @@ public struct Memo<A> {
|
||||
public func flatMap<B>(transform: A -> Memo<B>) -> Memo<B> {
|
||||
return Memo<B> { transform(self.value).value }
|
||||
}
|
||||
|
||||
|
||||
public var description: String {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
public var debugDescription: String {
|
||||
return String(reflecting: value)
|
||||
}
|
||||
}
|
||||
|
||||
private final class MutableBox<A> {
|
||||
|
@ -28,6 +28,11 @@ infix operator >>- {
|
||||
precedence 100
|
||||
}
|
||||
|
||||
infix operator &&& {
|
||||
associativity left
|
||||
precedence 120
|
||||
}
|
||||
|
||||
prefix operator ^ {}
|
||||
|
||||
postfix operator * {}
|
||||
|
@ -17,6 +17,35 @@ public prefix func ^(strings: [String])(_ input: String) -> State<String>? {
|
||||
}
|
||||
}
|
||||
|
||||
public prefix func ^<S where S: SequenceType, S.Generator.Element == Character>(strings: S) -> String -> State<String>? {
|
||||
return ^strings.map { String($0) }
|
||||
}
|
||||
|
||||
|
||||
/// Parse the full string with parser or fail.
|
||||
public func full<A>(parser: String -> State<A>?)(_ input: String) -> A? {
|
||||
return parser(input).flatMap { $0.rest.isEmpty ? $0.value : nil }
|
||||
}
|
||||
|
||||
|
||||
/// A convenience for use while developing parsers.
|
||||
public func never<T>(_: String) -> State<T>? {
|
||||
return nil
|
||||
}
|
||||
|
||||
//// Matches a single character that is not matched by `parser`.
|
||||
public func not<T>(parser: String -> State<T>?)(_ input: String) -> State<String>? {
|
||||
if input.isEmpty { return nil }
|
||||
return parser(input).map(const(nil)) ?? State(rest: input.from(1), value: input.to(1))
|
||||
}
|
||||
|
||||
|
||||
/// Delays evaluation of a parser.
|
||||
public func delay<A>(thunk: () -> String -> State<A>?) -> String -> State<A>? {
|
||||
return { thunk()($0) }
|
||||
}
|
||||
|
||||
|
||||
public func parseWhile(predicate: Character -> Bool)(_ input: String) -> State<String>? {
|
||||
return input.characters.count > 0 && predicate(input.characters[input.startIndex])
|
||||
? parseWhile(predicate)(input.from(1)).map { State(rest: $0.rest, value: input.to(1) + $0.value) } ?? State(rest: input.from(1), value: input.to(1))
|
||||
|
@ -63,6 +63,35 @@ public enum Stream<A>: NilLiteralConvertible, SequenceType {
|
||||
}
|
||||
|
||||
|
||||
public func fold<Result>(initial: Result, combine: (A, Memo<Result>) -> Result) -> Result {
|
||||
return analysis(
|
||||
ifCons: { combine($0, $1.map { $0.fold(initial, combine: combine) }) },
|
||||
ifNil: const(initial))
|
||||
}
|
||||
|
||||
public static func unfold<State>(state: State, _ unspool: State -> (A, State)?) -> Stream {
|
||||
return unspool(state).map { value, next in .Cons(value, Memo { self.unfold(next, unspool) }) } ?? .Nil
|
||||
}
|
||||
|
||||
|
||||
public func zipWith<S: SequenceType>(sequence: S) -> Stream<(A, S.Generator.Element)> {
|
||||
return Stream<(A, S.Generator.Element)>.unfold((self, Stream<S.Generator.Element>(sequence: sequence))) {
|
||||
guard let (x, xs) = $0.uncons, (y, ys) = $1.uncons else { return nil }
|
||||
return ((x, y), (xs.value, ys.value))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func take(n: Int) -> Stream {
|
||||
return Stream.unfold((Memo(evaluated: self), n)) { stream, n in
|
||||
guard let (x, xs) = stream.value.uncons else { return nil }
|
||||
return n > 0
|
||||
? (x, (xs, n - 1))
|
||||
: nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public init(nilLiteral: ()) {
|
||||
self = .Nil
|
||||
}
|
||||
|
@ -23,11 +23,99 @@ public enum Term: CustomDebugStringConvertible, CustomDocConvertible, CustomStri
|
||||
return s.doc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static let Apply: (Term, [Term]) -> Term = Syntax.Apply >>> Roll
|
||||
public static let Abstract: ([Term], [Term]) -> Term = Syntax.Abstract >>> Roll
|
||||
public static let Assign: (String, Term) -> Term = Syntax.Assign >>> Roll
|
||||
public static let Variable = Syntax.Variable >>> Roll
|
||||
public static let Literal = Syntax.Literal >>> Roll
|
||||
public static let Group: (Term, [Term]) -> Term = Syntax.Group >>> Roll
|
||||
|
||||
|
||||
// MARK: JSON representation.
|
||||
|
||||
/// Constructs a Term representing the `JSON` in a file at `path`.
|
||||
public init?(path: String, JSON: Doubt.JSON) {
|
||||
struct E: ErrorType {}
|
||||
func die<A>() throws -> A {
|
||||
throw E()
|
||||
}
|
||||
do {
|
||||
switch JSON.dictionary?["key.substructure"] {
|
||||
case let .Some(.Array(a)):
|
||||
self = .Roll(.Group(.Roll(.Literal(path)), try a.map { try Term(JSON: $0) ?? die() }))
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
} catch _ {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Constructs a Term representing `JSON`.
|
||||
public init?(JSON: Doubt.JSON) {
|
||||
enum Key: String {
|
||||
case Name = "key.name"
|
||||
case Substructure = "key.substructure"
|
||||
}
|
||||
struct E: ErrorType {}
|
||||
func die<A>() throws -> A {
|
||||
throw E()
|
||||
}
|
||||
do {
|
||||
switch JSON {
|
||||
case let .Dictionary(d) where d["key.name"] != nil:
|
||||
let name = d["key.name"]?.string ?? ""
|
||||
let substructure = d["key.substructure"]?.array ?? []
|
||||
let kind = d["key.kind"]?.string
|
||||
switch kind {
|
||||
case
|
||||
.Some("source.lang.swift.decl.class"),
|
||||
.Some("source.lang.swift.decl.extension"),
|
||||
.Some("source.lang.swift.decl.enum"),
|
||||
.Some("source.lang.swift.decl.struct"):
|
||||
self = .Group(.Literal(name), try substructure.map { try Term(JSON: $0) ?? die() })
|
||||
|
||||
case .Some("source.lang.swift.decl.enumelement"):
|
||||
fallthrough
|
||||
case
|
||||
.Some("source.lang.swift.decl.function.method.instance"),
|
||||
.Some("source.lang.swift.decl.function.free"):
|
||||
self = .Assign(name, .Abstract([], try substructure.map { try Term(JSON: $0) ?? die() }))
|
||||
|
||||
case
|
||||
.Some("source.lang.swift.decl.var.instance"),
|
||||
.Some("source.lang.swift.decl.var.static"):
|
||||
self = .Variable(name)
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
case let .Dictionary(d) where d["key.kind"]?.string == "source.lang.swift.decl.enumcase" && d["key.substructure"]?.array?.count == 1:
|
||||
let substructure = d["key.substructure"]?.array ?? []
|
||||
self = try Term(JSON: substructure[0]) ?? die()
|
||||
|
||||
case let .Dictionary(d) where d["key.kind"]?.string == "source.lang.swift.syntaxtype.comment.mark":
|
||||
self = .Empty
|
||||
|
||||
case .Null:
|
||||
self = .Empty
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
} catch _ {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum Syntax<Payload>: CustomDebugStringConvertible, CustomDocConvertible {
|
||||
case Apply(Payload, [Payload])
|
||||
case Abstract([Payload], Payload)
|
||||
case Abstract([Payload], [Payload])
|
||||
case Assign(String, Payload)
|
||||
case Variable(String)
|
||||
case Literal(String)
|
||||
@ -38,7 +126,7 @@ public enum Syntax<Payload>: CustomDebugStringConvertible, CustomDocConvertible
|
||||
case let .Apply(f, args):
|
||||
return .Apply(transform(f), args.map(transform))
|
||||
case let .Abstract(parameters, body):
|
||||
return .Abstract(parameters.map(transform), transform(body))
|
||||
return .Abstract(parameters.map(transform), body.map(transform))
|
||||
case let .Assign(n, v):
|
||||
return .Assign(n, transform(v))
|
||||
case let .Variable(n):
|
||||
@ -58,7 +146,7 @@ public enum Syntax<Payload>: CustomDebugStringConvertible, CustomDocConvertible
|
||||
|
||||
case let .Abstract(xs, x):
|
||||
initial = try xs.reduce(initial, combine: combine)
|
||||
return try combine(initial, x)
|
||||
return try x.reduce(initial, combine: combine)
|
||||
|
||||
case let .Assign(_, x):
|
||||
return try combine(initial, x)
|
||||
@ -106,7 +194,7 @@ public enum Syntax<Payload>: CustomDebugStringConvertible, CustomDocConvertible
|
||||
.Text("λ"),
|
||||
.Join(.Text(", "), parameters.map(Doc.init)),
|
||||
.Text("."),
|
||||
Doc(body)
|
||||
.Vertical(body.map(Doc.init))
|
||||
])
|
||||
case let .Assign(n, v):
|
||||
return .Horizontal([ .Text(n), .Text("="), Doc(v) ])
|
||||
|
115
prototype/Doubt/Vertex.swift
Normal file
115
prototype/Doubt/Vertex.swift
Normal file
@ -0,0 +1,115 @@
|
||||
public enum Vertex<Element>: CustomDebugStringConvertible, CustomStringConvertible {
|
||||
indirect case XY(Element, Memo<Vertex>, Memo<Vertex>)
|
||||
case End
|
||||
|
||||
public func analysis<Result>(@noescape ifXY ifXY: (Element, Memo<Vertex>, Memo<Vertex>) -> Result, @noescape ifEnd: () -> Result) -> Result {
|
||||
switch self {
|
||||
case let .XY(a, x, y):
|
||||
return ifXY(a, x, y)
|
||||
case .End:
|
||||
return ifEnd()
|
||||
}
|
||||
}
|
||||
|
||||
public var isEmpty: Bool {
|
||||
return analysis(ifXY: const(false), ifEnd: const(true))
|
||||
}
|
||||
|
||||
public var element: Element? {
|
||||
return analysis(
|
||||
ifXY: { x, _, _ in x },
|
||||
ifEnd: const(nil))
|
||||
}
|
||||
|
||||
public var right: Memo<Vertex> {
|
||||
return analysis(
|
||||
ifXY: { _, xs, _ in xs },
|
||||
ifEnd: const(Memo(evaluated: .End)))
|
||||
}
|
||||
|
||||
public var down: Memo<Vertex> {
|
||||
return analysis(
|
||||
ifXY: { _, _, ys in ys },
|
||||
ifEnd: const(Memo(evaluated: .End)))
|
||||
}
|
||||
|
||||
public var diagonal: Memo<Vertex> {
|
||||
return right.flatMap { $0.down }
|
||||
}
|
||||
|
||||
|
||||
public var row: Stream<Element> {
|
||||
return Stream.unfold(Memo(evaluated: self)) {
|
||||
$0.value.analysis(
|
||||
ifXY: { here, across, _ in .Some(here, across) },
|
||||
ifEnd: const(nil))
|
||||
}
|
||||
}
|
||||
|
||||
public var column: Stream<Element> {
|
||||
return Stream.unfold(Memo(evaluated: self)) {
|
||||
$0.value.analysis(
|
||||
ifXY: { here, _, down in .Some(here, down) },
|
||||
ifEnd: const(nil))
|
||||
}
|
||||
}
|
||||
|
||||
public var rowMajor: Stream<Stream<Element>> {
|
||||
return Stream.unfold(Memo(evaluated: self), { (state: Memo<Vertex>) -> (Stream<Element>, Memo<Vertex>)? in
|
||||
state.value.analysis(
|
||||
ifXY: { _, _, down in (state.value.row, down) },
|
||||
ifEnd: const(nil))
|
||||
})
|
||||
}
|
||||
|
||||
public var columnMajor: Stream<Stream<Element>> {
|
||||
return Stream.unfold(Memo(evaluated: self), { (state: Memo<Vertex>) -> (Stream<Element>, Memo<Vertex>)? in
|
||||
state.value.analysis(
|
||||
ifXY: { _, across, _ in (state.value.column, across) },
|
||||
ifEnd: const(nil))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
public init<S1: SequenceType, S2: SequenceType>(rows: S1, columns: S2, combine: (S1.Generator.Element, S2.Generator.Element) -> Element) {
|
||||
let rows = Stream(sequence: rows)
|
||||
let columns = Stream(sequence: columns)
|
||||
func across(vertex: Vertex<Element>) -> Stream<Memo<Vertex<Element>>> {
|
||||
return Stream.unfold(Memo(evaluated: vertex)) { vertex in
|
||||
vertex.value.analysis(
|
||||
ifXY: { _, xs, _ in .Some(vertex, xs) },
|
||||
ifEnd: const(.Some(vertex, vertex)))
|
||||
}
|
||||
}
|
||||
self = rows
|
||||
.map { a in columns.map { b in combine(a, b) } }
|
||||
.fold(.End) {
|
||||
$0.zipWith(across($1.value)).fold(.End) {
|
||||
.XY($0.0, $1, $0.1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func map<Other>(transform: Element -> Other) -> Vertex<Other> {
|
||||
switch self {
|
||||
case let .XY(xy, xs, ys):
|
||||
return .XY(transform(xy), xs.map { $0.map(transform) }, ys.map { $0.map(transform) })
|
||||
case .End:
|
||||
return .End
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public var debugDescription: String {
|
||||
return rowMajor.map {
|
||||
$0.map { String(reflecting: $0) }.joinWithSeparator("\t")
|
||||
}.joinWithSeparator("\n")
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
return rowMajor.map {
|
||||
$0.map { String($0) }.joinWithSeparator("\t")
|
||||
}.joinWithSeparator("\n")
|
||||
}
|
||||
}
|
@ -26,6 +26,11 @@ final class DiffTests: XCTestCase {
|
||||
func testSESCanDeleteInMiddle() {
|
||||
XCTAssertEqual(Diff.diff([ a, d, b, c ], [ a, b, c ]), [ Diff(a), Diff.Delete(d), Diff(b), Diff(c) ])
|
||||
}
|
||||
|
||||
func testSESOfLongerSequences() {
|
||||
// fixme: this is awfully slow for such a short sequence
|
||||
XCTAssertEqual(Diff.diff([ a, b, c, a, b, b, a ], [ c, b, a, b, a, c ]), [ Diff.Patch(a, c), Diff(b), Diff.Delete(c), Diff(a), Diff.Delete(b), Diff(b), Diff(a), Diff.Insert(c) ])
|
||||
}
|
||||
}
|
||||
|
||||
private let a = Term(.Literal("a"))
|
||||
|
@ -1,24 +0,0 @@
|
||||
final class DoubtTests: XCTestCase {
|
||||
func testEqualSyntaxResultsInRecursivelyCopyingDiff() {
|
||||
if let s = sexpr("\t(\n( a) \n)\t")?.value, t = sexpr("((a))")?.value {
|
||||
XCTAssertEqual(Diff(s, t), Diff.Copy(.Apply(.Copy(.Apply(.Copy(.Variable("a")), [])), [])))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let atom = Syntax<Term>.Variable <^> ^("abcdefghijklmnopqrstuvwxyz".characters.map { String($0) })
|
||||
let ws = ^(" \t\n".characters.map { String($0) })
|
||||
|
||||
let sexpr: String -> State<Term>? = fix { sexpr in
|
||||
let list = Syntax<Term>.Apply <^> (ws* *> ^"(" *> ws* *> sexpr <*> sexpr* <* ^")")
|
||||
return Term.init <^> (atom <|> list) <* ws*
|
||||
}
|
||||
|
||||
|
||||
func fix<T, U>(f: (T -> U) -> T -> U) -> T -> U {
|
||||
return { f(fix(f))($0) }
|
||||
}
|
||||
|
||||
|
||||
import Doubt
|
||||
import XCTest
|
19
prototype/DoubtTests/SwiftTests.swift
Normal file
19
prototype/DoubtTests/SwiftTests.swift
Normal file
@ -0,0 +1,19 @@
|
||||
final class SwiftTests: XCTestCase {
|
||||
func testParsingAFile() {
|
||||
let path = __FILE__
|
||||
guard let file = File(path: path) else {
|
||||
XCTFail("Could not make a File from \(__FILE__)")
|
||||
return
|
||||
}
|
||||
|
||||
let structure = Structure(file: file)
|
||||
let dictionary = toAnyObject(structure.dictionary)
|
||||
|
||||
print(JSON(object: dictionary).map { Term(path: path, JSON: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@testable import Doubt
|
||||
import SourceKittenFramework
|
||||
import XCTest
|
47
prototype/DoubtTests/VertexTests.swift
Normal file
47
prototype/DoubtTests/VertexTests.swift
Normal file
@ -0,0 +1,47 @@
|
||||
final class VertexTests: XCTestCase {
|
||||
func testConstructingWithStreamsProducesMatrixOfProducts() {
|
||||
let actual = Vertex(rows: Stream(sequence: [ "a", "b" ]), columns: Stream(sequence: [ "0", "1" ]), combine: +)
|
||||
|
||||
let expected: Vertex<String> = {
|
||||
let end = Memo<Vertex<String>>(evaluated: .End)
|
||||
let b1 = Memo<Vertex<String>> { .XY("b1", end, end) }
|
||||
let b0 = Memo<Vertex<String>> { .XY("b0", b1, end) }
|
||||
let a1 = Memo<Vertex<String>> { .XY("a1", end, b1) }
|
||||
let a0 = Memo<Vertex<String>> { .XY("a0", a1, b0) }
|
||||
return a0.value
|
||||
}()
|
||||
XCTAssert(actual == expected, "\(String(reflecting: actual)) != \(String(reflecting: expected))")
|
||||
}
|
||||
|
||||
func testConstructingWithStreamsProducesMatrix() {
|
||||
let actual = Vertex(rows: Stream(sequence: [ "a", "b", "c" ]), columns: Stream(sequence: [ "0", "1", "2" ]), combine: +)
|
||||
|
||||
let expected: Vertex<String> = {
|
||||
let end = Memo<Vertex<String>>(evaluated: .End)
|
||||
let c2 = Memo<Vertex<String>> { .XY("c2", end, end) }
|
||||
let c1 = Memo<Vertex<String>> { .XY("c1", c2, end) }
|
||||
let c0 = Memo<Vertex<String>> { .XY("c0", c1, end) }
|
||||
let b2 = Memo<Vertex<String>> { .XY("b2", end, c2) }
|
||||
let b1 = Memo<Vertex<String>> { .XY("b1", b2, c1) }
|
||||
let b0 = Memo<Vertex<String>> { .XY("b0", b1, c0) }
|
||||
let a2 = Memo<Vertex<String>> { .XY("a2", end, b2) }
|
||||
let a1 = Memo<Vertex<String>> { .XY("a1", a2, b1) }
|
||||
let a0 = Memo<Vertex<String>> { .XY("a0", a1, b0) }
|
||||
return a0.value
|
||||
}()
|
||||
XCTAssert(actual == expected, "\(String(reflecting: actual)) != \(String(reflecting: expected))")
|
||||
}
|
||||
|
||||
func testFib() {
|
||||
XCTAssertEqual(Array(fib.take(7)), [ 1, 1, 2, 3, 5, 8, 13 ])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private let fib: Stream<Int> = Stream.unfold((0, 1)) { x, y in
|
||||
(y, (y, x + y))
|
||||
}
|
||||
|
||||
|
||||
@testable import Doubt
|
||||
import XCTest
|
1
prototype/External/SourceKitten
vendored
Submodule
1
prototype/External/SourceKitten
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 25aafd5ed37f855c713e87b75c4693d77dbabc63
|
16
prototype/doubt-swift/BoundsCheckedArray.swift
Normal file
16
prototype/doubt-swift/BoundsCheckedArray.swift
Normal file
@ -0,0 +1,16 @@
|
||||
struct BoundsCheckedArray<Element>: CollectionType {
|
||||
init(array: [Element]) {
|
||||
self.array = array
|
||||
}
|
||||
|
||||
let array: [Element]
|
||||
|
||||
let startIndex = 0
|
||||
var endIndex: Int {
|
||||
return array.count
|
||||
}
|
||||
|
||||
subscript (i: Int) -> Element? {
|
||||
return i < count ? array[i] : nil
|
||||
}
|
||||
}
|
34
prototype/doubt-swift/Info.plist
Normal file
34
prototype/doubt-swift/Info.plist
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2015 GitHub. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
23
prototype/doubt-swift/main.swift
Normal file
23
prototype/doubt-swift/main.swift
Normal file
@ -0,0 +1,23 @@
|
||||
import Doubt
|
||||
import SourceKittenFramework
|
||||
|
||||
let arguments = BoundsCheckedArray(array: Process.arguments)
|
||||
|
||||
extension Term {
|
||||
init?(path: String) {
|
||||
guard path != "/dev/null" else {
|
||||
self = .Empty
|
||||
return
|
||||
}
|
||||
guard let term = File(path: path)
|
||||
.map(Structure.init)
|
||||
.map({ $0.dictionary })
|
||||
.map(toAnyObject)
|
||||
.flatMap({ JSON(object: $0).flatMap { Term(path: path, JSON: $0) } }) else { return nil }
|
||||
self = term
|
||||
}
|
||||
}
|
||||
|
||||
if let a = arguments[1].flatMap(Term.init), b = arguments[2].flatMap(Term.init) {
|
||||
print(String(reflecting: Diff(a, b)))
|
||||
}
|
Loading…
Reference in New Issue
Block a user