@apple/tree-sitter-pkl 0.16.0
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.
- package/CODE_OF_CONDUCT.adoc +78 -0
- package/CONTRIBUTING.adoc +52 -0
- package/Cargo.lock +80 -0
- package/Cargo.toml +29 -0
- package/LICENSE.txt +202 -0
- package/MAINTAINERS.adoc +11 -0
- package/NOTICE.txt +4 -0
- package/README.adoc +61 -0
- package/SECURITY.adoc +13 -0
- package/binding.gyp +19 -0
- package/bindings/node/binding.cc +28 -0
- package/bindings/node/index.js +19 -0
- package/grammar.js +779 -0
- package/package.json +51 -0
- package/queries/highlights.scm +138 -0
- package/queries/injections.scm +9 -0
- package/queries/locals.scm +38 -0
- package/src/grammar.json +3962 -0
- package/src/node-types.json +5668 -0
- package/src/parser.c +59696 -0
- package/src/scanner.c +285 -0
- package/src/synctests.ts +44 -0
- package/src/tree_sitter/parser.h +224 -0
- package/tsconfig.json +101 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
== Code of Conduct
|
|
2
|
+
|
|
3
|
+
=== Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our
|
|
7
|
+
project and our community a harassment-free experience for everyone,
|
|
8
|
+
regardless of age, body size, disability, ethnicity, sex
|
|
9
|
+
characteristics, gender identity and expression, level of experience,
|
|
10
|
+
education, socio-economic status, nationality, personal appearance,
|
|
11
|
+
race, religion, or sexual identity and orientation.
|
|
12
|
+
|
|
13
|
+
=== Our Standards
|
|
14
|
+
|
|
15
|
+
Examples of behavior that contributes to creating a positive environment
|
|
16
|
+
include:
|
|
17
|
+
|
|
18
|
+
* Using welcoming and inclusive language
|
|
19
|
+
* Being respectful of differing viewpoints and experiences
|
|
20
|
+
* Gracefully accepting constructive criticism
|
|
21
|
+
* Focusing on what is best for the community
|
|
22
|
+
* Showing empathy towards other community members
|
|
23
|
+
|
|
24
|
+
Examples of unacceptable behavior by participants include:
|
|
25
|
+
|
|
26
|
+
* The use of sexualized language or imagery and unwelcome sexual
|
|
27
|
+
attention or advances
|
|
28
|
+
* Trolling, insulting/derogatory comments, and personal or political
|
|
29
|
+
attacks
|
|
30
|
+
* Public or private harassment
|
|
31
|
+
* Publishing others’ private information, such as a physical or
|
|
32
|
+
electronic address, without explicit permission
|
|
33
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
34
|
+
professional setting
|
|
35
|
+
|
|
36
|
+
=== Our Responsibilities
|
|
37
|
+
|
|
38
|
+
Project maintainers are responsible for clarifying the standards of
|
|
39
|
+
acceptable behavior and are expected to take appropriate and fair
|
|
40
|
+
corrective action in response to any instances of unacceptable behavior.
|
|
41
|
+
|
|
42
|
+
Project maintainers have the right and responsibility to remove, edit,
|
|
43
|
+
or reject comments, commits, code, wiki edits, issues, and other
|
|
44
|
+
contributions that are not aligned to this Code of Conduct, or to ban
|
|
45
|
+
temporarily or permanently any contributor for other behaviors that they
|
|
46
|
+
deem inappropriate, threatening, offensive, or harmful.
|
|
47
|
+
|
|
48
|
+
=== Scope
|
|
49
|
+
|
|
50
|
+
This Code of Conduct applies within all project spaces, and it also
|
|
51
|
+
applies when an individual is representing the project or its community
|
|
52
|
+
in public spaces. Examples of representing a project or community
|
|
53
|
+
include using an official project e-mail address, posting via an
|
|
54
|
+
official social media account, or acting as an appointed representative
|
|
55
|
+
at an online or offline event. Representation of a project may be
|
|
56
|
+
further defined and clarified by project maintainers.
|
|
57
|
+
|
|
58
|
+
=== Enforcement
|
|
59
|
+
|
|
60
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may
|
|
61
|
+
be reported by contacting the open source team at
|
|
62
|
+
opensource-conduct@group.apple.com. All complaints will be reviewed and
|
|
63
|
+
investigated and will result in a response that is deemed necessary and
|
|
64
|
+
appropriate to the circumstances. The project team is obligated to
|
|
65
|
+
maintain confidentiality with regard to the reporter of an incident.
|
|
66
|
+
Further details of specific enforcement policies may be posted
|
|
67
|
+
separately.
|
|
68
|
+
|
|
69
|
+
Project maintainers who do not follow or enforce the Code of Conduct in
|
|
70
|
+
good faith may face temporary or permanent repercussions as determined
|
|
71
|
+
by other members of the project’s leadership.
|
|
72
|
+
|
|
73
|
+
=== Attribution
|
|
74
|
+
|
|
75
|
+
This Code of Conduct is adapted from the
|
|
76
|
+
https://www.contributor-covenant.org[Contributor Covenant], version 1.4,
|
|
77
|
+
available at
|
|
78
|
+
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
:uri-github-issue-pkl: https://github.com/apple/tree-sitter-pkl/issues/new
|
|
2
|
+
:uri-seven-rules: https://cbea.ms/git-commit/#seven-rules
|
|
3
|
+
|
|
4
|
+
= Tree Sitter Pkl Contributors Guide
|
|
5
|
+
|
|
6
|
+
Welcome to the Pkl community, and thank you for contributing!
|
|
7
|
+
This guide explains how to get involved.
|
|
8
|
+
|
|
9
|
+
* <<Licensing>>
|
|
10
|
+
* <<Issue Tracking>>
|
|
11
|
+
* <<Pull Requests>>
|
|
12
|
+
|
|
13
|
+
== Licensing
|
|
14
|
+
|
|
15
|
+
Tree Sitter Pkl is released under the Apache 2.0 license.
|
|
16
|
+
This is why we require that, by submitting a pull request, you acknowledge that you have the right to license your contribution to Apple and the community, and agree that your contribution is licensed under the Apache 2.0 license.
|
|
17
|
+
|
|
18
|
+
== Issue Tracking
|
|
19
|
+
|
|
20
|
+
To file a bug or feature request, use {uri-github-issue-pkl}[GitHub].
|
|
21
|
+
Be sure to include the following information:
|
|
22
|
+
|
|
23
|
+
* Context
|
|
24
|
+
** What are/were you trying to achieve?
|
|
25
|
+
** What's the impact of this bug/feature?
|
|
26
|
+
|
|
27
|
+
For bug reports, additionally include the following information:
|
|
28
|
+
|
|
29
|
+
* The output of `pkl --version`.
|
|
30
|
+
* The complete error message.
|
|
31
|
+
* The simplest possible steps to reproduce.
|
|
32
|
+
* Output produced from the template.
|
|
33
|
+
* Error messages from the target system.
|
|
34
|
+
|
|
35
|
+
== Pull Requests
|
|
36
|
+
|
|
37
|
+
When preparing a pull request, follow this checklist:
|
|
38
|
+
|
|
39
|
+
* Imitate the conventions of surrounding code.
|
|
40
|
+
* Format the files in your PR with the JetBrains IDE formatter.
|
|
41
|
+
* Follow the {uri-seven-rules}[seven rules] of great Git commit messages:
|
|
42
|
+
** Separate subject from body with a blank line.
|
|
43
|
+
** Limit the subject line to 50 characters.
|
|
44
|
+
** Capitalize the subject line.
|
|
45
|
+
** Do not end the subject line with a period.
|
|
46
|
+
** Use the imperative mood in the subject line.
|
|
47
|
+
** Wrap the body at 72 characters.
|
|
48
|
+
** Use the body to explain what and why vs. how.
|
|
49
|
+
|
|
50
|
+
== Maintainers
|
|
51
|
+
|
|
52
|
+
The project’s maintainers (those with write access to the upstream repository) are listed in link:MAINTAINERS.adoc[].
|
package/Cargo.lock
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 3
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "cc"
|
|
16
|
+
version = "1.0.83"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"libc",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "libc"
|
|
25
|
+
version = "0.2.148"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "memchr"
|
|
31
|
+
version = "2.6.3"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "regex"
|
|
37
|
+
version = "1.9.5"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"aho-corasick",
|
|
42
|
+
"memchr",
|
|
43
|
+
"regex-automata",
|
|
44
|
+
"regex-syntax",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[[package]]
|
|
48
|
+
name = "regex-automata"
|
|
49
|
+
version = "0.3.8"
|
|
50
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
51
|
+
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
|
|
52
|
+
dependencies = [
|
|
53
|
+
"aho-corasick",
|
|
54
|
+
"memchr",
|
|
55
|
+
"regex-syntax",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[[package]]
|
|
59
|
+
name = "regex-syntax"
|
|
60
|
+
version = "0.7.5"
|
|
61
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
62
|
+
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
|
63
|
+
|
|
64
|
+
[[package]]
|
|
65
|
+
name = "tree-sitter"
|
|
66
|
+
version = "0.20.10"
|
|
67
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
68
|
+
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
|
|
69
|
+
dependencies = [
|
|
70
|
+
"cc",
|
|
71
|
+
"regex",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[[package]]
|
|
75
|
+
name = "tree-sitter-pkl"
|
|
76
|
+
version = "0.16.0"
|
|
77
|
+
dependencies = [
|
|
78
|
+
"cc",
|
|
79
|
+
"tree-sitter",
|
|
80
|
+
]
|
package/Cargo.toml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "tree-sitter-pkl"
|
|
3
|
+
description = "Pkl grammar for the tree-sitter parsing library"
|
|
4
|
+
version = "0.16.0"
|
|
5
|
+
keywords = ["incremental", "parsing", "pkl"]
|
|
6
|
+
categories = ["parsing", "text-editors"]
|
|
7
|
+
repository = "https://github.com/apple/tree-sitter-pkl"
|
|
8
|
+
edition = "2018"
|
|
9
|
+
license = "Apache-2.0"
|
|
10
|
+
authors = [
|
|
11
|
+
"pkl-oss@group.apple.com"
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
build = "bindings/rust/build.rs"
|
|
15
|
+
include = [
|
|
16
|
+
"bindings/rust/*",
|
|
17
|
+
"grammar.js",
|
|
18
|
+
"queries/*",
|
|
19
|
+
"src/*",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[lib]
|
|
23
|
+
path = "bindings/rust/lib.rs"
|
|
24
|
+
|
|
25
|
+
[dependencies]
|
|
26
|
+
tree-sitter = "~0.20.6"
|
|
27
|
+
|
|
28
|
+
[build-dependencies]
|
|
29
|
+
cc = "1.0"
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/MAINTAINERS.adoc
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
= MAINTAINERS
|
|
2
|
+
|
|
3
|
+
This page lists all active Maintainers of this repository.
|
|
4
|
+
|
|
5
|
+
See link:CONTRIBUTING.adoc[] for general contribution guidelines.
|
|
6
|
+
|
|
7
|
+
== Maintainers (in alphabetical order)
|
|
8
|
+
|
|
9
|
+
* https://github.com/bioball[Daniel Chao]
|
|
10
|
+
* https://github.com/stackoverflow[Islon Scherer]
|
|
11
|
+
* https://github.com/holzensp[Philip Hölzenspies]
|
package/NOTICE.txt
ADDED
package/README.adoc
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
A tree-sitter grammar for Pkl.
|
|
2
|
+
|
|
3
|
+
[source, shell]
|
|
4
|
+
----
|
|
5
|
+
# install dependencies
|
|
6
|
+
$ npm install
|
|
7
|
+
|
|
8
|
+
# build parser
|
|
9
|
+
$ npm run build
|
|
10
|
+
|
|
11
|
+
# parse some code
|
|
12
|
+
$ ./node_modules/.bin/tree-sitter parse test.pkl
|
|
13
|
+
----
|
|
14
|
+
|
|
15
|
+
== Tests
|
|
16
|
+
|
|
17
|
+
Tree sitter comes with its own test framework.
|
|
18
|
+
Files in `corpus/` describe one test each.
|
|
19
|
+
All tests in `corpus/` are performed by the command
|
|
20
|
+
|
|
21
|
+
[source,shell]
|
|
22
|
+
---
|
|
23
|
+
$ tree-sitter test
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
The script `src/synctests.ts` creates `corpus/` test files from tests in `pkl`'s `LanguageSnippetTests`.
|
|
27
|
+
The script assumes that `../pkl` is a checked out `pkl` repository (and that the tests are under `pkl-core/src/test/files/LanguageSnippetFiles/input`).
|
|
28
|
+
A pre-condition of the script is that `tree-sitter test` currently passes.
|
|
29
|
+
If broken tests need replacing, the broken tests must first be deleted.
|
|
30
|
+
|
|
31
|
+
It can be executed by running
|
|
32
|
+
|
|
33
|
+
[source,shell]
|
|
34
|
+
---
|
|
35
|
+
$ npm run synctests
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
== Upgrading tree-sitter
|
|
39
|
+
|
|
40
|
+
Upgrading tree-sitter involves upgrading the NPM package.
|
|
41
|
+
|
|
42
|
+
1. Run `npm update tree-sitter` to install the newer version of tree-sitter.
|
|
43
|
+
2. Commit to main, and push.
|
|
44
|
+
|
|
45
|
+
== Releasing
|
|
46
|
+
|
|
47
|
+
1. Run the build & test to make sure everything is up-to-date and passes (check 0 diff).
|
|
48
|
+
2. Create a `Prepare 1.2.3 release` (with appropriate version number) commit where
|
|
49
|
+
* Versions are bumped in `package.json`, `Cargo.toml`
|
|
50
|
+
* Lockfiles are updated (`npm install`, `cargo check`)
|
|
51
|
+
* You have checked the previous release PR for any changes in process not described in this `README.adoc`; if any
|
|
52
|
+
- Adopt the changes accordingly
|
|
53
|
+
- Update this description to capture the changed process
|
|
54
|
+
3. Merge into `main` & push
|
|
55
|
+
4. Check that CI release succeeded (https://app.circleci.com/pipelines/github/apple/tree-sitter-pkl[release pipeline])
|
|
56
|
+
5. Check the publication is reachable, https://www.npmjs.com/package/@apple/tree-sitter-pkl[on NPM]
|
|
57
|
+
|
|
58
|
+
== Resources
|
|
59
|
+
|
|
60
|
+
- https://tree-sitter.github.io/tree-sitter/[Tree-sitter docs]
|
|
61
|
+
- https://gist.github.com/Aerijo/df27228d70c633e088b0591b8857eeef[Guide to your first Tree-sitter grammar]
|
package/SECURITY.adoc
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
= Security
|
|
2
|
+
|
|
3
|
+
For the protection of our community, the Pkl team does not disclose, discuss, or confirm security issues until our investigation is complete and any necessary updates are generally available.
|
|
4
|
+
|
|
5
|
+
== Reporting a security vulnerability
|
|
6
|
+
|
|
7
|
+
If you have discovered a security vulnerability within the Pkl Pantry project, please report it to us.
|
|
8
|
+
We welcome reports from everyone, including security researchers, developers, and users.
|
|
9
|
+
|
|
10
|
+
Security vulnerabilities may be reported on the link:https://security.apple.com/submit[Report a vulnerability] form.
|
|
11
|
+
When submitting a vulnerability, select "Apple Devices and Software" as the affected platform, and "Open Source" as the affected area.
|
|
12
|
+
|
|
13
|
+
For more information, see https://pkl-lang.org/security.html.
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "tree_sitter_pkl_binding",
|
|
5
|
+
"include_dirs": [
|
|
6
|
+
"<!(node -e \"require('nan')\")",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"sources": [
|
|
10
|
+
"bindings/node/binding.cc",
|
|
11
|
+
"src/parser.c",
|
|
12
|
+
# If your language uses an external scanner, add it here.
|
|
13
|
+
],
|
|
14
|
+
"cflags_c": [
|
|
15
|
+
"-std=c99",
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#include "tree_sitter/parser.h"
|
|
2
|
+
#include <node.h>
|
|
3
|
+
#include "nan.h"
|
|
4
|
+
|
|
5
|
+
using namespace v8;
|
|
6
|
+
|
|
7
|
+
extern "C" TSLanguage * tree_sitter_pkl();
|
|
8
|
+
|
|
9
|
+
namespace {
|
|
10
|
+
|
|
11
|
+
NAN_METHOD(New) {}
|
|
12
|
+
|
|
13
|
+
void Init(Local<Object> exports, Local<Object> module) {
|
|
14
|
+
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
15
|
+
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
|
16
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
17
|
+
|
|
18
|
+
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
|
19
|
+
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
|
20
|
+
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_pkl());
|
|
21
|
+
|
|
22
|
+
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("pkl").ToLocalChecked());
|
|
23
|
+
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NODE_MODULE(tree_sitter_pkl_binding, Init)
|
|
27
|
+
|
|
28
|
+
} // namespace
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
try {
|
|
2
|
+
module.exports = require("../../build/Release/tree_sitter_pkl_binding");
|
|
3
|
+
} catch (error1) {
|
|
4
|
+
if (error1.code !== 'MODULE_NOT_FOUND') {
|
|
5
|
+
throw error1;
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
module.exports = require("../../build/Debug/tree_sitter_pkl_binding");
|
|
9
|
+
} catch (error2) {
|
|
10
|
+
if (error2.code !== 'MODULE_NOT_FOUND') {
|
|
11
|
+
throw error2;
|
|
12
|
+
}
|
|
13
|
+
throw error1
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
|
19
|
+
} catch (_) {}
|