tree-sitter-glsl-spec 1.0.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 +21 -0
- package/README.md +106 -0
- package/binding.gyp +21 -0
- package/bindings/node/binding.cc +20 -0
- package/bindings/node/binding_test.js +11 -0
- package/bindings/node/index.d.ts +91 -0
- package/bindings/node/index.js +39 -0
- package/grammar.js +2932 -0
- package/package.json +71 -0
- package/queries/constructor-heuristics.scm +7 -0
- package/queries/highlights.in +112 -0
- package/queries/highlights.scm +486 -0
- package/queries/injections.scm +5 -0
- package/queries/locals.scm +34 -0
- package/queries/tags.scm +50 -0
- package/queries/version-tags.scm +150 -0
- package/src/grammar.json +7839 -0
- package/src/node-types.json +5807 -0
- package/src/parser.c +237532 -0
- package/src/tree_sitter/alloc.h +54 -0
- package/src/tree_sitter/array.h +330 -0
- package/src/tree_sitter/parser.h +286 -0
- package/src/tree_sitter/runtime.h +112 -0
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tree-sitter-glsl-spec",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "GLSL grammar for tree-sitter",
|
|
5
|
+
"main": "bindings/node",
|
|
6
|
+
"types": "bindings/node",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"parser",
|
|
9
|
+
"glsl"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
"grammar.js",
|
|
13
|
+
"binding.gyp",
|
|
14
|
+
"prebuilds/**",
|
|
15
|
+
"bindings/node/*",
|
|
16
|
+
"queries/*",
|
|
17
|
+
"src/**"
|
|
18
|
+
],
|
|
19
|
+
"author": "Tin Švagelj",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"node-addon-api": "^8.7.0",
|
|
23
|
+
"node-gyp-build": "^4.8.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"tree-sitter": "^0.25.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependenciesMeta": {
|
|
29
|
+
"tree_sitter": {
|
|
30
|
+
"optional": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.5.2",
|
|
35
|
+
"eslint": "^10.2.0",
|
|
36
|
+
"eslint-config-treesitter": "^1.0.2",
|
|
37
|
+
"globals": "^17.4.0",
|
|
38
|
+
"prebuildify": "^6.0.0",
|
|
39
|
+
"tree-sitter-cli": "^0.26.8",
|
|
40
|
+
"typescript": "^6.0.2",
|
|
41
|
+
"xml-js": "^1.6.11"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"install": "node-gyp-build",
|
|
45
|
+
"prebuildify": "prebuildify --napi --strip",
|
|
46
|
+
"generate:highlights": "node scripts/generate_highlights.js",
|
|
47
|
+
"test": "tree-sitter test",
|
|
48
|
+
"test:bindings": "npm run test:bindings:node && npm run test:bindings:rust && npm run test:bindings:go && npm run test:bindings:python && npm run test:bindings:swift",
|
|
49
|
+
"test:bindings:node": "node bindings/node/binding_test.js",
|
|
50
|
+
"test:bindings:rust": "cargo test",
|
|
51
|
+
"test:bindings:go": "cd bindings/go && go test",
|
|
52
|
+
"test:bindings:python": "python -m pytest bindings/python/tests",
|
|
53
|
+
"test:bindings:swift": "swift test",
|
|
54
|
+
"check:names": "node scripts/scrape_identifiers.js specification",
|
|
55
|
+
"check:ast": "node scripts/audit_node_types.js",
|
|
56
|
+
"check:coverage": "node scripts/audit_node_types.js --coverage",
|
|
57
|
+
"check:lint": "eslint",
|
|
58
|
+
"check:types": "tsc --noEmit"
|
|
59
|
+
},
|
|
60
|
+
"type": "module",
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "git://github.com/Caellian/tree-sitter-glsl.git"
|
|
64
|
+
},
|
|
65
|
+
"contributors": [
|
|
66
|
+
{
|
|
67
|
+
"name": "Tin Švagelj",
|
|
68
|
+
"email": "tin.svagelj@live.com"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
; Opt-in heuristic query for constructor-like user-defined calls.
|
|
2
|
+
; Builtin GLSL constructors are already parsed as `constructor_expression`.
|
|
3
|
+
|
|
4
|
+
(function_call
|
|
5
|
+
function: (type_specifier
|
|
6
|
+
(type_identifier) @name)
|
|
7
|
+
(#match? @name "^[A-Z]")) @reference.constructor
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"break" @keyword
|
|
2
|
+
"case" @keyword
|
|
3
|
+
"const" @keyword
|
|
4
|
+
"continue" @keyword
|
|
5
|
+
"default" @keyword
|
|
6
|
+
"discard" @keyword
|
|
7
|
+
"do" @keyword
|
|
8
|
+
"else" @keyword
|
|
9
|
+
"for" @keyword
|
|
10
|
+
"if" @keyword
|
|
11
|
+
"return" @keyword
|
|
12
|
+
"struct" @keyword
|
|
13
|
+
"switch" @keyword
|
|
14
|
+
"while" @keyword
|
|
15
|
+
|
|
16
|
+
(preproc_call
|
|
17
|
+
directive: (preproc_directive) @keyword)
|
|
18
|
+
|
|
19
|
+
"=" @operator
|
|
20
|
+
(assignment_expression
|
|
21
|
+
operator: _ @operator)
|
|
22
|
+
|
|
23
|
+
(binary_expression
|
|
24
|
+
operator: _ @operator)
|
|
25
|
+
|
|
26
|
+
(unary_expression
|
|
27
|
+
operator: _ @operator)
|
|
28
|
+
|
|
29
|
+
(update_expression
|
|
30
|
+
operator: _ @operator)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
"." @delimiter
|
|
34
|
+
"," @delimiter
|
|
35
|
+
";" @delimiter
|
|
36
|
+
"(" @delimiter
|
|
37
|
+
")" @delimiter
|
|
38
|
+
"[" @delimiter
|
|
39
|
+
"]" @delimiter
|
|
40
|
+
"{" @delimiter
|
|
41
|
+
"}" @delimiter
|
|
42
|
+
|
|
43
|
+
[
|
|
44
|
+
(number_literal)
|
|
45
|
+
] @number
|
|
46
|
+
|
|
47
|
+
(bool_literal) @boolean
|
|
48
|
+
|
|
49
|
+
(comment) @comment
|
|
50
|
+
|
|
51
|
+
(invariant_qualifier) @keyword
|
|
52
|
+
(layout_qualifier) @keyword
|
|
53
|
+
(precise_qualifier) @keyword
|
|
54
|
+
|
|
55
|
+
((storage_qualifier) @keyword
|
|
56
|
+
(#match? @keyword "^subroutine(\\(|$)"))
|
|
57
|
+
|
|
58
|
+
(function_declarator
|
|
59
|
+
name: (identifier) @function)
|
|
60
|
+
|
|
61
|
+
(function_call
|
|
62
|
+
function: (identifier) @function)
|
|
63
|
+
|
|
64
|
+
(function_call
|
|
65
|
+
function: (field_expression
|
|
66
|
+
field: (field_identifier) @function))
|
|
67
|
+
|
|
68
|
+
(preproc_function_def
|
|
69
|
+
name: (identifier) @function.special)
|
|
70
|
+
|
|
71
|
+
(field_identifier) @property
|
|
72
|
+
|
|
73
|
+
(type_specifier
|
|
74
|
+
(type_identifier) @type)
|
|
75
|
+
|
|
76
|
+
{{GENERATED_TYPE_BUILTIN_KEYWORDS}}
|
|
77
|
+
|
|
78
|
+
{{GENERATED_TYPE_QUALIFIER_KEYWORDS}}
|
|
79
|
+
|
|
80
|
+
(layout_argument
|
|
81
|
+
"shared" @attribute)
|
|
82
|
+
|
|
83
|
+
{{GENERATED_ATTRIBUTE_KEYWORDS}}
|
|
84
|
+
|
|
85
|
+
((identifier) @constant
|
|
86
|
+
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
|
|
87
|
+
|
|
88
|
+
; Built-in constant names from builtins.adoc.
|
|
89
|
+
((identifier) @constant.builtin
|
|
90
|
+
{{GENERATED_BUILTIN_CONSTANT_PREDICATE}})
|
|
91
|
+
|
|
92
|
+
; Built-in variable names from builtins.adoc.
|
|
93
|
+
((identifier) @variable.builtin
|
|
94
|
+
{{GENERATED_BUILTIN_VARIABLE_PREDICATE}})
|
|
95
|
+
|
|
96
|
+
; Built-in type-like names from builtins.adoc such as gl_PerVertex.
|
|
97
|
+
((type_specifier
|
|
98
|
+
(type_identifier) @type.builtin)
|
|
99
|
+
{{GENERATED_BUILTIN_TYPE_NAME_PREDICATE}})
|
|
100
|
+
|
|
101
|
+
; Built-in function names from builtinfunctions.adoc.
|
|
102
|
+
; Vulkan-only built-in function names from builtinfunctions.adoc.
|
|
103
|
+
((function_call
|
|
104
|
+
function: (identifier) @function.builtin.vk)
|
|
105
|
+
{{GENERATED_POSTFIX_VK_FUNCTION_PREDICATE}})
|
|
106
|
+
|
|
107
|
+
; Built-in function names from builtinfunctions.adoc.
|
|
108
|
+
((function_call
|
|
109
|
+
function: (identifier) @function.builtin)
|
|
110
|
+
{{GENERATED_POSTFIX_FUNCTION_PREDICATE}})
|
|
111
|
+
|
|
112
|
+
(identifier) @variable
|