@willbooster/tree-sitter-go 6.0.0 → 6.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/grammar.js +19 -3
- package/package.json +1 -1
- package/queries/highlights.scm +56 -0
- package/src/node-types.json +14 -2
- package/tree-sitter-go.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -63,6 +63,7 @@ const hexFloatLiteral = seq('0', choice('x', 'X'), hexMantissa, hexExponent);
|
|
|
63
63
|
const floatLiteral = choice(decimalFloatLiteral, hexFloatLiteral);
|
|
64
64
|
|
|
65
65
|
const imaginaryLiteral = seq(choice(decimalDigits, intLiteral, floatLiteral), 'i');
|
|
66
|
+
const formatArgumentIndex = /\[0*[1-9][0-9]*\]/;
|
|
66
67
|
|
|
67
68
|
module.exports = grammar({
|
|
68
69
|
name: 'go',
|
|
@@ -886,19 +887,34 @@ module.exports = grammar({
|
|
|
886
887
|
|
|
887
888
|
raw_string_literal: $ => seq(
|
|
888
889
|
'`',
|
|
889
|
-
|
|
890
|
-
|
|
890
|
+
repeat(choice(
|
|
891
|
+
alias(token.immediate(prec(1, /[^`%]+/)), $.raw_string_literal_content),
|
|
892
|
+
alias(token.immediate('%'), $.raw_string_literal_content),
|
|
893
|
+
$.format_specifier,
|
|
894
|
+
)),
|
|
895
|
+
token.immediate('`'),
|
|
891
896
|
),
|
|
892
897
|
|
|
893
898
|
interpreted_string_literal: $ => seq(
|
|
894
899
|
'"',
|
|
895
900
|
repeat(choice(
|
|
896
|
-
alias(token.immediate(prec(1, /[^"\n
|
|
901
|
+
alias(token.immediate(prec(1, /[^"\n\\%]+/)), $.interpreted_string_literal_content),
|
|
902
|
+
alias(token.immediate('%'), $.interpreted_string_literal_content),
|
|
903
|
+
$.format_specifier,
|
|
897
904
|
$.escape_sequence,
|
|
898
905
|
)),
|
|
899
906
|
token.immediate('"'),
|
|
900
907
|
),
|
|
901
908
|
|
|
909
|
+
format_specifier: _ => token.immediate(prec(2, seq(
|
|
910
|
+
'%',
|
|
911
|
+
/[+#0 -]*/,
|
|
912
|
+
optional(choice(/[0-9]+/, seq(optional(formatArgumentIndex), '*'))),
|
|
913
|
+
optional(seq('.', choice(/[0-9]*/, seq(optional(formatArgumentIndex), '*')))),
|
|
914
|
+
optional(formatArgumentIndex),
|
|
915
|
+
/[vTtbcdoOqxXUeEfFgGspw%]/,
|
|
916
|
+
))),
|
|
917
|
+
|
|
902
918
|
escape_sequence: _ => token.immediate(seq(
|
|
903
919
|
'\\',
|
|
904
920
|
choice(
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
|
@@ -93,6 +93,62 @@
|
|
|
93
93
|
(rune_literal)
|
|
94
94
|
] @string
|
|
95
95
|
|
|
96
|
+
((call_expression
|
|
97
|
+
function: (identifier) @function
|
|
98
|
+
arguments: (argument_list
|
|
99
|
+
. (comment)*
|
|
100
|
+
. [
|
|
101
|
+
(interpreted_string_literal
|
|
102
|
+
. [(interpreted_string_literal_content) (escape_sequence) (format_specifier) @string.special]* .)
|
|
103
|
+
(raw_string_literal
|
|
104
|
+
. [(raw_string_literal_content) (format_specifier) @string.special]* .)
|
|
105
|
+
]))
|
|
106
|
+
(#match? @function "^(Printf|Sprintf|Errorf|Scanf|Fatalf|Panicf|Skipf|Logf|Debugf|Infof|Warnf|Warningf|Tracef)$"))
|
|
107
|
+
|
|
108
|
+
((call_expression
|
|
109
|
+
function: (selector_expression field: (field_identifier) @function.method)
|
|
110
|
+
arguments: (argument_list
|
|
111
|
+
. (comment)*
|
|
112
|
+
. [
|
|
113
|
+
(interpreted_string_literal
|
|
114
|
+
. [(interpreted_string_literal_content) (escape_sequence) (format_specifier) @string.special]* .)
|
|
115
|
+
(raw_string_literal
|
|
116
|
+
. [(raw_string_literal_content) (format_specifier) @string.special]* .)
|
|
117
|
+
]))
|
|
118
|
+
(#match? @function.method "^(Printf|Sprintf|Errorf|Scanf|Fatalf|Panicf|Skipf|Logf|Debugf|Infof|Warnf|Warningf|Tracef)$"))
|
|
119
|
+
|
|
120
|
+
((call_expression
|
|
121
|
+
function: (identifier) @function
|
|
122
|
+
arguments: (argument_list
|
|
123
|
+
. (comment)*
|
|
124
|
+
. (_)
|
|
125
|
+
. (comment)*
|
|
126
|
+
. ","
|
|
127
|
+
. (comment)*
|
|
128
|
+
. [
|
|
129
|
+
(interpreted_string_literal
|
|
130
|
+
. [(interpreted_string_literal_content) (escape_sequence) (format_specifier) @string.special]* .)
|
|
131
|
+
(raw_string_literal
|
|
132
|
+
. [(raw_string_literal_content) (format_specifier) @string.special]* .)
|
|
133
|
+
]))
|
|
134
|
+
(#match? @function "^(Fprintf|Appendf|Fscanf|Sscanf)$"))
|
|
135
|
+
|
|
136
|
+
((call_expression
|
|
137
|
+
function: (selector_expression field: (field_identifier) @function.method)
|
|
138
|
+
arguments: (argument_list
|
|
139
|
+
. (comment)*
|
|
140
|
+
. (_)
|
|
141
|
+
. (comment)*
|
|
142
|
+
. ","
|
|
143
|
+
. (comment)*
|
|
144
|
+
. [
|
|
145
|
+
(interpreted_string_literal
|
|
146
|
+
. [(interpreted_string_literal_content) (escape_sequence) (format_specifier) @string.special]* .)
|
|
147
|
+
(raw_string_literal
|
|
148
|
+
. [(raw_string_literal_content) (format_specifier) @string.special]* .)
|
|
149
|
+
]))
|
|
150
|
+
(#match? @function.method "^(Fprintf|Appendf|Fscanf|Sscanf)$"))
|
|
151
|
+
|
|
96
152
|
(escape_sequence) @escape
|
|
97
153
|
|
|
98
154
|
[
|
package/src/node-types.json
CHANGED
|
@@ -1445,6 +1445,10 @@
|
|
|
1445
1445
|
"type": "escape_sequence",
|
|
1446
1446
|
"named": true
|
|
1447
1447
|
},
|
|
1448
|
+
{
|
|
1449
|
+
"type": "format_specifier",
|
|
1450
|
+
"named": true
|
|
1451
|
+
},
|
|
1448
1452
|
{
|
|
1449
1453
|
"type": "interpreted_string_literal_content",
|
|
1450
1454
|
"named": true
|
|
@@ -1879,9 +1883,13 @@
|
|
|
1879
1883
|
"named": true,
|
|
1880
1884
|
"fields": {},
|
|
1881
1885
|
"children": {
|
|
1882
|
-
"multiple":
|
|
1883
|
-
"required":
|
|
1886
|
+
"multiple": true,
|
|
1887
|
+
"required": false,
|
|
1884
1888
|
"types": [
|
|
1889
|
+
{
|
|
1890
|
+
"type": "format_specifier",
|
|
1891
|
+
"named": true
|
|
1892
|
+
},
|
|
1885
1893
|
{
|
|
1886
1894
|
"type": "raw_string_literal_content",
|
|
1887
1895
|
"named": true
|
|
@@ -2940,6 +2948,10 @@
|
|
|
2940
2948
|
"type": "for",
|
|
2941
2949
|
"named": false
|
|
2942
2950
|
},
|
|
2951
|
+
{
|
|
2952
|
+
"type": "format_specifier",
|
|
2953
|
+
"named": true
|
|
2954
|
+
},
|
|
2943
2955
|
{
|
|
2944
2956
|
"type": "func",
|
|
2945
2957
|
"named": false
|
package/tree-sitter-go.wasm
CHANGED
|
Binary file
|