tree-sitter-lispex 0.1.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/LICENSE ADDED
@@ -0,0 +1,170 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work.
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original
45
+ version of the Work and any modifications or additions to that Work or
46
+ Derivative Works thereof, that is intentionally submitted to Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or Legal Entity
48
+ authorized to submit on behalf of the copyright owner. For the purposes of this
49
+ definition, "submitted" means any form of electronic, verbal, or written
50
+ communication sent to the Licensor or its representatives, including but not
51
+ limited to communication on electronic mailing lists, source code control
52
+ systems, and issue tracking systems that are managed by, or on behalf of, the
53
+ Licensor for the purpose of discussing and improving the Work, but excluding
54
+ communication that is conspicuously marked or otherwise designated in writing by
55
+ the copyright owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License.
62
+
63
+ Subject to the terms and conditions of this License, each Contributor hereby
64
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
66
+ publicly display, publicly perform, sublicense, and distribute the Work and such
67
+ Derivative Works in Source or Object form.
68
+
69
+ 3. Grant of Patent License.
70
+
71
+ Subject to the terms and conditions of this License, each Contributor hereby
72
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73
+ irrevocable (except as stated in this section) patent license to make, have
74
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75
+ such license applies only to those patent claims licensable by such Contributor
76
+ that are necessarily infringed by their Contribution(s) alone or by combination
77
+ of their Contribution(s) with the Work to which such Contribution(s) was
78
+ submitted. If You institute patent litigation against any entity (including a
79
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80
+ Contribution incorporated within the Work constitutes direct or contributory
81
+ patent infringement, then any patent licenses granted to You under this License
82
+ for that Work shall terminate as of the date such litigation is filed.
83
+
84
+ 4. Redistribution.
85
+
86
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
87
+ in any medium, with or without modifications, and in Source or Object form,
88
+ provided that You meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
91
+ this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices stating that
94
+ You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works that You
97
+ distribute, all copyright, patent, trademark, and attribution notices from the
98
+ Source form of the Work, excluding those notices that do not pertain to any part
99
+ of the Derivative Works; and
100
+
101
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
102
+ any Derivative Works that You distribute must include a readable copy of the
103
+ attribution notices contained within such NOTICE file, excluding those notices
104
+ that do not pertain to any part of the Derivative Works, in at least one of the
105
+ following places: within a NOTICE text file distributed as part of the
106
+ Derivative Works; within the Source form or documentation, if provided along
107
+ with the Derivative Works; or within a display generated by the Derivative
108
+ Works, if and wherever such third-party notices normally appear. The contents
109
+ of the NOTICE file are for informational purposes only and do not modify the
110
+ License. You may add Your own attribution notices within Derivative Works,
111
+ alongside or as an addendum to the NOTICE text from the Work, provided that such
112
+ additional attribution notices cannot be construed as modifying the License.
113
+
114
+ You may add Your own copyright statement to Your modifications and may provide
115
+ additional or different license terms and conditions for use, reproduction, or
116
+ distribution of Your modifications, or for any such Derivative Works as a whole,
117
+ provided Your use, reproduction, and distribution of the Work otherwise complies
118
+ with the conditions stated in this License.
119
+
120
+ 5. Submission of Contributions.
121
+
122
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
123
+ for inclusion in the Work by You to the Licensor shall be under the terms and
124
+ conditions of this License, without any additional terms or conditions.
125
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
126
+ any separate license agreement you may have executed with Licensor regarding
127
+ such Contributions.
128
+
129
+ 6. Trademarks.
130
+
131
+ This License does not grant permission to use the trade names, trademarks,
132
+ service marks, or product names of the Licensor, except as required for
133
+ reasonable and customary use in describing the origin of the Work and
134
+ reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty.
137
+
138
+ Unless required by applicable law or agreed to in writing, Licensor provides the
139
+ Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
141
+ including, without limitation, any warranties or conditions of TITLE,
142
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
143
+ solely responsible for determining the appropriateness of using or
144
+ redistributing the Work and assume any risks associated with Your exercise of
145
+ permissions under this License.
146
+
147
+ 8. Limitation of Liability.
148
+
149
+ In no event and under no legal theory, whether in tort (including negligence),
150
+ contract, or otherwise, unless required by applicable law (such as deliberate
151
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special, incidental,
153
+ or consequential damages of any character arising as a result of this License or
154
+ out of the use or inability to use the Work (including but not limited to
155
+ damages for loss of goodwill, work stoppage, computer failure or malfunction,
156
+ or any and all other commercial damages or losses), even if such Contributor
157
+ has been advised of the possibility of such damages.
158
+
159
+ 9. Accepting Warranty or Additional Liability.
160
+
161
+ While redistributing the Work or Derivative Works thereof, You may choose to
162
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
163
+ other liability obligations and/or rights consistent with this License.
164
+ However, in accepting such obligations, You may act only on Your own behalf and
165
+ on Your sole responsibility, not on behalf of any other Contributor, and only if
166
+ You agree to indemnify, defend, and hold each Contributor harmless for any
167
+ liability incurred by, or claims asserted against, such Contributor by reason of
168
+ your accepting any such warranty or additional liability.
169
+
170
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Lispex tree-sitter grammar
2
+ Copyright 2025-2026 Lispex contributors
3
+
4
+ Licensed under the Apache License, Version 2.0. See LICENSE.
package/binding.gyp ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "tree_sitter_lispex_binding",
5
+ "dependencies": [
6
+ "<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except"
7
+ ],
8
+ "include_dirs": ["src"],
9
+ "sources": [
10
+ "bindings/node/binding.cc",
11
+ "src/parser.c",
12
+ "src/scanner.c"
13
+ ],
14
+ "conditions": [
15
+ ["OS!='win'", {
16
+ "cflags_c": ["-std=c11"]
17
+ }, {
18
+ "cflags_c": ["/std:c11", "/utf-8"]
19
+ }]
20
+ ]
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,21 @@
1
+ #include <napi.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ extern "C" TSLanguage *tree_sitter_lispex();
6
+
7
+ // "tree-sitter", "language" hashed with BLAKE2.
8
+ const napi_type_tag LANGUAGE_TYPE_TAG = {
9
+ 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
10
+ };
11
+
12
+ Napi::Object Init(Napi::Env env, Napi::Object exports) {
13
+ exports["name"] = Napi::String::New(env, "lispex");
14
+ auto language =
15
+ Napi::External<TSLanguage>::New(env, tree_sitter_lispex());
16
+ language.TypeTag(&LANGUAGE_TYPE_TAG);
17
+ exports["language"] = language;
18
+ return exports;
19
+ }
20
+
21
+ NODE_API_MODULE(tree_sitter_lispex_binding, Init)
@@ -0,0 +1,7 @@
1
+ import type { Language } from "tree-sitter";
2
+
3
+ declare const binding: {
4
+ language: Language;
5
+ };
6
+
7
+ export = binding;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ const root = require("node-gyp-build")(__dirname + "/../..");
4
+
5
+ module.exports = root;
6
+
7
+ try {
8
+ module.exports.nodeTypeInfo = require("../../src/node-types.json");
9
+ } catch (_) {}
package/grammar.js ADDED
@@ -0,0 +1,83 @@
1
+ module.exports = grammar({
2
+ name: "lispex",
3
+
4
+ word: ($) => $.symbol,
5
+
6
+ externals: ($) => [
7
+ $.block_comment,
8
+ $.character,
9
+ $.boolean,
10
+ $.byte,
11
+ $.integer,
12
+ $.rational,
13
+ $.real,
14
+ $.symbol,
15
+ $.forbidden_reader_extension,
16
+ ],
17
+
18
+ extras: ($) => [
19
+ /[\s\uFEFF]/,
20
+ $.line_comment,
21
+ $.header_pragma,
22
+ $.block_comment,
23
+ ],
24
+
25
+ rules: {
26
+ source_file: ($) =>
27
+ repeat(
28
+ choice(
29
+ $.datum,
30
+ $.forbidden_reader_extension,
31
+ ),
32
+ ),
33
+
34
+ datum: ($) =>
35
+ choice(
36
+ $.quote,
37
+ $.quasiquote,
38
+ $.unquote,
39
+ $.unquote_splicing,
40
+ $.list,
41
+ $.dotted_list,
42
+ $.vector,
43
+ $.bytevector,
44
+ $.block_comment,
45
+ $.boolean,
46
+ $.character,
47
+ $.string,
48
+ $.rational,
49
+ $.real,
50
+ $.integer,
51
+ $.symbol,
52
+ ),
53
+
54
+ quote: ($) => seq("'", field("datum", $.datum)),
55
+ quasiquote: ($) => seq("`", field("datum", $.datum)),
56
+ unquote: ($) => seq(",", field("datum", $.datum)),
57
+ unquote_splicing: ($) => seq(",@", field("datum", $.datum)),
58
+
59
+ list: ($) => seq("(", repeat($.datum), ")"),
60
+ dotted_list: ($) =>
61
+ seq(
62
+ "(",
63
+ field("head", repeat1($.datum)),
64
+ ".",
65
+ field("tail", $.datum),
66
+ ")",
67
+ ),
68
+
69
+ vector: ($) => seq("#(", repeat($.datum), ")"),
70
+ bytevector: ($) => seq("#u8(", repeat($.byte), ")"),
71
+
72
+ string: (_) =>
73
+ token(
74
+ prec(
75
+ 4,
76
+ /"(?:[^"\\]|\\["\\ntr]|\\[xX][0-9A-Fa-f]+;)*"/,
77
+ ),
78
+ ),
79
+
80
+ header_pragma: (_) => token(prec(3, /;![^\r\n]*/)),
81
+ line_comment: (_) => token(prec(1, /;[^\r\n]*/)),
82
+ },
83
+ });
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "tree-sitter-lispex",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "license": "Apache-2.0",
6
+ "main": "bindings/node",
7
+ "types": "bindings/node",
8
+ "files": [
9
+ "LICENSE",
10
+ "NOTICE",
11
+ "binding.gyp",
12
+ "bindings/node/**",
13
+ "grammar.js",
14
+ "queries/**",
15
+ "src/**",
16
+ "tree-sitter.json"
17
+ ],
18
+ "scripts": {
19
+ "install": "node-gyp-build",
20
+ "generate": "tree-sitter generate",
21
+ "test": "tree-sitter test",
22
+ "test:node": "node scripts/test-node-binding.mjs",
23
+ "test:queries": "node scripts/check-queries.mjs",
24
+ "parse:acceptance": "node scripts/parse-acceptance.mjs",
25
+ "package:audit": "node scripts/package-audit.mjs",
26
+ "prepack": "tree-sitter generate"
27
+ },
28
+ "dependencies": {
29
+ "node-addon-api": "^8.5.0",
30
+ "node-gyp-build": "^4.8.4"
31
+ },
32
+ "devDependencies": {
33
+ "tree-sitter": "0.25.0",
34
+ "tree-sitter-cli": "0.25.10"
35
+ },
36
+ "peerDependencies": {
37
+ "tree-sitter": "^0.25.0"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "tree-sitter": {
41
+ "optional": true
42
+ }
43
+ },
44
+ "tree-sitter": [
45
+ {
46
+ "scope": "source.lispex",
47
+ "file-types": [
48
+ "lspx"
49
+ ],
50
+ "highlights": "queries/highlights.scm",
51
+ "injections": "queries/injections.scm",
52
+ "locals": "queries/locals.scm",
53
+ "indents": "queries/indents.scm"
54
+ }
55
+ ],
56
+ "directories": {
57
+ "test": "test"
58
+ },
59
+ "keywords": [],
60
+ "type": "commonjs"
61
+ }
@@ -0,0 +1,35 @@
1
+ (header_pragma) @preproc
2
+ (line_comment) @comment
3
+ (block_comment) @comment
4
+ (forbidden_reader_extension) @error
5
+
6
+ (boolean) @boolean
7
+ (integer) @number
8
+ (rational) @number
9
+ (real) @number.float
10
+ (character) @character
11
+ (string) @string
12
+ (byte) @number
13
+
14
+ [
15
+ "'"
16
+ "`"
17
+ ","
18
+ ",@"
19
+ "."
20
+ ] @operator
21
+
22
+ ((symbol) @keyword
23
+ (#match? @keyword "^(lambda|if|begin|set!|define|let|let\\*|letrec|quote|quasiquote|unquote|unquote-splicing|values|call-with-values|call/cc|dynamic-wind|cond|case|and|or|when|unless|do|guard)$"))
24
+
25
+ ((list
26
+ .
27
+ (datum
28
+ (symbol) @function.call)))
29
+
30
+ ((dotted_list
31
+ .
32
+ (datum
33
+ (symbol) @function.call)))
34
+
35
+ (symbol) @variable
@@ -0,0 +1,8 @@
1
+ [
2
+ (list)
3
+ (dotted_list)
4
+ (vector)
5
+ (bytevector)
6
+ ] @indent
7
+
8
+ ")" @outdent
@@ -0,0 +1 @@
1
+ ; Lispex has no embedded-language reader form.
@@ -0,0 +1,23 @@
1
+ (source_file) @local.scope
2
+
3
+ ((list
4
+ .
5
+ (datum
6
+ (symbol) @_define)
7
+ .
8
+ (datum
9
+ (symbol) @local.definition))
10
+ (#eq? @_define "define"))
11
+
12
+ ((list
13
+ .
14
+ (datum
15
+ (symbol) @_lambda)
16
+ .
17
+ (datum
18
+ (list
19
+ (datum
20
+ (symbol) @local.definition))))
21
+ (#eq? @_lambda "lambda"))
22
+
23
+ (symbol) @local.reference