A Swift parser combinator framework.
Extracted from InterfaCSS, originally inspired by Parcoa.
The simplest way is to use CocoaPods.
pod 'Parsicle'
Support for Swift Package Manager is also on the way...
let parsicle = Parsicles.sequential([
.string("Hello"),
.spaces(1),
.string("World"),
.spaces(1),
.choice([
.char("π€―"),
.char("π"),
.char("π©"),
]),
])
if parsicle.matches("Hello World π€―") {
print("π")
}
Example using Swift function builder syntax
Sequential {
"Hello"
Spaces(1)
"World"
Spaces()
Choice {
"π€―"
"π"
"π©"
}
}
See unit tests for more concrete examples: ParsicleTests.swift
MIT license - see here.