-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathscm.scm
113 lines (100 loc) · 2.19 KB
/
scm.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
;; import scm.collections.scm
;; import scm.name.scm
;; https://github.com/tree-sitter-grammars/tree-sitter-query/blob/master/src/grammar.json
;; A statement is any top-level node that's not a comment
(
(program
(_) @statement
) @_.iteration
(#not-type? @statement comment)
)
(comment) @comment @textFragment
(anonymous_node
name: (_) @string @textFragment
(#child-range! @textFragment 0 -1 true true)
)
;; functionCall:
;;!! (#aaa? @bbb "ccc")
;;! ^^^^^^^^^^^^^^^^^^
;; functionCallee:
;;!! (#aaa? @bbb "ccc")
;;! ^^^^
;;! ------------------
(predicate
name: (identifier) @functionCallee.start
type: (predicate_type) @functionCallee.end
) @functionCall @functionCallee.domain
;;!! ((#aaa!) (#bbb!))
;;! *****************
(grouping) @functionCall.iteration @functionCallee.iteration
;;!! (#aaa? @bbb "ccc")
;;! ^^^^ ^^^^^
;;! ******************
(predicate
(parameters
(_) @argumentOrParameter
)
)
(predicate
(parameters) @argumentOrParameter.iteration
) @argumentOrParameter.iteration.domain
;;!! (aaa) @bbb
;;! ^^^
;;! ----------
(named_node
name: _ @type
) @_.domain
;;!! "aaa" @bbb
;;! ^^^
;;! ----------
(anonymous_node
name: [
"_" @type
(identifier
"\"" @type.start.endOf
"\"" @type.end.startOf
)
]
) @_.domain
;;!! aaa: (bbb) @ccc
;;! ^^^
;;! xxxxx
;;! ---------------
(field_definition
name: (identifier) @collectionKey
.
(_) @_.trailing.startOf
) @_.domain
;;!! aaa: (bbb) @ccc
;;! ^^^^^
;;! ---------------
;;!! aaa: [(bbb)]* @ccc
;;! ^^^^^^^^
;;! ------------------
;; Note that this pattern is a bit ugly in order to exclude the capture (@foo).
;; Unfortunately the capture is part of the node to the right of the `:`, so we
;; kinda need to reach inside that node to exclude it.
(field_definition
":"
(_
[
")"
"]"
] @value.end
(quantifier)? @value.end
) @value.start.startOf
) @_.domain
;;!! aaa: "bbb" @ccc
;;! ^^^^^
;;! ---------------
;; As above, this pattern is a bit ugly in order to exclude the capture (@foo).
(field_definition
":"
(anonymous_node
[
(identifier)
"_"
] @value.end
(quantifier)? @value.end
) @value.start.startOf
) @_.domain