docs: Fix references to runtime.h, libruntime.a
This commit is contained in:
parent
743d18d956
commit
af44147157
1 changed files with 14 additions and 14 deletions
|
|
@ -5,33 +5,33 @@ permalink: using-parsers
|
|||
|
||||
# Using Parsers
|
||||
|
||||
All of Tree-sitter's parsing functionality is exposed through C APIs. Applications written in higher-level languages can use Tree-sitter via binding libraries like [node-tree-sitter](https://github.com/tree-sitter/node-tree-sitter) or [rust-tree-sitter](https://github.com/tree-sitter/rust-tree-sitter), which have their own documentation.
|
||||
All of Tree-sitter's parsing functionality is exposed through C APIs. Applications written in higher-level languages can use Tree-sitter via binding libraries like [node-tree-sitter](https://github.com/tree-sitter/node-tree-sitter) or [rust-tree-sitter](https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding), which have their own documentation.
|
||||
|
||||
This document will describes the general concepts of how to use Tree-sitter, which should be relevant regardless of what language you're using. It also goes into some C-specific details that are useful if you're using the C API directly or are building a new binding to a different language.
|
||||
|
||||
## Building the Runtime Library
|
||||
## Building the Library
|
||||
|
||||
Building the runtime library requires one git submodule: [`utf8proc`](https://github.com/JuliaStrings/utf8proc). Make sure that `utf8proc` is downloaded by running this command from the Tree-sitter directory:
|
||||
Building the library requires one git submodule: [`utf8proc`](https://github.com/JuliaStrings/utf8proc). Make sure that `utf8proc` is downloaded by running this command from the Tree-sitter directory:
|
||||
|
||||
```sh
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
To build the runtime library on a POSIX system, run this script, which will create a static library called `libruntime.a` in the Tree-sitter folder:
|
||||
To build the library on a POSIX system, run this script, which will create a static library called `libtree-sitter.a` in the Tree-sitter folder:
|
||||
|
||||
```sh
|
||||
script/build-runtime
|
||||
script/build-lib
|
||||
```
|
||||
|
||||
Alternatively, you can use the runtime library in a larger project by adding one source file to the project. This source file needs three directories to be in the include path when compiled:
|
||||
Alternatively, you can use the library in a larger project by adding one source file to the project. This source file needs three directories to be in the include path when compiled:
|
||||
|
||||
**source file:**
|
||||
* `tree-sitter/src/runtime/runtime.c`
|
||||
* `tree-sitter/lib/src/lib.c`
|
||||
|
||||
**include directories:**
|
||||
* `tree-sitter/src`
|
||||
* `tree-sitter/include`
|
||||
* `tree-sitter/externals/utf8proc`
|
||||
* `tree-sitter/lib/src`
|
||||
* `tree-sitter/lib/include`
|
||||
* `tree-sitter/lib/utf8proc`
|
||||
|
||||
## The Objects
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ Here's an example of a simple C program that uses the Tree-sitter [JSON parser](
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <tree_sitter/runtime.h>
|
||||
#include <tree_sitter/api.h>
|
||||
|
||||
// Declare the `tree_sitter_json` function, which is
|
||||
// implemented by the `tree-sitter-json` library.
|
||||
|
|
@ -103,14 +103,14 @@ int main() {
|
|||
}
|
||||
```
|
||||
|
||||
This program uses the Tree-sitter C API, which is declared in the header file `tree_sitter/runtime.h`, so we need to add the `tree_sitter/include` directory to the include path. We also need to link `libruntime.a` into the binary. We compile the source code of the JSON language directly into the binary as well.
|
||||
This program uses the Tree-sitter C API, which is declared in the header file `tree_sitter/api.h`, so we need to add the `tree_sitter/include` directory to the include path. We also need to link `libtree-sitter.a` into the binary. We compile the source code of the JSON language directly into the binary as well.
|
||||
|
||||
```sh
|
||||
clang \
|
||||
-I tree-sitter/include \
|
||||
test-json-parser.c \
|
||||
tree-sitter-json/src/parser.c \
|
||||
tree-sitter/libruntime.a \
|
||||
tree-sitter/libtree-sitter.a \
|
||||
-o test-json-parser
|
||||
|
||||
./test-json-parser
|
||||
|
|
@ -303,7 +303,7 @@ Conceptually, it can be represented by three syntax trees with overlapping range
|
|||
|
||||
```c
|
||||
#include <string.h>
|
||||
#include <tree_sitter/runtime.h>
|
||||
#include <tree_sitter/api.h>
|
||||
|
||||
// These functions are each implemented in their own repo.
|
||||
const TSLanguage *tree_sitter_embedded_template();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue