From ee1d005ab9fcd20f185cbfe116f4c45942f67e62 Mon Sep 17 00:00:00 2001 From: Dimitri Racordon Date: Sat, 23 Feb 2019 02:21:39 +0100 Subject: [PATCH 01/32] Update .gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 02c0875..623b3b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ +# macOS .DS_Store + +# Swift PM and Xcode /.build /Packages +/Package.resolved /*.xcodeproj + +# Project specific files +InputSamples/ From b6b585eb5453c9f51f99d75644639c75df0e9cae Mon Sep 17 00:00:00 2001 From: Dimitri Racordon Date: Sat, 23 Feb 2019 02:27:16 +0100 Subject: [PATCH 02/32] Remove the interpreter --- Package.swift | 25 +- README.md | 40 - Sources/LogicKitParser/Parser.swift | 100 -- Sources/linenoise/LICENSE | 25 - Sources/linenoise/Makefile | 7 - Sources/linenoise/README.markdown | 229 ---- Sources/linenoise/include/linenoise.h | 75 -- Sources/linenoise/linenoise.c | 1199 ----------------- Sources/lki/main.swift | 125 -- .../LogicKitParserTests.swift | 85 -- 10 files changed, 8 insertions(+), 1902 deletions(-) delete mode 100644 Sources/LogicKitParser/Parser.swift delete mode 100644 Sources/linenoise/LICENSE delete mode 100644 Sources/linenoise/Makefile delete mode 100644 Sources/linenoise/README.markdown delete mode 100644 Sources/linenoise/include/linenoise.h delete mode 100644 Sources/linenoise/linenoise.c delete mode 100644 Sources/lki/main.swift delete mode 100644 Tests/LogicKitParserTests/LogicKitParserTests.swift diff --git a/Package.swift b/Package.swift index 3310605..c2999ba 100644 --- a/Package.swift +++ b/Package.swift @@ -3,21 +3,12 @@ import PackageDescription let package = Package( - name: "LogicKit", - products: [ - .library(name: "LogicKit", type: .static, targets: ["LogicKit"]), - .executable(name: "lki", targets: ["lki"]), - ], - dependencies: [ - .package(url: "https://github.com/rxwei/Parsey.git", .revision("32f653044f95c880cd0cce929cfef29efb07ee5b")), - ], - targets: [ - .target(name: "LogicKit"), - .target(name: "LogicKitParser", dependencies: ["LogicKit", "Parsey"]), - .target(name: "lki", dependencies: ["LogicKit", "LogicKitParser", "linenoise"]), - .target(name: "linenoise"), - - .testTarget(name: "LogicKitTests", dependencies: ["LogicKit"]), - .testTarget(name: "LogicKitParserTests", dependencies: ["LogicKit", "LogicKitParser"]), - ] + name: "LogicKit", + products: [ + .library(name: "LogicKit", type: .static, targets: ["LogicKit"]), + ], + targets: [ + .target(name: "LogicKit"), + .testTarget(name: "LogicKitTests", dependencies: ["LogicKit"]), + ] ) diff --git a/README.md b/README.md index 6d68cdf..8ae288d 100644 --- a/README.md +++ b/README.md @@ -217,46 +217,6 @@ import LogicKit > The schemes of the auto-generated package might require some manual configuration. > Please refer to Xcode's documentation for more information on that end. -### Using the interpreter - -LogicKit comes with an interpreter, `lki`, -that you can use to design and/or debug knowledge bases. -To use the interpreter, first clone this repository: - -```bash -git clone git@github.com:kyouko-taiga/LogicKit.git -``` - -You can then compile `lki`: - -```bash -swift build --configuration release --product lki -``` - -Which will create a binary `lki` in `.build/release/`. -Feel free to symlink copy or symlink this binary to include it in your path. - -To use `lki`, first write your knowledge base in some file, for instance `nat.kb`: - -```swift -.fact("add", zero, y, y), -.rule("add", .fact("succ", x), y, z) { - .fact("add", x, .fact("succ", y), z) -} -``` - -Then, invoke the interpreter with a path to your knowledge base: - -```bash -lki /path/to/nat.kb -``` - -You'll be presented a prompt that lets you issue queries against your knowledge base. - -> Note that `lki` can only read knowledge bases written with the LogicKit syntax, -> meaning that you can't use the full power of Swift -> like you would be able to in actual Swift sources. - ## License LogicKit is licensed under the MIT License. diff --git a/Sources/LogicKitParser/Parser.swift b/Sources/LogicKitParser/Parser.swift deleted file mode 100644 index 0fc9309..0000000 --- a/Sources/LogicKitParser/Parser.swift +++ /dev/null @@ -1,100 +0,0 @@ -import LogicKit -import Parsey - -@available(swift, deprecated: 4.1) -public struct Grammar { - - // MARK: Knowledge base (entry point of the grammar) - - public static let knowledge = newlines.? ~~> statement.* - public static let statement = (term | rule).amid(ws.?) <~~ terminator - - public static let terminator = - (comma.amid(ws.?) <~~ newlines).skipped() - | newlines.skipped() - | Lexer.end.skipped() - - // MARK: Variables - - public static let variable = - ".var(" ~~> string.amid(ws.?) <~~ ")" -