tree-sitter/docs/index.md

69 lines
3.5 KiB
Markdown
Raw Normal View History

2018-06-10 09:54:59 -07:00
---
title: Introduction
---
# Introduction
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:
2018-06-10 09:54:59 -07:00
* **General** enough to parse any programming language
2018-06-11 19:17:10 -07:00
* **Fast** enough to parse on every keystroke in a text editor
* **Robust** enough to provide useful results even in the presence of syntax errors
docs: merge of all binding and grammar link PRs Joined commit messages: --- Closes: #2048 docs: add capnp, smali, thrift Closes: #2026 Add Perl binding Closes: #1989 Add Ada to the list of available parsers Closes: #1980 Add clojure to list of available parsers After some discussion in https://github.com/sogaiu/tree-sitter-clojure/issues/28 I decided to submit an issue to the tree-sitter organization to include tree-sitter-clojure in their list of available parsers. This repository is used by a couple of editors and tools, and I am using it to build a tree-sitter based programming mode for Clojure in Emacs. Since there are a couple of tools that depend on it, it seems worthy of inclusion in an official list of tree-sitter grammars. Closes: #1943 Add meson grammar to list. Closes: #1926 docs(meson): add parse for meson add meson Closes: #1912 Merge branch 'master' into add-heex-parser Closes: #1908 Add Apex to available parsers Closes: #1876 Add tree-sitter-gleam to list of available parsers Closes: #1862 DOCS: Add entries various SQL flavor parsers Closes: #1857 Add Go to the available language bindings Closes: #1856 docs: add jq grammar Closes: #1828 Add tree sitter lalrpop This is a parser for https://github.com/lalrpop/lalrpop, a parser generator for use in Rust. It is still in development because it should support some kind of highlighting of the pseudo rust code used in rules. Closes: #1733 Add YANG parser to parser list I wrote this parser over summer vacation last year and I've been using it at work every day since. Closes: #1728 Add link to m68k grammar Link to m68k (Motorola 68000 assembly) grammar in docs. Closes: #1697 Added rego language Closes: #1694 docs: add Formula parser Closes: #1672 docs: Add link to QML (Qt UI spec/programming language) parser Closes: #1671 parser: add beancount parser link Closes: #1623 Add link to llvm grammars Add links to LLVM IR, MIR and TableGen parsers. Closes: #1579 Add my Smali parser to the WIP list Closes: #1575 Update index.md Closes: #1563 Add re2c and sort alphabetically Added re2c parser (lexer generator). Sorted the list alphabetically case-insensitively. Closes: #1209 add link to chess Portable Game Notation grammar Closes: #1176 Add tree-sitter-lean. Closes: #1123 Add parsers to list --- Co-authored-by: Amaan Qureshi <amaanq12@gmail.com> Co-authored-by: Felipe Gasper <FGasper@users.noreply.github.com> Co-authored-by: Emmanuel Briot <briot.emmanuel@gmail.com> Co-authored-by: Danny Freeman <dannyfreeman@users.noreply.github.com> Co-authored-by: Garrett D'Amore <garrett@damore.org> Co-authored-by: ShootingStarDragons <ShootingStarDragons@protonmail.com> Co-authored-by: Clay <connorlay@users.noreply.github.com> Co-authored-by: Anthony Heber <anthony@heber.dev> Co-authored-by: Jonathan Arnett <jonarnett90@gmail.com> Co-authored-by: takegue <takegue@gmail.com> Co-authored-by: Cédric Fabianski <cedric@bearer.sh> Co-authored-by: flurie <flurie@gmail.com> Co-authored-by: traxys <quentin+dev@familleboyer.net> Co-authored-by: Tomas Sandven <597206+Hubro@users.noreply.github.com> Co-authored-by: Graham Bates <info@grahambates.com> Co-authored-by: Lex <mr.x97@mail.ru> Co-authored-by: Ben Siraphob <bensiraphob@gmail.com> Co-authored-by: Yuya Nishihara <yuya@tcha.org> Co-authored-by: WeiZhang <kweizh@gmail.com> Co-authored-by: Flakebi <flakebi@t-online.de> Co-authored-by: Yotam <me@yotam.net> Co-authored-by: Fymyte <34305318+Fymyte@users.noreply.github.com> Co-authored-by: Alexandre A. Muller <muller@outlook.com> Co-authored-by: Roland Walker <walker@pobox.com> Co-authored-by: Julian Berman <Julian@GrayVines.com> Co-authored-by: Santos Gallegos <stsewd@protonmail.com>
2023-01-27 10:15:23 +02:00
* **Dependency-free** so that the runtime library (which is written in pure [C](https://github.com/tree-sitter/tree-sitter/tree/master/lib)) can be embedded in any application
2018-06-10 09:54:59 -07:00
### Language Bindings
There are currently bindings that allow Tree-sitter to be used from the following languages:
#### Official
* [C#](https://github.com/tree-sitter/csharp-tree-sitter)
* [Go](https://github.com/tree-sitter/go-tree-sitter)
* [Haskell](https://github.com/tree-sitter/haskell-tree-sitter)
* [Java (JDK 22)](https://github.com/tree-sitter/java-tree-sitter)
* [JavaScript (Node.js)](https://github.com/tree-sitter/node-tree-sitter)
* [JavaScript (Wasm)](https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_web)
* [Kotlin](https://github.com/tree-sitter/kotlin-tree-sitter)
* [Python](https://github.com/tree-sitter/py-tree-sitter)
* [Rust](https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_rust)
#### Third-party
* [Delphi](https://github.com/modersohn/delphi-tree-sitter)
* [ELisp](https://github.com/emacs-tree-sitter/elisp-tree-sitter)
* [Go](https://github.com/smacker/go-tree-sitter)
* [Guile](https://github.com/Z572/guile-ts)
* [Java (Android)](https://github.com/AndroidIDEOfficial/android-tree-sitter)
* [Java (JDK 8+)](https://github.com/bonede/tree-sitter-ng)
* [Java (JDK 11+)](https://github.com/seart-group/java-tree-sitter)
* [Julia](https://github.com/MichaelHatherly/TreeSitter.jl)
2021-11-19 13:58:46 -08:00
* [Lua](https://github.com/euclidianAce/ltreesitter)
* [Lua](https://github.com/xcb-xwii/lua-tree-sitter)
* [OCaml](https://github.com/semgrep/ocaml-tree-sitter-core)
* [Odin](https://github.com/laytan/odin-tree-sitter)
docs: merge of all binding and grammar link PRs Joined commit messages: --- Closes: #2048 docs: add capnp, smali, thrift Closes: #2026 Add Perl binding Closes: #1989 Add Ada to the list of available parsers Closes: #1980 Add clojure to list of available parsers After some discussion in https://github.com/sogaiu/tree-sitter-clojure/issues/28 I decided to submit an issue to the tree-sitter organization to include tree-sitter-clojure in their list of available parsers. This repository is used by a couple of editors and tools, and I am using it to build a tree-sitter based programming mode for Clojure in Emacs. Since there are a couple of tools that depend on it, it seems worthy of inclusion in an official list of tree-sitter grammars. Closes: #1943 Add meson grammar to list. Closes: #1926 docs(meson): add parse for meson add meson Closes: #1912 Merge branch 'master' into add-heex-parser Closes: #1908 Add Apex to available parsers Closes: #1876 Add tree-sitter-gleam to list of available parsers Closes: #1862 DOCS: Add entries various SQL flavor parsers Closes: #1857 Add Go to the available language bindings Closes: #1856 docs: add jq grammar Closes: #1828 Add tree sitter lalrpop This is a parser for https://github.com/lalrpop/lalrpop, a parser generator for use in Rust. It is still in development because it should support some kind of highlighting of the pseudo rust code used in rules. Closes: #1733 Add YANG parser to parser list I wrote this parser over summer vacation last year and I've been using it at work every day since. Closes: #1728 Add link to m68k grammar Link to m68k (Motorola 68000 assembly) grammar in docs. Closes: #1697 Added rego language Closes: #1694 docs: add Formula parser Closes: #1672 docs: Add link to QML (Qt UI spec/programming language) parser Closes: #1671 parser: add beancount parser link Closes: #1623 Add link to llvm grammars Add links to LLVM IR, MIR and TableGen parsers. Closes: #1579 Add my Smali parser to the WIP list Closes: #1575 Update index.md Closes: #1563 Add re2c and sort alphabetically Added re2c parser (lexer generator). Sorted the list alphabetically case-insensitively. Closes: #1209 add link to chess Portable Game Notation grammar Closes: #1176 Add tree-sitter-lean. Closes: #1123 Add parsers to list --- Co-authored-by: Amaan Qureshi <amaanq12@gmail.com> Co-authored-by: Felipe Gasper <FGasper@users.noreply.github.com> Co-authored-by: Emmanuel Briot <briot.emmanuel@gmail.com> Co-authored-by: Danny Freeman <dannyfreeman@users.noreply.github.com> Co-authored-by: Garrett D'Amore <garrett@damore.org> Co-authored-by: ShootingStarDragons <ShootingStarDragons@protonmail.com> Co-authored-by: Clay <connorlay@users.noreply.github.com> Co-authored-by: Anthony Heber <anthony@heber.dev> Co-authored-by: Jonathan Arnett <jonarnett90@gmail.com> Co-authored-by: takegue <takegue@gmail.com> Co-authored-by: Cédric Fabianski <cedric@bearer.sh> Co-authored-by: flurie <flurie@gmail.com> Co-authored-by: traxys <quentin+dev@familleboyer.net> Co-authored-by: Tomas Sandven <597206+Hubro@users.noreply.github.com> Co-authored-by: Graham Bates <info@grahambates.com> Co-authored-by: Lex <mr.x97@mail.ru> Co-authored-by: Ben Siraphob <bensiraphob@gmail.com> Co-authored-by: Yuya Nishihara <yuya@tcha.org> Co-authored-by: WeiZhang <kweizh@gmail.com> Co-authored-by: Flakebi <flakebi@t-online.de> Co-authored-by: Yotam <me@yotam.net> Co-authored-by: Fymyte <34305318+Fymyte@users.noreply.github.com> Co-authored-by: Alexandre A. Muller <muller@outlook.com> Co-authored-by: Roland Walker <walker@pobox.com> Co-authored-by: Julian Berman <Julian@GrayVines.com> Co-authored-by: Santos Gallegos <stsewd@protonmail.com>
2023-01-27 10:15:23 +02:00
* [Perl](https://metacpan.org/pod/Text::Treesitter)
* [R](https://github.com/DavisVaughan/r-tree-sitter)
* [Ruby](https://github.com/Faveod/ruby-tree-sitter)
2021-11-17 11:30:32 -05:00
* [Swift](https://github.com/ChimeHQ/SwiftTreeSitter)
2018-06-10 09:54:59 -07:00
### Parsers
2018-06-10 09:54:59 -07:00
A list of known parsers can be found in the [wiki](https://github.com/tree-sitter/tree-sitter/wiki/List-of-parsers).
2018-06-10 09:54:59 -07:00
### Talks on Tree-sitter
* [Strange Loop 2018](https://www.thestrangeloop.com/2018/tree-sitter---a-new-parsing-system-for-programming-tools.html)
2018-06-10 09:54:59 -07:00
* [FOSDEM 2018](https://www.youtube.com/watch?v=0CGzC_iss-8)
* [GitHub Universe 2017](https://www.youtube.com/watch?v=a1rC79DHpmY)
2018-06-11 19:17:10 -07:00
### Underlying Research
The design of Tree-sitter was greatly influenced by the following research papers:
* [Practical Algorithms for Incremental Software Development Environments](https://www2.eecs.berkeley.edu/Pubs/TechRpts/1997/CSD-97-946.pdf)
* [Context Aware Scanning for Parsing Extensible Languages](https://www-users.cse.umn.edu/~evw/pubs/vanwyk07gpce/vanwyk07gpce.pdf)
* [Efficient and Flexible Incremental Parsing](https://harmonia.cs.berkeley.edu/papers/twagner-parsing.pdf)
* [Incremental Analysis of Real Programming Languages](https://harmonia.cs.berkeley.edu/papers/twagner-glr.pdf)
* [Error Detection and Recovery in LR Parsers](https://what-when-how.com/compiler-writing/bottom-up-parsing-compiler-writing-part-13)
* [Error Recovery for LR Parsers](https://apps.dtic.mil/sti/pdfs/ADA043470.pdf)