tolo / Parsicle

A Swift parser combinator framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsicle

Parsicle logo

A Swift parser combinator framework.

Extracted from InterfaCSS, originally inspired by Parcoa.

Getting started

Install

The simplest way is to use CocoaPods.

pod 'Parsicle'

Support for Swift Package Manager is also on the way...

Examples

Simple example with sequential parser

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 {
    "🀯"
    "😍"
    "πŸ’©"
  }
}

More

See unit tests for more concrete examples: ParsicleTests.swift

License

MIT license - see here.

About

A Swift parser combinator framework

License:MIT License


Languages

Language:Swift 98.9%Language:Ruby 1.1%