tree-sitter-familymarkup 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +22 -0
- package/README.md +3 -0
- package/binding.gyp +30 -0
- package/bindings/node/binding.cc +20 -0
- package/bindings/node/binding_test.js +9 -0
- package/bindings/node/index.d.ts +28 -0
- package/bindings/node/index.js +7 -0
- package/grammar.js +97 -0
- package/package.json +44 -0
- package/queries/highlights.scm +67 -0
- package/queries/locals.scm +9 -0
- package/src/binding.go +13 -0
- package/src/grammar.json +760 -0
- package/src/node-types.json +435 -0
- package/src/parser.c +2487 -0
- package/src/tree_sitter/alloc.h +54 -0
- package/src/tree_sitter/array.h +290 -0
- package/src/tree_sitter/parser.h +266 -0
package/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
BSD 4-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2024, Sergii Kliuchnyk
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
7
|
+
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
10
|
+
3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Sergii Kliuchnyk.
|
11
|
+
4. Neither the name of Sergii Kliuchnyk nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
14
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
15
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
17
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
18
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
19
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
20
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
21
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
22
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
package/binding.gyp
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"targets": [
|
3
|
+
{
|
4
|
+
"target_name": "tree_sitter_familymarkup_binding",
|
5
|
+
"dependencies": [
|
6
|
+
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
|
7
|
+
],
|
8
|
+
"include_dirs": [
|
9
|
+
"src",
|
10
|
+
],
|
11
|
+
"sources": [
|
12
|
+
"bindings/node/binding.cc",
|
13
|
+
"src/parser.c",
|
14
|
+
# NOTE: if your language has an external scanner, add it here.
|
15
|
+
],
|
16
|
+
"conditions": [
|
17
|
+
["OS!='win'", {
|
18
|
+
"cflags_c": [
|
19
|
+
"-std=c11",
|
20
|
+
],
|
21
|
+
}, { # OS == "win"
|
22
|
+
"cflags_c": [
|
23
|
+
"/std:c11",
|
24
|
+
"/utf-8",
|
25
|
+
],
|
26
|
+
}],
|
27
|
+
],
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#include <napi.h>
|
2
|
+
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
4
|
+
|
5
|
+
extern "C" TSLanguage *tree_sitter_familymarkup();
|
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, "familymarkup");
|
14
|
+
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_familymarkup());
|
15
|
+
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
16
|
+
exports["language"] = language;
|
17
|
+
return exports;
|
18
|
+
}
|
19
|
+
|
20
|
+
NODE_API_MODULE(tree_sitter_familymarkup_binding, Init)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
|
3
|
+
const assert = require("node:assert");
|
4
|
+
const { test } = require("node:test");
|
5
|
+
|
6
|
+
test("can load grammar", () => {
|
7
|
+
const parser = new (require("tree-sitter"))();
|
8
|
+
assert.doesNotThrow(() => parser.setLanguage(require(".")));
|
9
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
type BaseNode = {
|
2
|
+
type: string;
|
3
|
+
named: boolean;
|
4
|
+
};
|
5
|
+
|
6
|
+
type ChildNode = {
|
7
|
+
multiple: boolean;
|
8
|
+
required: boolean;
|
9
|
+
types: BaseNode[];
|
10
|
+
};
|
11
|
+
|
12
|
+
type NodeInfo =
|
13
|
+
| (BaseNode & {
|
14
|
+
subtypes: BaseNode[];
|
15
|
+
})
|
16
|
+
| (BaseNode & {
|
17
|
+
fields: { [name: string]: ChildNode };
|
18
|
+
children: ChildNode[];
|
19
|
+
});
|
20
|
+
|
21
|
+
type Language = {
|
22
|
+
name: string;
|
23
|
+
language: unknown;
|
24
|
+
nodeTypeInfo: NodeInfo[];
|
25
|
+
};
|
26
|
+
|
27
|
+
declare const language: Language;
|
28
|
+
export = language;
|
package/grammar.js
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
module.exports = grammar({
|
2
|
+
name: 'familymarkup',
|
3
|
+
|
4
|
+
conflicts: $ => [
|
5
|
+
[$.family],
|
6
|
+
[$.relations],
|
7
|
+
[$.relation],
|
8
|
+
[$.targets],
|
9
|
+
],
|
10
|
+
|
11
|
+
extras: _ => [' ', '\t'],
|
12
|
+
|
13
|
+
rules: {
|
14
|
+
root: $ => seq(
|
15
|
+
optional(choice($._nl, $._multi_newline)),
|
16
|
+
repeatWith($.family, $._multi_newline),
|
17
|
+
optional(choice($._nl, $._multi_newline)),
|
18
|
+
),
|
19
|
+
|
20
|
+
_multi_newline: _ => /\r?\n[\r\n\s]*\r?\n/,
|
21
|
+
_nl: _ => /\r?\n/,
|
22
|
+
|
23
|
+
family: $ => seq(
|
24
|
+
field('name', $.family_name),
|
25
|
+
optional(seq(
|
26
|
+
$._nl,
|
27
|
+
repeatWith($.comment, $._nl)
|
28
|
+
)),
|
29
|
+
optional(seq(
|
30
|
+
$._multi_newline,
|
31
|
+
$.relations
|
32
|
+
))
|
33
|
+
),
|
34
|
+
|
35
|
+
relations: $ => repeatWith($.relation, $._multi_newline),
|
36
|
+
|
37
|
+
relation: $ => seq(
|
38
|
+
field('sources', $.sources),
|
39
|
+
field('arrow', $._arrows),
|
40
|
+
field('label', optional($.words)),
|
41
|
+
optional($._nl),
|
42
|
+
field('targets', optional($.targets)),
|
43
|
+
),
|
44
|
+
|
45
|
+
sources: $ => repeatWith(
|
46
|
+
choice($.name_ref, $.name, $.unknown),
|
47
|
+
field('delimiter', choice('+', ',', $._words))
|
48
|
+
),
|
49
|
+
targets: $ => repeatWith(
|
50
|
+
choice($.name_ref, $.name_def, $.num_unknown, $.unknown, $.comment),
|
51
|
+
field('delimiter', choice(',', $._nl, $._words))
|
52
|
+
),
|
53
|
+
|
54
|
+
name_ref: $ => seq(alias($.name, $.surname), $.name),
|
55
|
+
|
56
|
+
family_name: $ => seq(
|
57
|
+
field('name', $.name),
|
58
|
+
field('aliases', optional($.name_aliases)),
|
59
|
+
),
|
60
|
+
|
61
|
+
name_def: $ => seq(
|
62
|
+
field('number', optional($.num)),
|
63
|
+
field('surname', optional($.new_surname)),
|
64
|
+
field('name', $.name),
|
65
|
+
field('aliases', optional($.name_aliases)),
|
66
|
+
),
|
67
|
+
|
68
|
+
num: _ => /\d+[.)]?/,
|
69
|
+
|
70
|
+
new_surname: $ => seq(
|
71
|
+
'(', $.name, ')'
|
72
|
+
),
|
73
|
+
|
74
|
+
name_aliases: $ => seq(
|
75
|
+
'(', optional(repeatWith($.name, ',')), ')'
|
76
|
+
),
|
77
|
+
|
78
|
+
comment: _ => seq(choice('*', '/', '#'), optional(/[^\n]+/)),
|
79
|
+
|
80
|
+
name: _ => /\p{Lu}[\p{L}\-\d'"]*/u,
|
81
|
+
|
82
|
+
unknown: _ => choice('?', /\p{L}[\p{L}\-\d'" ]*\?/u),
|
83
|
+
num_unknown: $ => seq($.num, $.unknown),
|
84
|
+
|
85
|
+
words: _ => /\p{Ll}([\p{Ll}'"\s]*[\p{Ll}'"])?/u,
|
86
|
+
_words: $ => alias($.words, '_words'),
|
87
|
+
|
88
|
+
_arrows: _ => choice('=', '<->', '->', '<-', '-'),
|
89
|
+
},
|
90
|
+
});
|
91
|
+
|
92
|
+
function repeatWith(rule, sep) {
|
93
|
+
return seq(
|
94
|
+
rule,
|
95
|
+
optional(repeat(seq(sep, rule)))
|
96
|
+
);
|
97
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"name": "tree-sitter-familymarkup",
|
3
|
+
"description": "Tree sitter for FamilyMarkup",
|
4
|
+
"version": "1.8.3",
|
5
|
+
"main": "bindings/node",
|
6
|
+
"types": "bindings/node",
|
7
|
+
"scripts": {
|
8
|
+
"install": "node-gyp-build",
|
9
|
+
"gb": "tree-sitter generate && tree-sitter build && rm -rf bindings/go",
|
10
|
+
"prestart": "tree-sitter build --wasm",
|
11
|
+
"start": "tree-sitter playground",
|
12
|
+
"test": "tree-sitter test"
|
13
|
+
},
|
14
|
+
"keywords": [
|
15
|
+
"tree-sitter",
|
16
|
+
"familymarkup"
|
17
|
+
],
|
18
|
+
"files": [
|
19
|
+
"grammar.js",
|
20
|
+
"binding.gyp",
|
21
|
+
"prebuilds/**",
|
22
|
+
"bindings/node/*",
|
23
|
+
"queries/*",
|
24
|
+
"src/**"
|
25
|
+
],
|
26
|
+
"author": "Sergii Kliuchnyk",
|
27
|
+
"license": "BSD 4-Clause",
|
28
|
+
"devDependencies": {
|
29
|
+
"prebuildify": "^6.0.0",
|
30
|
+
"tree-sitter-cli": "^0.24.4"
|
31
|
+
},
|
32
|
+
"dependencies": {
|
33
|
+
"node-addon-api": "^8.2.2",
|
34
|
+
"node-gyp-build": "^4.8.0"
|
35
|
+
},
|
36
|
+
"peerDependencies": {
|
37
|
+
"tree-sitter": "^0.21.0"
|
38
|
+
},
|
39
|
+
"peerDependenciesMeta": {
|
40
|
+
"tree_sitter": {
|
41
|
+
"optional": true
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
(family_name
|
2
|
+
(name) @class.declaration.family_name
|
3
|
+
)
|
4
|
+
|
5
|
+
(family_name
|
6
|
+
(name_aliases
|
7
|
+
(name) @class.declaration.family_name.alias
|
8
|
+
)
|
9
|
+
)
|
10
|
+
|
11
|
+
(name_ref
|
12
|
+
(surname) @class.family_name.ref
|
13
|
+
)
|
14
|
+
|
15
|
+
(name_ref
|
16
|
+
(name) @property.static.name.ref
|
17
|
+
)
|
18
|
+
|
19
|
+
(name_def
|
20
|
+
(name) @property.declaration.static.name.def
|
21
|
+
)
|
22
|
+
|
23
|
+
(name_def
|
24
|
+
(name_aliases (name) @property.declaration.static.name.def.alias)
|
25
|
+
)
|
26
|
+
|
27
|
+
(sources
|
28
|
+
(name) @property.static.name.ref
|
29
|
+
)
|
30
|
+
|
31
|
+
(targets
|
32
|
+
(name_def
|
33
|
+
.
|
34
|
+
(name) @property.static.name.ref
|
35
|
+
.
|
36
|
+
)
|
37
|
+
)
|
38
|
+
|
39
|
+
(relation
|
40
|
+
arrow: "="
|
41
|
+
(targets
|
42
|
+
(name_def
|
43
|
+
.
|
44
|
+
(name) @property.declaration.static.name.def
|
45
|
+
.
|
46
|
+
)
|
47
|
+
)
|
48
|
+
)
|
49
|
+
|
50
|
+
(new_surname
|
51
|
+
(name) @class.family_name.ref
|
52
|
+
)
|
53
|
+
|
54
|
+
(unknown) @string.unknown
|
55
|
+
|
56
|
+
(comment) @comment
|
57
|
+
|
58
|
+
(num) @number.targets
|
59
|
+
|
60
|
+
(sources delimiter: _ @punctuation.delimiter.sources)
|
61
|
+
(targets delimiter: _ @punctuation.delimiter.targets)
|
62
|
+
|
63
|
+
"+" @operator.sources.join
|
64
|
+
|
65
|
+
(relation arrow: _ @operator.arrow)
|
66
|
+
|
67
|
+
(relation label: _ @string.label)
|
package/src/binding.go
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
package src
|
2
|
+
|
3
|
+
// #cgo CFLAGS: -std=c11 -fPIC
|
4
|
+
// #include "./tree_sitter/parser.h"
|
5
|
+
//TSLanguage *tree_sitter_familymarkup();
|
6
|
+
import "C"
|
7
|
+
|
8
|
+
import "unsafe"
|
9
|
+
|
10
|
+
// Get the tree-sitter Language for this grammar.
|
11
|
+
func Language() unsafe.Pointer {
|
12
|
+
return unsafe.Pointer(C.tree_sitter_familymarkup())
|
13
|
+
}
|