Swiftpack.co - Package - SwiftStudies/OysterKit


| | Status| | --------- | :-----| | Linux/macOS/iOS/tvOS | Build Status | | Test Coverage | codecov | | Documentation Coverage | 97% |

OysterKit enables native Swift scanning, lexical analysis, and parsing capabilities as a pure Swift framework. Two additional elements are also provided in this package. The first is a second framework STLR which uses OysterKit to provide a plain text grammar specification language called STLR (Swift Tool for Language Recognition). Finally a command line tool, stlr can be used to automatically generate Swift source code for OysterKit for STLR grammars, as well as dynamically apply STLR grammars to a number of use-cases. The following documentation is available:

Key Features

  • OysterKit Provides support for scanning strings
    • Fully supports direct and indirect left hand recursion in rules
    • Provides support for parsing strings using defined rules as streams of tokens or constructing Abstract Syntax Trees (ASTs)
    • All of the above provided as implementations of protocols allowing the replacement of any by your own components if you wish
    • Create your own file decoders (using Swift 4's Encoding/Decoding framework Encodable and Decodable)
  • STLR Provides support for defining scanning (terminal) and parsing rules
    • A lexical analysis and parser definition language, STLR, which can be compiled at run-time in memory, or from stored files
    • Complied STLR can be used immediately at run time, or through the generation of a Swift source file


  • All tests are passing

For those that used v1.0 there are significant performance and capability benefits of moving to v2. I have not yet built an OKScript translator, but that could quite easily be done if there is demand.


Stars: 113
Help us keep the lights on



v0.3.0-beta - Feb 6, 2018

This is a significant release. The API and underlying implementation have been replaced significantly simplifying both.

The remainder of the releases up to v1.0 will now focus on stabilising the STLR language itself (not bugs, but ensuring there is a solid base to build on in future releases, and that any grammar breaking changes are minimised (I am not aware of any that are required at this point, but I will leave the door open)

0.2.0 - Feb 4, 2018

The overly complex API for streams, homogenous, and heterogenous abstract syntax trees are replaced by a much simpler & smaller yet equally configurable set of classes.

You should refer to TokenStream and AbstractSyntaxTreeConstructor for more information.

Deprecation warnings will be issued for use of the previous classes, and support for these will be removed most likely by 0.3 when internal dependencies on the legacy types has been resolved.

In addition there are numerous fixes, although all of these are available only in the new APIs and have not been applied to the legacy ones.

0.1.4 - Jan 26, 2018

Refactored repository to break out STLR into it's own framework and also include the stlr command line tool

0.1.3 - Jan 19, 2018

The focus of this release has been getting the API documentation off the ground. I have also added a substantial tutorial demonstrating many of the standard OysterKit features including STLR, Swift Code Generation, automatic Parser Decoding (Using the Swift 4.0 Decoding features), stlr command line processing, and off course some standard Swift.

In the next interim release there will be some code breaking changes as I break out STLR and it attendant parsing from OysterKit itself. I also intend to remerge the stlr command line product back into this package as well as integrating the tutorial repositories to make it easier to get up and running with OysterKit.

0.1.2 - Jan 15, 2018

This release fixes a few issues, most importantly an issue that stopped consumers using dynamically generated languages.