A simple parser combinator, created in Swift.
ParserCombinator attempts to create a simple and user-friendly way to parse strings into objects and structures. Technical terms are largely avoided and convenience parsers are provided.
The parser can be enacted by calling the 'run' function:
myParser.run(on: "String to parse")
The unit tests provide examples of using the parser and creating your own parsing rules.
Pull requests for improvements are welcome.
There are no external requirements for this project, just Swift.
- iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 11+
- Swift 5.1+
For previous versions of Xcode and Swift please see prior releases.
Swift Package Manager
The Swift Package Manager is the official tool for managing the distribution of Swift code. It is currently available for all Apple platforms. It can also be used with Linux but this project does not fully support Linux at this point in time.
If you use it to manage your dependencies, simply add ParserCombinator to the dependencies value of your Package.swift file.
dependencies: [ .package(url: "https://github.com/Tigerpixel/ParserCombinator.git", from: "2.1.0") ]
ParserCombinator is available through CocoaPods. To install it, simply add the following line to your Podfile:
If you use Carthage to manage your dependencies, simply add the following line to your Cartfile:
If you use Carthage to build your dependencies, make sure you have added
ParserCombinator.framework to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.
- Add the ParserCombinator repository as a submodule of your application’s repository.
git submodule update --init --recursivefrom within the ParserCombinator folder.
- Drag and drop
ParserCombinator.xcodeprojinto your application’s Xcode project or workspace.
- On the “General” tab of your application target’s settings, add
ParserCombinator.framework. to the “Embedded Binaries” section.
- If your application target does not contain Swift code at all, you should also set the
EMBEDDED_CONTENT_CONTAINS_SWIFTbuild setting to “Yes”.
ParserCombinator is available under the MIT license. Details can be found within the LICENSE file.
You may find interesting
Swift 5.1 and Xcode 11 - 2019-09-30 21:00:06
Update to Swift Package Manager to make compatible with Swift 5.1. Added Swift Package Manager capabilities to all platforms. Updated Swift code to take advantage of Swift 5.1 features. Swiftlint version update to 0.35.0.
Swift 5 and Xcode 10.3 with SPM - 2019-08-20 22:07:16
Patch version to ensure that Swift Package Manager builds with the latest tools. Only required for Mac users building with SPM. It will not be sent to CocoaPods as it is not required by CocoaPods users.
Swift 5 and xcode 10.3 - 2019-08-17 23:49:36
Update build for Swift language version 5. Update the version of Xcode used to build the project to 10.3 Update the version of Swiftlint used to 0.34.0 Update to use native types, removing some type aliases for clarity. Remove some unnecessary string copies for efficiency.
Swift 4 and Xcode 9.0 - 2017-09-27 20:47:36
Update build for Swift language version 4. Update the version of Xcode used to build the project to 9.0 Update the version of Swiftlint used to 0.22.0 Add failure messages to all simple test failures.
Initial Release for Swift 3.1 - 2017-09-18 23:15:44
Initial release for Swift 3.1
Add Foundation imports to classes which use character sets.
Update to Swift 3.1 build with Xcode 8.3 - 2017-09-17 08:38:00
Update to Swift 3.1 build with Xcode 8.3 Changes to build files and documentation to update Swift and xcode versions. A small change to the precedence order of one operator.
Parser Combinator with docs and tests. - 2017-04-11 08:34:22
A basic Parser Combinator with documentation and tests.
A set of combinators. A set of convenience parsers. A set of operators.
See release notes for full details.