tree-sitter-aspx 0.0.0-stage → 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/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "tree-sitter-aspx",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Tree-sitter grammar for ASP.NET Web Forms markup",
5
+ "main": "bindings/node",
6
+ "types": "bindings/node",
7
+ "scripts": {
8
+ "install": "node-gyp-build",
9
+ "prestart": "npx --yes --package=tree-sitter-cli@0.27.1 -- tree-sitter build --wasm",
10
+ "start": "npx --yes --package=tree-sitter-cli@0.27.1 -- tree-sitter playground",
11
+ "test": "node --test bindings/node/*_test.js",
12
+ "lint": "oxlint grammar.js tools bindings/node",
13
+ "format": "oxfmt \"grammar.js\" \"tools/*.mjs\" \"bindings/node/*.js\"",
14
+ "format:check": "oxfmt --check \"grammar.js\" \"tools/*.mjs\" \"bindings/node/*.js\""
15
+ },
16
+ "author": "M. Reifschneider",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "node-addon-api": "8.9.2",
20
+ "node-gyp-build": "4.8.4"
21
+ },
22
+ "devDependencies": {
23
+ "node-gyp": "13.1.0",
24
+ "oxfmt": "0.75.0",
25
+ "oxlint": "1.90.0",
26
+ "tree-sitter": "0.25.1",
27
+ "tree-sitter-cli": "0.27.1"
28
+ },
29
+ "peerDependencies": {
30
+ "tree-sitter": "^0.25.0"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "tree-sitter": {
34
+ "optional": true
35
+ }
36
+ },
37
+ "gypfile": true,
38
+ "directories": {
39
+ "test": "test"
40
+ },
41
+ "type": "module",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/alfpricot/tree-sitter-aspx.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/alfpricot/tree-sitter-aspx/issues"
48
+ },
49
+ "homepage": "https://github.com/alfpricot/tree-sitter-aspx#readme",
50
+ "keywords": [
51
+ "parser",
52
+ "aspx",
53
+ "aspnet",
54
+ "tree-sitter"
55
+ ],
56
+ "files": [
57
+ "grammar.js",
58
+ "binding.gyp",
59
+ "bindings/node/*",
60
+ "queries/*",
61
+ "src/**",
62
+ "prebuilds/**",
63
+ "tree-sitter.json",
64
+ "NOTICE"
65
+ ],
66
+ "allowScripts": {
67
+ "tree-sitter-cli@0.27.1": true,
68
+ "tree-sitter@0.25.1": true
69
+ }
70
+ }
@@ -0,0 +1,24 @@
1
+ ; Syntax highlighting for ASP.NET Web Forms markup.
2
+
3
+ (directive_name) @keyword
4
+ (tag_name) @tag
5
+ (attribute_name) @attribute
6
+ (attribute_value) @string
7
+ (language_value) @type
8
+ (doctype_token) @keyword
9
+ (doctype_declaration) @string
10
+ (processing_instruction) @keyword
11
+ (cdata_section) @string
12
+
13
+ (server_comment) @comment
14
+ (server_comment_text) @comment
15
+ (html_comment) @comment
16
+ (comment_text) @comment
17
+
18
+ (text) @text
19
+ (style_text) @string
20
+ (expression_value) @string
21
+
22
+ ["<%" "<%=" "<%:" "<%#" "<%$" "%>" "<%@" "<%--" "--%>"] @punctuation.special
23
+ ["<" ">" "</" "/>"] @punctuation.bracket
24
+ ["="] @operator
@@ -0,0 +1,99 @@
1
+ ; Embedded C# and VB.NET.
2
+ ;
3
+ ; The scanner records the page Language attribute and emits c_sharp_code or
4
+ ; vb_code for each nugget, so a host does not have to walk back to the
5
+ ; directive. Statement blocks are combined: `<% if (x) { %>` markup `<% } %>`
6
+ ; is one C# or VB document with the markup left out of the injected ranges.
7
+ ; Output, encoded, and binding nuggets are separate expressions and are not
8
+ ; combined with statement blocks or with each other.
9
+ ;
10
+ ; A <script> body uses the same code node. Without runat="server" the body
11
+ ; is client script, so the query below replaces the page language with
12
+ ; JavaScript. With runat="server" the page language, or the script's own
13
+ ; language attribute, stands. ASP.NET compares the value without regard to
14
+ ; case and accepts it unquoted, so runat=SERVER and runat=server count too.
15
+ ; The pattern needs whitespace before runat and a non-name character after
16
+ ; server, so text such as src="x.ashx?runat=server" or runat="serverless"
17
+ ; does not match. It uses only syntax that Rust, ECMAScript, and Vim regex
18
+ ; read the same way.
19
+ ; Expression builders (`<%$ ... %>`) are not C# or VB and are not injected.
20
+ ; <style> bodies inject as CSS.
21
+ ;
22
+ ; A nugget inside a <script> or <style> body splits the body into several
23
+ ; code or style_text chunks. Those patterns set injection.combined so the
24
+ ; chunks are parsed together with the nuggets left out; the nuggets
25
+ ; themselves are injected by the patterns above. Combined injection joins
26
+ ; every match of a pattern in the page, so all client script bodies form one
27
+ ; JavaScript document, and likewise for server scripts and styles.
28
+
29
+ ((statement_block
30
+ (c_sharp_code) @injection.content)
31
+ (#set! injection.language "c_sharp")
32
+ (#set! injection.combined))
33
+
34
+ ((statement_block
35
+ (vb_code) @injection.content)
36
+ (#set! injection.language "vb")
37
+ (#set! injection.combined))
38
+
39
+ ((output_expression
40
+ (c_sharp_code) @injection.content)
41
+ (#set! injection.language "c_sharp"))
42
+
43
+ ((output_expression
44
+ (vb_code) @injection.content)
45
+ (#set! injection.language "vb"))
46
+
47
+ ((encoded_expression
48
+ (c_sharp_code) @injection.content)
49
+ (#set! injection.language "c_sharp"))
50
+
51
+ ((encoded_expression
52
+ (vb_code) @injection.content)
53
+ (#set! injection.language "vb"))
54
+
55
+ ((binding_expression
56
+ (c_sharp_code) @injection.content)
57
+ (#set! injection.language "c_sharp"))
58
+
59
+ ((binding_expression
60
+ (vb_code) @injection.content)
61
+ (#set! injection.language "vb"))
62
+
63
+ ; Handler files (.ashx, .asmx) are a directive plus code. The code pieces
64
+ ; between any <script> elements and server comments form one document.
65
+ ((handler_code
66
+ (c_sharp_code) @injection.content)
67
+ (#set! injection.language "c_sharp")
68
+ (#set! injection.combined))
69
+
70
+ ((handler_code
71
+ (vb_code) @injection.content)
72
+ (#set! injection.language "vb")
73
+ (#set! injection.combined))
74
+
75
+ ((script_element
76
+ (start_tag) @_tag
77
+ (c_sharp_code) @injection.content)
78
+ (#match? @_tag "\\s[Rr][Uu][Nn][Aa][Tt]\\s*=\\s*[\"']*[Ss][Ee][Rr][Vv][Ee][Rr][^A-Za-z0-9_:.-]")
79
+ (#set! injection.language "c_sharp")
80
+ (#set! injection.combined))
81
+
82
+ ((script_element
83
+ (start_tag) @_tag
84
+ (vb_code) @injection.content)
85
+ (#match? @_tag "\\s[Rr][Uu][Nn][Aa][Tt]\\s*=\\s*[\"']*[Ss][Ee][Rr][Vv][Ee][Rr][^A-Za-z0-9_:.-]")
86
+ (#set! injection.language "vb")
87
+ (#set! injection.combined))
88
+
89
+ ((script_element
90
+ (start_tag) @_tag
91
+ [(c_sharp_code) (vb_code)] @injection.content)
92
+ (#not-match? @_tag "\\s[Rr][Uu][Nn][Aa][Tt]\\s*=\\s*[\"']*[Ss][Ee][Rr][Vv][Ee][Rr][^A-Za-z0-9_:.-]")
93
+ (#set! injection.language "javascript")
94
+ (#set! injection.combined))
95
+
96
+ ((style_element
97
+ (style_text) @injection.content)
98
+ (#set! injection.language "css")
99
+ (#set! injection.combined))