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 10.3+
- Swift 5.0+
For previous versions of Xcode and Swift please see prior releases.
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.
Swift Package Manager
The Swift Package Manager is the official tool for managing the distribution of Swift code. It is currently available for macOS. 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", majorVersion: 2) ]
- 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.
Help us keep the lights on
2.0.1 - Aug 20, 2019
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.
2.0.0 - Aug 17, 2019
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.
1.1.0 - Sep 27, 2017
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.
1.0.0 - Sep 18, 2017
Initial release for Swift 3.1
Add Foundation imports to classes which use character sets.
0.3.0 - Sep 17, 2017
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.