tree-sitter-containerfile 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tree_sitter_containerfile-0.3.1/LICENSE +21 -0
- tree_sitter_containerfile-0.3.1/LICENSE-MIT-CamdenCheek +21 -0
- tree_sitter_containerfile-0.3.1/PKG-INFO +151 -0
- tree_sitter_containerfile-0.3.1/README.md +131 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile/__init__.py +40 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile/__init__.pyi +17 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile/binding.c +35 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile/py.typed +1 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/PKG-INFO +151 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/SOURCES.txt +16 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/dependency_links.txt +1 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/not-zip-safe +1 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/requires.txt +3 -0
- tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/top_level.txt +2 -0
- tree_sitter_containerfile-0.3.1/pyproject.toml +29 -0
- tree_sitter_containerfile-0.3.1/queries/highlights.scm +58 -0
- tree_sitter_containerfile-0.3.1/setup.cfg +4 -0
- tree_sitter_containerfile-0.3.1/setup.py +83 -0
- tree_sitter_containerfile-0.3.1/src/parser.c +12680 -0
- tree_sitter_containerfile-0.3.1/src/scanner.c +330 -0
- tree_sitter_containerfile-0.3.1/src/tree_sitter/alloc.h +54 -0
- tree_sitter_containerfile-0.3.1/src/tree_sitter/array.h +330 -0
- tree_sitter_containerfile-0.3.1/src/tree_sitter/parser.h +286 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WharfLab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Camden Cheek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-containerfile
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A Containerfile and Dockerfile grammar for tree-sitter
|
|
5
|
+
Author: WharfLab
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/wharflab/tree-sitter-containerfile
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,containerfile,dockerfile
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: LICENSE-MIT-CamdenCheek
|
|
17
|
+
Provides-Extra: core
|
|
18
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# tree-sitter-containerfile
|
|
22
|
+
|
|
23
|
+
A maintained Containerfile and Dockerfile grammar for [tree-sitter](https://tree-sitter.github.io/).
|
|
24
|
+
|
|
25
|
+
This project is intended to be a reliable, actively maintained grammar for
|
|
26
|
+
modern container build files, with published packages and generated bindings
|
|
27
|
+
for Node.js, Python, Rust, Go, Swift, and C.
|
|
28
|
+
|
|
29
|
+
## Why This Package
|
|
30
|
+
|
|
31
|
+
Containerfile and Dockerfile syntax continues to evolve across Docker,
|
|
32
|
+
BuildKit, Podman, and related tooling. This grammar aims to close the gap for
|
|
33
|
+
modern Dockerfile features, keep real-world fixtures parsing cleanly, and ship
|
|
34
|
+
usable packages across the common tree-sitter binding ecosystems.
|
|
35
|
+
|
|
36
|
+
The historical `tree-sitter-dockerfile` npm package is not a dependable
|
|
37
|
+
installation target: it currently resolves to a `0.0.1-security` placeholder
|
|
38
|
+
release. `tree-sitter-containerfile` is the maintained package name for this
|
|
39
|
+
grammar and its generated artifacts.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
### npm
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm install tree-sitter-containerfile
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### PyPI
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pip install tree-sitter-containerfile
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Cargo
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
cargo add tree-sitter-containerfile
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Go
|
|
62
|
+
|
|
63
|
+
```go
|
|
64
|
+
import containerfile "github.com/wharflab/tree-sitter-containerfile"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
### Node.js
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
import Parser from "tree-sitter";
|
|
73
|
+
import Containerfile from "tree-sitter-containerfile";
|
|
74
|
+
|
|
75
|
+
const parser = new Parser();
|
|
76
|
+
parser.setLanguage(Containerfile);
|
|
77
|
+
|
|
78
|
+
const tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n");
|
|
79
|
+
console.log(tree.rootNode.toString());
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Python
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from tree_sitter import Language, Parser
|
|
86
|
+
import tree_sitter_containerfile
|
|
87
|
+
|
|
88
|
+
parser = Parser(Language(tree_sitter_containerfile.language()))
|
|
89
|
+
tree = parser.parse(b"FROM alpine:3.20\nRUN echo ok\n")
|
|
90
|
+
print(tree.root_node.sexp())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Rust
|
|
94
|
+
|
|
95
|
+
```rust
|
|
96
|
+
let mut parser = tree_sitter::Parser::new();
|
|
97
|
+
let language = tree_sitter_containerfile::LANGUAGE;
|
|
98
|
+
parser.set_language(&language.into()).unwrap();
|
|
99
|
+
|
|
100
|
+
let tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n", None).unwrap();
|
|
101
|
+
println!("{}", tree.root_node().to_sexp());
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Go
|
|
105
|
+
|
|
106
|
+
```go
|
|
107
|
+
package main
|
|
108
|
+
|
|
109
|
+
import (
|
|
110
|
+
"fmt"
|
|
111
|
+
|
|
112
|
+
sitter "github.com/tree-sitter/go-tree-sitter"
|
|
113
|
+
containerfile "github.com/wharflab/tree-sitter-containerfile"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
func main() {
|
|
117
|
+
parser := sitter.NewParser()
|
|
118
|
+
defer parser.Close()
|
|
119
|
+
|
|
120
|
+
_ = parser.SetLanguage(containerfile.GetLanguage())
|
|
121
|
+
tree := parser.Parse([]byte("FROM alpine:3.20\nRUN echo ok\n"), nil)
|
|
122
|
+
defer tree.Close()
|
|
123
|
+
|
|
124
|
+
fmt.Println(tree.RootNode().ToSexp())
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
npm ci
|
|
132
|
+
npm run generate
|
|
133
|
+
tree-sitter test
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The test suite includes the upstream corpus and integration parsing of the
|
|
137
|
+
real-world Containerfile fixtures in `examples/`.
|
|
138
|
+
|
|
139
|
+
## Credits
|
|
140
|
+
|
|
141
|
+
This grammar started from
|
|
142
|
+
[`camdencheek/tree-sitter-dockerfile`](https://github.com/camdencheek/tree-sitter-dockerfile).
|
|
143
|
+
The project is being maintained and extended here under the
|
|
144
|
+
`tree-sitter-containerfile` package name.
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
Licensed under [MIT](LICENSE).
|
|
149
|
+
|
|
150
|
+
The original MIT notice for the upstream grammar and fixtures is preserved in
|
|
151
|
+
[LICENSE-MIT-CamdenCheek](LICENSE-MIT-CamdenCheek).
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# tree-sitter-containerfile
|
|
2
|
+
|
|
3
|
+
A maintained Containerfile and Dockerfile grammar for [tree-sitter](https://tree-sitter.github.io/).
|
|
4
|
+
|
|
5
|
+
This project is intended to be a reliable, actively maintained grammar for
|
|
6
|
+
modern container build files, with published packages and generated bindings
|
|
7
|
+
for Node.js, Python, Rust, Go, Swift, and C.
|
|
8
|
+
|
|
9
|
+
## Why This Package
|
|
10
|
+
|
|
11
|
+
Containerfile and Dockerfile syntax continues to evolve across Docker,
|
|
12
|
+
BuildKit, Podman, and related tooling. This grammar aims to close the gap for
|
|
13
|
+
modern Dockerfile features, keep real-world fixtures parsing cleanly, and ship
|
|
14
|
+
usable packages across the common tree-sitter binding ecosystems.
|
|
15
|
+
|
|
16
|
+
The historical `tree-sitter-dockerfile` npm package is not a dependable
|
|
17
|
+
installation target: it currently resolves to a `0.0.1-security` placeholder
|
|
18
|
+
release. `tree-sitter-containerfile` is the maintained package name for this
|
|
19
|
+
grammar and its generated artifacts.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### npm
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install tree-sitter-containerfile
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### PyPI
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pip install tree-sitter-containerfile
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Cargo
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
cargo add tree-sitter-containerfile
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Go
|
|
42
|
+
|
|
43
|
+
```go
|
|
44
|
+
import containerfile "github.com/wharflab/tree-sitter-containerfile"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### Node.js
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import Parser from "tree-sitter";
|
|
53
|
+
import Containerfile from "tree-sitter-containerfile";
|
|
54
|
+
|
|
55
|
+
const parser = new Parser();
|
|
56
|
+
parser.setLanguage(Containerfile);
|
|
57
|
+
|
|
58
|
+
const tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n");
|
|
59
|
+
console.log(tree.rootNode.toString());
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Python
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from tree_sitter import Language, Parser
|
|
66
|
+
import tree_sitter_containerfile
|
|
67
|
+
|
|
68
|
+
parser = Parser(Language(tree_sitter_containerfile.language()))
|
|
69
|
+
tree = parser.parse(b"FROM alpine:3.20\nRUN echo ok\n")
|
|
70
|
+
print(tree.root_node.sexp())
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Rust
|
|
74
|
+
|
|
75
|
+
```rust
|
|
76
|
+
let mut parser = tree_sitter::Parser::new();
|
|
77
|
+
let language = tree_sitter_containerfile::LANGUAGE;
|
|
78
|
+
parser.set_language(&language.into()).unwrap();
|
|
79
|
+
|
|
80
|
+
let tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n", None).unwrap();
|
|
81
|
+
println!("{}", tree.root_node().to_sexp());
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Go
|
|
85
|
+
|
|
86
|
+
```go
|
|
87
|
+
package main
|
|
88
|
+
|
|
89
|
+
import (
|
|
90
|
+
"fmt"
|
|
91
|
+
|
|
92
|
+
sitter "github.com/tree-sitter/go-tree-sitter"
|
|
93
|
+
containerfile "github.com/wharflab/tree-sitter-containerfile"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
func main() {
|
|
97
|
+
parser := sitter.NewParser()
|
|
98
|
+
defer parser.Close()
|
|
99
|
+
|
|
100
|
+
_ = parser.SetLanguage(containerfile.GetLanguage())
|
|
101
|
+
tree := parser.Parse([]byte("FROM alpine:3.20\nRUN echo ok\n"), nil)
|
|
102
|
+
defer tree.Close()
|
|
103
|
+
|
|
104
|
+
fmt.Println(tree.RootNode().ToSexp())
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
npm ci
|
|
112
|
+
npm run generate
|
|
113
|
+
tree-sitter test
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The test suite includes the upstream corpus and integration parsing of the
|
|
117
|
+
real-world Containerfile fixtures in `examples/`.
|
|
118
|
+
|
|
119
|
+
## Credits
|
|
120
|
+
|
|
121
|
+
This grammar started from
|
|
122
|
+
[`camdencheek/tree-sitter-dockerfile`](https://github.com/camdencheek/tree-sitter-dockerfile).
|
|
123
|
+
The project is being maintained and extended here under the
|
|
124
|
+
`tree-sitter-containerfile` package name.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Licensed under [MIT](LICENSE).
|
|
129
|
+
|
|
130
|
+
The original MIT notice for the upstream grammar and fixtures is preserved in
|
|
131
|
+
[LICENSE-MIT-CamdenCheek](LICENSE-MIT-CamdenCheek).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
""""""
|
|
2
|
+
|
|
3
|
+
from importlib.resources import files as _files
|
|
4
|
+
|
|
5
|
+
from ._binding import language
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _get_query(name, file):
|
|
9
|
+
query = _files(f"{__package__}.queries") / file
|
|
10
|
+
globals()[name] = query.read_text()
|
|
11
|
+
return globals()[name]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def __getattr__(name):
|
|
15
|
+
if name == "HIGHLIGHTS_QUERY":
|
|
16
|
+
return _get_query("HIGHLIGHTS_QUERY", "highlights.scm")
|
|
17
|
+
# if name == "INJECTIONS_QUERY":
|
|
18
|
+
# return _get_query("INJECTIONS_QUERY", "injections.scm")
|
|
19
|
+
# if name == "LOCALS_QUERY":
|
|
20
|
+
# return _get_query("LOCALS_QUERY", "locals.scm")
|
|
21
|
+
# if name == "TAGS_QUERY":
|
|
22
|
+
# return _get_query("TAGS_QUERY", "tags.scm")
|
|
23
|
+
|
|
24
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"language",
|
|
29
|
+
"HIGHLIGHTS_QUERY",
|
|
30
|
+
# "INJECTIONS_QUERY",
|
|
31
|
+
# "LOCALS_QUERY",
|
|
32
|
+
# "TAGS_QUERY",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __dir__():
|
|
37
|
+
return sorted(__all__ + [
|
|
38
|
+
"__all__", "__builtins__", "__cached__", "__doc__", "__file__",
|
|
39
|
+
"__loader__", "__name__", "__package__", "__path__", "__spec__",
|
|
40
|
+
])
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Final
|
|
2
|
+
from typing_extensions import CapsuleType
|
|
3
|
+
|
|
4
|
+
HIGHLIGHTS_QUERY: Final[str] | None
|
|
5
|
+
"""The syntax highlighting query for this grammar."""
|
|
6
|
+
|
|
7
|
+
INJECTIONS_QUERY: Final[str] | None
|
|
8
|
+
"""The language injection query for this grammar."""
|
|
9
|
+
|
|
10
|
+
LOCALS_QUERY: Final[str] | None
|
|
11
|
+
"""The local variable query for this grammar."""
|
|
12
|
+
|
|
13
|
+
TAGS_QUERY: Final[str] | None
|
|
14
|
+
"""The symbol tagging query for this grammar."""
|
|
15
|
+
|
|
16
|
+
def language() -> CapsuleType:
|
|
17
|
+
"""The tree-sitter language function for this grammar."""
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include <Python.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
TSLanguage *tree_sitter_containerfile(void);
|
|
6
|
+
|
|
7
|
+
static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) {
|
|
8
|
+
return PyCapsule_New(tree_sitter_containerfile(), "tree_sitter.Language", NULL);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static struct PyModuleDef_Slot slots[] = {
|
|
12
|
+
#ifdef Py_GIL_DISABLED
|
|
13
|
+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
|
14
|
+
#endif
|
|
15
|
+
{0, NULL}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
static PyMethodDef methods[] = {
|
|
19
|
+
{"language", _binding_language, METH_NOARGS,
|
|
20
|
+
"Get the tree-sitter language for this grammar."},
|
|
21
|
+
{NULL, NULL, 0, NULL}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
static struct PyModuleDef module = {
|
|
25
|
+
.m_base = PyModuleDef_HEAD_INIT,
|
|
26
|
+
.m_name = "_binding",
|
|
27
|
+
.m_doc = NULL,
|
|
28
|
+
.m_size = 0,
|
|
29
|
+
.m_methods = methods,
|
|
30
|
+
.m_slots = slots,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
PyMODINIT_FUNC PyInit__binding(void) {
|
|
34
|
+
return PyModuleDef_Init(&module);
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tree-sitter-containerfile
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A Containerfile and Dockerfile grammar for tree-sitter
|
|
5
|
+
Author: WharfLab
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/wharflab/tree-sitter-containerfile
|
|
8
|
+
Keywords: incremental,parsing,tree-sitter,containerfile,dockerfile
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: LICENSE-MIT-CamdenCheek
|
|
17
|
+
Provides-Extra: core
|
|
18
|
+
Requires-Dist: tree-sitter~=0.24; extra == "core"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# tree-sitter-containerfile
|
|
22
|
+
|
|
23
|
+
A maintained Containerfile and Dockerfile grammar for [tree-sitter](https://tree-sitter.github.io/).
|
|
24
|
+
|
|
25
|
+
This project is intended to be a reliable, actively maintained grammar for
|
|
26
|
+
modern container build files, with published packages and generated bindings
|
|
27
|
+
for Node.js, Python, Rust, Go, Swift, and C.
|
|
28
|
+
|
|
29
|
+
## Why This Package
|
|
30
|
+
|
|
31
|
+
Containerfile and Dockerfile syntax continues to evolve across Docker,
|
|
32
|
+
BuildKit, Podman, and related tooling. This grammar aims to close the gap for
|
|
33
|
+
modern Dockerfile features, keep real-world fixtures parsing cleanly, and ship
|
|
34
|
+
usable packages across the common tree-sitter binding ecosystems.
|
|
35
|
+
|
|
36
|
+
The historical `tree-sitter-dockerfile` npm package is not a dependable
|
|
37
|
+
installation target: it currently resolves to a `0.0.1-security` placeholder
|
|
38
|
+
release. `tree-sitter-containerfile` is the maintained package name for this
|
|
39
|
+
grammar and its generated artifacts.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
### npm
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm install tree-sitter-containerfile
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### PyPI
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pip install tree-sitter-containerfile
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Cargo
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
cargo add tree-sitter-containerfile
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Go
|
|
62
|
+
|
|
63
|
+
```go
|
|
64
|
+
import containerfile "github.com/wharflab/tree-sitter-containerfile"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
### Node.js
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
import Parser from "tree-sitter";
|
|
73
|
+
import Containerfile from "tree-sitter-containerfile";
|
|
74
|
+
|
|
75
|
+
const parser = new Parser();
|
|
76
|
+
parser.setLanguage(Containerfile);
|
|
77
|
+
|
|
78
|
+
const tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n");
|
|
79
|
+
console.log(tree.rootNode.toString());
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Python
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from tree_sitter import Language, Parser
|
|
86
|
+
import tree_sitter_containerfile
|
|
87
|
+
|
|
88
|
+
parser = Parser(Language(tree_sitter_containerfile.language()))
|
|
89
|
+
tree = parser.parse(b"FROM alpine:3.20\nRUN echo ok\n")
|
|
90
|
+
print(tree.root_node.sexp())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Rust
|
|
94
|
+
|
|
95
|
+
```rust
|
|
96
|
+
let mut parser = tree_sitter::Parser::new();
|
|
97
|
+
let language = tree_sitter_containerfile::LANGUAGE;
|
|
98
|
+
parser.set_language(&language.into()).unwrap();
|
|
99
|
+
|
|
100
|
+
let tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n", None).unwrap();
|
|
101
|
+
println!("{}", tree.root_node().to_sexp());
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Go
|
|
105
|
+
|
|
106
|
+
```go
|
|
107
|
+
package main
|
|
108
|
+
|
|
109
|
+
import (
|
|
110
|
+
"fmt"
|
|
111
|
+
|
|
112
|
+
sitter "github.com/tree-sitter/go-tree-sitter"
|
|
113
|
+
containerfile "github.com/wharflab/tree-sitter-containerfile"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
func main() {
|
|
117
|
+
parser := sitter.NewParser()
|
|
118
|
+
defer parser.Close()
|
|
119
|
+
|
|
120
|
+
_ = parser.SetLanguage(containerfile.GetLanguage())
|
|
121
|
+
tree := parser.Parse([]byte("FROM alpine:3.20\nRUN echo ok\n"), nil)
|
|
122
|
+
defer tree.Close()
|
|
123
|
+
|
|
124
|
+
fmt.Println(tree.RootNode().ToSexp())
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
npm ci
|
|
132
|
+
npm run generate
|
|
133
|
+
tree-sitter test
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The test suite includes the upstream corpus and integration parsing of the
|
|
137
|
+
real-world Containerfile fixtures in `examples/`.
|
|
138
|
+
|
|
139
|
+
## Credits
|
|
140
|
+
|
|
141
|
+
This grammar started from
|
|
142
|
+
[`camdencheek/tree-sitter-dockerfile`](https://github.com/camdencheek/tree-sitter-dockerfile).
|
|
143
|
+
The project is being maintained and extended here under the
|
|
144
|
+
`tree-sitter-containerfile` package name.
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
Licensed under [MIT](LICENSE).
|
|
149
|
+
|
|
150
|
+
The original MIT notice for the upstream grammar and fixtures is preserved in
|
|
151
|
+
[LICENSE-MIT-CamdenCheek](LICENSE-MIT-CamdenCheek).
|
tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
LICENSE-MIT-CamdenCheek
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
bindings/python/tree_sitter_containerfile/__init__.py
|
|
7
|
+
bindings/python/tree_sitter_containerfile/__init__.pyi
|
|
8
|
+
bindings/python/tree_sitter_containerfile/binding.c
|
|
9
|
+
bindings/python/tree_sitter_containerfile/py.typed
|
|
10
|
+
bindings/python/tree_sitter_containerfile.egg-info/PKG-INFO
|
|
11
|
+
bindings/python/tree_sitter_containerfile.egg-info/SOURCES.txt
|
|
12
|
+
bindings/python/tree_sitter_containerfile.egg-info/dependency_links.txt
|
|
13
|
+
bindings/python/tree_sitter_containerfile.egg-info/not-zip-safe
|
|
14
|
+
bindings/python/tree_sitter_containerfile.egg-info/requires.txt
|
|
15
|
+
bindings/python/tree_sitter_containerfile.egg-info/top_level.txt
|
|
16
|
+
src/parser.c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
tree_sitter_containerfile-0.3.1/bindings/python/tree_sitter_containerfile.egg-info/not-zip-safe
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=80"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tree-sitter-containerfile"
|
|
7
|
+
description = "A Containerfile and Dockerfile grammar for tree-sitter"
|
|
8
|
+
dynamic = ["version"]
|
|
9
|
+
keywords = ["incremental", "parsing", "tree-sitter", "containerfile", "dockerfile"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Topic :: Software Development :: Compilers",
|
|
13
|
+
"Topic :: Text Processing :: Linguistic",
|
|
14
|
+
"Typing :: Typed",
|
|
15
|
+
]
|
|
16
|
+
authors = [{ name = "WharfLab" }]
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
license = "MIT"
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/wharflab/tree-sitter-containerfile"
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
core = ["tree-sitter~=0.24"]
|
|
26
|
+
|
|
27
|
+
[tool.cibuildwheel]
|
|
28
|
+
build = "cp3{10,11,12,13}-*"
|
|
29
|
+
build-frontend = "build"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[
|
|
2
|
+
"FROM"
|
|
3
|
+
"AS"
|
|
4
|
+
"RUN"
|
|
5
|
+
"CMD"
|
|
6
|
+
"LABEL"
|
|
7
|
+
"EXPOSE"
|
|
8
|
+
"ENV"
|
|
9
|
+
"ADD"
|
|
10
|
+
"COPY"
|
|
11
|
+
"ENTRYPOINT"
|
|
12
|
+
"VOLUME"
|
|
13
|
+
"USER"
|
|
14
|
+
"WORKDIR"
|
|
15
|
+
"ARG"
|
|
16
|
+
"ONBUILD"
|
|
17
|
+
"STOPSIGNAL"
|
|
18
|
+
"HEALTHCHECK"
|
|
19
|
+
"SHELL"
|
|
20
|
+
"MAINTAINER"
|
|
21
|
+
"CROSS_BUILD"
|
|
22
|
+
(heredoc_marker)
|
|
23
|
+
(heredoc_end)
|
|
24
|
+
] @keyword
|
|
25
|
+
|
|
26
|
+
[
|
|
27
|
+
":"
|
|
28
|
+
"@"
|
|
29
|
+
] @operator
|
|
30
|
+
|
|
31
|
+
(comment) @comment
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
(image_spec
|
|
35
|
+
(image_tag
|
|
36
|
+
":" @punctuation.special)
|
|
37
|
+
(image_digest
|
|
38
|
+
"@" @punctuation.special))
|
|
39
|
+
|
|
40
|
+
[
|
|
41
|
+
(double_quoted_string)
|
|
42
|
+
(single_quoted_string)
|
|
43
|
+
(json_string)
|
|
44
|
+
(heredoc_line)
|
|
45
|
+
] @string
|
|
46
|
+
|
|
47
|
+
(expansion
|
|
48
|
+
[
|
|
49
|
+
"$"
|
|
50
|
+
"{"
|
|
51
|
+
"}"
|
|
52
|
+
] @punctuation.special
|
|
53
|
+
) @none
|
|
54
|
+
|
|
55
|
+
((variable) @constant
|
|
56
|
+
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
|
57
|
+
|
|
58
|
+
|