Skip to content

Swift Package for Tree Sitter, an incremental parsing system for programming tools

License

Notifications You must be signed in to change notification settings

unsignedapps/swift-tree-sitter

 
 

Repository files navigation

tree-sitter

Build Status Build status

Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited. Tree-sitter aims to be:

  • General enough to parse any programming language
  • Fast enough to parse on every keystroke in a text editor
  • Robust enough to provide useful results even in the presence of syntax errors
  • Dependency-free so that the runtime library (which is written in pure C) can be embedded in any application

Documentation

Swift Wrapper

This fork of tree-sitter comes with a minimal Swift Wrapper thats designed to incorporate Swift conventions while staying out of the way of the fast C library underneath.

Documentation is copied from the C library where possible but there are a number of gaps. Consult lib/include/tree_sitter/api.h and the C source in lib/src/ for accurate information on how things work.

Installation

To include swift-tree-sitter in your Swift package add the following dependency to your Package.swift:

.package(url: "https://github.com/unsignedapps/swift-tree-sitter.git", from: "0.16.5.1")

Note: The first version that has Swift Package Manager support is 0.16.5.1.

Don't forget to include the library in your target:

.target(name: "BestExampleApp", dependencies: [ "TreeSitter" ])

And import the module in your code:

import Foundation
import TreeSitter

TODO

This is a partial wrapper. Some things still to be done:

  • Unit Tests
  • Logging
  • DOT graphs

Links

About

Swift Package for Tree Sitter, an incremental parsing system for programming tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 63.3%
  • C 25.1%
  • JavaScript 6.0%
  • Swift 2.8%
  • C++ 1.2%
  • Shell 1.1%
  • Other 0.5%