1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

Merge pull request #159 from github/parse-with-tree-sitter

Integrate with tree-sitter
This commit is contained in:
Josh Vera 2015-10-28 10:58:10 -04:00
commit 8db8a38d8e
15 changed files with 75128 additions and 12 deletions

3
.gitmodules vendored
View File

@ -10,3 +10,6 @@
[submodule "prototype/External/SwiftCheck"]
path = prototype/External/SwiftCheck
url = https://github.com/typelift/SwiftCheck.git
[submodule "prototype/External/tree-sitter"]
path = prototype/External/tree-sitter
url = https://github.com/maxbrunsfeld/tree-sitter.git

View File

@ -53,6 +53,14 @@
D4DF970A1BC5DF800040F41F /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4DF97091BC5DF800040F41F /* main.swift */; };
D4DF970C1BC5DF9E0040F41F /* BoundsCheckedArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = D435B7521BB31BBC000902F6 /* BoundsCheckedArray.swift */; };
D4DF970D1BC5E1B40040F41F /* Doubt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4AAE4FD1B5AE22E004E581F /* Doubt.framework */; };
D4FB2CD61BDEBC9000B3CCE0 /* Doubt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4AAE4FD1B5AE22E004E581F /* Doubt.framework */; };
D4FB2CD71BDEBC9D00B3CCE0 /* Either.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D42F09671BCCC41600B95610 /* Either.framework */; };
D4FB2CD81BDEBC9D00B3CCE0 /* Memo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D42F09681BCCC41600B95610 /* Memo.framework */; };
D4FB2CD91BDEBC9D00B3CCE0 /* Prelude.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D42F09691BCCC41600B95610 /* Prelude.framework */; };
D4FB2CDA1BDEBC9D00B3CCE0 /* Stream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D42F096A1BCCC41600B95610 /* Stream.framework */; };
D4FB2CDC1BDEBCCD00B3CCE0 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4FB2CDB1BDEBCCD00B3CCE0 /* main.swift */; };
D4FB2CE01BDEBD1C00B3CCE0 /* libruntime.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D4FB2CDE1BDEBD1C00B3CCE0 /* libruntime.a */; };
D4FB2CEA1BDEC7FA00B3CCE0 /* javascript.c in Sources */ = {isa = PBXBuildFile; fileRef = D4FB2CE91BDEC7FA00B3CCE0 /* javascript.c */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -63,6 +71,13 @@
remoteGlobalIDString = D4AAE4FC1B5AE22E004E581F;
remoteInfo = Doubt;
};
D4FB2CE31BDEBD4200B3CCE0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D4AAE4F41B5AE22E004E581F /* Project object */;
proxyType = 1;
remoteGlobalIDString = D485A7841BDEB6C5003A17B6;
remoteInfo = runtime;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@ -108,6 +123,11 @@
D4DF96F01BC54C970040F41F /* Doubt.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = Doubt.modulemap; sourceTree = "<group>"; };
D4DF96FB1BC5DF050040F41F /* doubt-json.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "doubt-json.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D4DF97091BC5DF800040F41F /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
D4FB2CC91BDEBC6300B3CCE0 /* doubt-difftool.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "doubt-difftool.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D4FB2CDB1BDEBCCD00B3CCE0 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
D4FB2CDE1BDEBD1C00B3CCE0 /* libruntime.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libruntime.a; path = "External/tree-sitter/out/Release/libruntime.a"; sourceTree = SOURCE_ROOT; };
D4FB2CE51BDEBE7900B3CCE0 /* doubt-difftool-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "doubt-difftool-Bridging-Header.h"; sourceTree = "<group>"; };
D4FB2CE91BDEC7FA00B3CCE0 /* javascript.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = javascript.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -149,6 +169,19 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D4FB2CC61BDEBC6300B3CCE0 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D4FB2CD61BDEBC9000B3CCE0 /* Doubt.framework in Frameworks */,
D4FB2CD71BDEBC9D00B3CCE0 /* Either.framework in Frameworks */,
D4FB2CD81BDEBC9D00B3CCE0 /* Memo.framework in Frameworks */,
D4FB2CE01BDEBD1C00B3CCE0 /* libruntime.a in Frameworks */,
D4FB2CD91BDEBC9D00B3CCE0 /* Prelude.framework in Frameworks */,
D4FB2CDA1BDEBC9D00B3CCE0 /* Stream.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@ -158,6 +191,7 @@
D4AAE4FF1B5AE22E004E581F /* Doubt */,
D4AAE5111B5AE22E004E581F /* DoubtTests */,
D4DF96FC1BC5DF050040F41F /* doubt-json */,
D4FB2CCA1BDEBC6300B3CCE0 /* doubt-difftool */,
D4AAE4FE1B5AE22E004E581F /* Products */,
);
sourceTree = "<group>";
@ -168,6 +202,7 @@
D4AAE4FD1B5AE22E004E581F /* Doubt.framework */,
D4AAE50D1B5AE22E004E581F /* DoubtTests.xctest */,
D4DF96FB1BC5DF050040F41F /* doubt-json.app */,
D4FB2CC91BDEBC6300B3CCE0 /* doubt-difftool.app */,
);
name = Products;
sourceTree = "<group>";
@ -240,6 +275,17 @@
path = "doubt-json";
sourceTree = "<group>";
};
D4FB2CCA1BDEBC6300B3CCE0 /* doubt-difftool */ = {
isa = PBXGroup;
children = (
D4FB2CDB1BDEBCCD00B3CCE0 /* main.swift */,
D4FB2CE91BDEC7FA00B3CCE0 /* javascript.c */,
D4FB2CE51BDEBE7900B3CCE0 /* doubt-difftool-Bridging-Header.h */,
D4FB2CDE1BDEBD1C00B3CCE0 /* libruntime.a */,
);
path = "doubt-difftool";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@ -252,6 +298,23 @@
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXLegacyTarget section */
D485A7841BDEB6C5003A17B6 /* runtime */ = {
isa = PBXLegacyTarget;
buildArgumentsString = "$(ACTION)";
buildConfigurationList = D485A7871BDEB6C5003A17B6 /* Build configuration list for PBXLegacyTarget "runtime" */;
buildPhases = (
);
buildToolPath = "$(SRCROOT)/script/tree-sitter.sh";
buildWorkingDirectory = "$(SRCROOT)/External/tree-sitter";
dependencies = (
);
name = runtime;
passBuildSettingsInEnvironment = 1;
productName = "tree-sitter";
};
/* End PBXLegacyTarget section */
/* Begin PBXNativeTarget section */
D4AAE4FC1B5AE22E004E581F /* Doubt */ = {
isa = PBXNativeTarget;
@ -295,7 +358,6 @@
buildPhases = (
D4DF96F71BC5DF050040F41F /* Sources */,
D4DF96F81BC5DF050040F41F /* Frameworks */,
D4DF96F91BC5DF050040F41F /* Resources */,
);
buildRules = (
);
@ -306,16 +368,36 @@
productReference = D4DF96FB1BC5DF050040F41F /* doubt-json.app */;
productType = "com.apple.product-type.application";
};
D4FB2CC81BDEBC6300B3CCE0 /* doubt-difftool */ = {
isa = PBXNativeTarget;
buildConfigurationList = D4FB2CD31BDEBC6300B3CCE0 /* Build configuration list for PBXNativeTarget "doubt-difftool" */;
buildPhases = (
D4FB2CC51BDEBC6300B3CCE0 /* Sources */,
D4FB2CC61BDEBC6300B3CCE0 /* Frameworks */,
);
buildRules = (
);
dependencies = (
D4FB2CE41BDEBD4200B3CCE0 /* PBXTargetDependency */,
);
name = "doubt-difftool";
productName = "doubt-difftool";
productReference = D4FB2CC91BDEBC6300B3CCE0 /* doubt-difftool.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D4AAE4F41B5AE22E004E581F /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = GitHub;
TargetAttributes = {
D485A7841BDEB6C5003A17B6 = {
CreatedOnToolsVersion = 7.1;
};
D4AAE4FC1B5AE22E004E581F = {
CreatedOnToolsVersion = 7.0;
};
@ -325,6 +407,9 @@
D4DF96FA1BC5DF050040F41F = {
CreatedOnToolsVersion = 7.0.1;
};
D4FB2CC81BDEBC6300B3CCE0 = {
CreatedOnToolsVersion = 7.1;
};
};
};
buildConfigurationList = D4AAE4F71B5AE22E004E581F /* Build configuration list for PBXProject "Doubt" */;
@ -343,6 +428,8 @@
D4AAE4FC1B5AE22E004E581F /* Doubt */,
D4AAE50C1B5AE22E004E581F /* DoubtTests */,
D4DF96FA1BC5DF050040F41F /* doubt-json */,
D4FB2CC81BDEBC6300B3CCE0 /* doubt-difftool */,
D485A7841BDEB6C5003A17B6 /* runtime */,
);
};
/* End PBXProject section */
@ -362,13 +449,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D4DF96F91BC5DF050040F41F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@ -422,6 +502,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D4FB2CC51BDEBC6300B3CCE0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D4FB2CEA1BDEC7FA00B3CCE0 /* javascript.c in Sources */,
D4FB2CDC1BDEBCCD00B3CCE0 /* main.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
@ -430,9 +519,38 @@
target = D4AAE4FC1B5AE22E004E581F /* Doubt */;
targetProxy = D4AAE50F1B5AE22E004E581F /* PBXContainerItemProxy */;
};
D4FB2CE41BDEBD4200B3CCE0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D485A7841BDEB6C5003A17B6 /* runtime */;
targetProxy = D4FB2CE31BDEBD4200B3CCE0 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
D485A7851BDEB6C5003A17B6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEBUGGING_SYMBOLS = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D485A7861BDEB6C5003A17B6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
D4AAE5151B5AE22E004E581F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@ -621,9 +739,62 @@
};
name = Release;
};
D4FB2CD41BDEBC6300B3CCE0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
HEADER_SEARCH_PATHS = "$(SRCROOT)/External/tree-sitter/include/";
INFOPLIST_FILE = "doubt-difftool/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/External/tree-sitter/out/Release",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.doubt-difftool";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "doubt-difftool/doubt-difftool-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
D4FB2CD51BDEBC6300B3CCE0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
HEADER_SEARCH_PATHS = "$(SRCROOT)/External/tree-sitter/include/";
INFOPLIST_FILE = "doubt-difftool/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/External/tree-sitter/out/Release",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.doubt-difftool";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "doubt-difftool/doubt-difftool-Bridging-Header.h";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D485A7871BDEB6C5003A17B6 /* Build configuration list for PBXLegacyTarget "runtime" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D485A7851BDEB6C5003A17B6 /* Debug */,
D485A7861BDEB6C5003A17B6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D4AAE4F71B5AE22E004E581F /* Build configuration list for PBXProject "Doubt" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@ -660,6 +831,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D4FB2CD31BDEBC6300B3CCE0 /* Build configuration list for PBXNativeTarget "doubt-difftool" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D4FB2CD41BDEBC6300B3CCE0 /* Debug */,
D4FB2CD51BDEBC6300B3CCE0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D4AAE4F41B5AE22E004E581F /* Project object */;

View File

@ -0,0 +1,109 @@
<?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 = "D4FB2CC81BDEBC6300B3CCE0"
BuildableName = "doubt-difftool.app"
BlueprintName = "doubt-difftool"
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 = "D4FB2CC81BDEBC6300B3CCE0"
BuildableName = "doubt-difftool.app"
BlueprintName = "doubt-difftool"
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 = "D4FB2CC81BDEBC6300B3CCE0"
BuildableName = "doubt-difftool.app"
BlueprintName = "doubt-difftool"
ReferencedContainer = "container:Doubt.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "$(SRCROOT)/doubt-difftool/Fixtures/before.js"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "$(SRCROOT)/doubt-difftool/Fixtures/after.js"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "$(SRCROOT)/UI/doubt-difftool.js.json"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "$(SRCROOT)/UI/index.html"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D4FB2CC81BDEBC6300B3CCE0"
BuildableName = "doubt-difftool.app"
BlueprintName = "doubt-difftool"
ReferencedContainer = "container:Doubt.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,80 @@
<?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 = "D485A7841BDEB6C5003A17B6"
BuildableName = "runtime"
BlueprintName = "runtime"
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>
<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 = "D485A7841BDEB6C5003A17B6"
BuildableName = "runtime"
BlueprintName = "runtime"
ReferencedContainer = "container:Doubt.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D485A7841BDEB6C5003A17B6"
BuildableName = "runtime"
BlueprintName = "runtime"
ReferencedContainer = "container:Doubt.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -84,7 +84,7 @@ public enum JSON: ArrayLiteralConvertible, BooleanLiteralConvertible, Dictionary
}
public func serialize() -> NSData {
return try! NSJSONSerialization.dataWithJSONObject(object, options: .PrettyPrinted)
return try! NSJSONSerialization.dataWithJSONObject(object, options: [])
}

1
prototype/External/tree-sitter vendored Submodule

@ -0,0 +1 @@
Subproject commit 1829b34c6f72ed890310b8d523e861f950fb0687

View File

@ -1 +1 @@
diff.json
*.json

View File

@ -65,7 +65,7 @@
<div id="before" class="diff"></div>
<div id="after" class="diff"></div>
<script type="text/javascript">
loadJSON('diff.json', function (json) {
loadJSON((window.location.search || '?diff.json').substr(1), function (json) {
var diff = diffFromJSON(json.diff);
var before = diff.map(function(value) {
var element;

View File

@ -0,0 +1,53 @@
function diffFromJSON(json) {
if (json.pure != null) { return new Diff({ pure: new Patch(json.pure) }); }
if (json.roll != null) {
return new Diff({
roll: {
extract: json.roll.extract,
unwrap: new Syntax(json.roll.unwrap, function(x) { return diffFromJSON(x); })
}
});
}
}
function Diff(object) {
if (object.pure != null) { this.pure = object.pure; }
if (object.roll != null) { this.roll = object.roll; }
return this;
}
// forall a b. Diff a -> (a -> b) -> Diff b
Diff.prototype.map = function(transform) {
if (this.pure != null) { return new Diff({ pure: transform(this.pure) }); }
if (this.roll != null) {
return new Diff({
roll: {
extract: this.roll.extract,
unwrap: this.roll.unwrap.map(function(x) { return x.map(transform); })
}
});
}
}
// forall a. Diff a -> (Syntax a -> a) -> a
Diff.prototype.cata = function(transform) {
if (this.pure != null) { return this.pure; }
if (this.roll != null) {
return transform(this.roll.unwrap.map(function(diff) {
return diff.cata(transform);
}))
}
}
/// Diff -> String -> String -> DOM
function diffToDOM(diff, which, source) {
if (diff.pure != null) { return diff.pure; }
function getRange(diff) {
if (diff.pure != null) { return diff.pure["data-range"]; }
if (diff.roll != null) { return diff.roll.extract[which]; }
}
return rangeAndSyntaxToDOM(getRange(diff), diff.roll.unwrap, source, getRange, function(diff) {
return diffToDOM(diff, which, source);
})
}

View File

@ -0,0 +1,77 @@
function diffFromJSON(json) {
if (json.pure != null) {
return new Diff({
pure: new Patch(json.pure)
});
}
if (json.roll != null) {
return new Diff({
roll: {
extract: json.roll.extract,
unwrap: new Syntax(json.roll.unwrap, function(x) {
return diffFromJSON(x);
})
}
});
}
}
function Diff(object) {
if (object.pure != null) {
this.pure = object.pure;
}
if (object.roll != null) {
this.roll = object.roll;
}
return this;
}
// forall a b. Diff a -> (a -> b) -> Diff b
Diff.prototype.map = function(transform) {
if (this.pure != null) {
return new Diff({
pure: transform(this.pure)
});
}
if (this.roll != null) {
return new Diff({
roll: {
extract: this.roll.extract,
unwrap: this.roll.unwrap.map(function(x) {
return x.map(transform);
})
}
});
}
}
// forall a. Diff a -> (Syntax a -> a) -> a
Diff.prototype.cata = function(transform) {
if (this.pure != null) {
return this.pure;
}
if (this.roll != null) {
return transform(this.roll.unwrap.map(function(diff) {
return diff.cata(transform);
}))
}
}
/// Diff -> String -> String -> DOM
function diffToDOM(diff, which, source) {
if (diff.pure != null) {
return diff.pure;
}
function getRange(diff) {
if (diff.pure != null) {
return diff.pure["data-range"];
}
if (diff.roll != null) {
return diff.roll.extract[which];
}
}
return rangeAndSyntaxToDOM(getRange(diff), diff.roll.unwrap, source, getRange, function(diff) {
return diffToDOM(diff, which, source);
})
}

View 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>

View File

@ -0,0 +1,3 @@
#import "tree_sitter/runtime.h"
extern TSLanguage *ts_language_javascript();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,69 @@
import Cocoa
import Doubt
import Prelude
func readFile(path: String) -> String? {
guard let data = try? NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) else { return nil }
return data as String?
}
typealias Term = Cofree<String, Range<Int>>
func termWithInput(string: String) -> Term? {
let document = ts_document_make()
defer { ts_document_free(document) }
return string.withCString {
ts_document_set_language(document, ts_language_javascript())
ts_document_set_input_string(document, $0)
ts_document_parse(document)
let root = ts_document_root_node(document)
return Cofree
.ana { node in
let count = ts_node_named_child_count(node)
guard count > 0 else {
return String.fromCString(ts_node_name(node, document)).map(Syntax.Leaf)!
}
return .Indexed((0..<count).map { ts_node_named_child(node, $0) })
} (root)
.map {
let start = ts_node_pos($0).chars
return start..<(start + ts_node_size($0).chars)
}
}
}
let arguments = BoundsCheckedArray(array: Process.arguments)
if let aString = arguments[1].flatMap(readFile), bString = arguments[2].flatMap(readFile), c = arguments[3], ui = arguments[4] {
if let a = termWithInput(aString), b = termWithInput(bString) {
let diff = Interpreter<Term>(equal: Term.equals(annotation: const(true), leaf: ==), comparable: const(true), cost: Free.sum(Patch.difference)).run(a, b)
let range: Range<Int> -> Doubt.JSON = {
let start = $0.startIndex
let end = $0.endIndex
return [
.Number(Double(start)),
.Number(Double(end - start)),
]
}
let JSON: Doubt.JSON = [
"before": .String(aString),
"after": .String(bString),
"diff": diff.JSON(pure: { $0.JSON { $0.JSON(annotation: range, leaf: Doubt.JSON.String) } }, leaf: Doubt.JSON.String, annotation: {
[
"before": range($0),
"after": range($1),
]
}),
]
let data = JSON.serialize()
try data.writeToFile(c, options: .DataWritingAtomic)
let components = NSURLComponents()
components.scheme = "file"
components.path = ui
components.query = c
if let URL = components.URL {
NSWorkspace.sharedWorkspace().openURL(URL)
}
}
}

17
prototype/script/tree-sitter.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
cd `dirname $0`/../External/tree-sitter
case "$1" in
""|build)
script/configure.sh
make "$PRODUCT_NAME"
;;
clean)
script/clean.sh
;;
*)
echo "I don't know how to '$1'"
exit 1
;;
esac