-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathcpp.scm
73 lines (64 loc) · 1.7 KB
/
cpp.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
;; import c.scm
;; https://github.com/tree-sitter/tree-sitter-cpp/blob/master/src/grammar.json
;; Generated by the following command:
;; > curl https://raw.githubusercontent.com/tree-sitter/tree-sitter-cpp/master/src/node-types.json | jq '[.[] | select(.type == "compound_statement") | .children.types[].type] + [.[] | select(.type == "_statement") | .subtypes[].type]'
[
(alias_declaration)
(namespace_definition)
(static_assert_declaration)
(template_declaration)
(template_instantiation)
(using_declaration)
(for_range_loop)
(throw_statement)
(try_statement)
] @statement
(_
(class_specifier
name: (_) @className @name
body: (_)
) @_.domain.start @class.start @type.start
.
";"? @_.domain.end @class.end @type.end
)
(_
(class_specifier
name: (_)
body: (_)
) @statement.start
.
";"? @statement.end
)
;;!! void ClassName::method() {}
(function_definition
declarator: (_
declarator: (_
scope: (_) @className
)
)
) @_.domain
(lambda_expression) @anonymousFunction
(attribute_declaration) @attribute
;; > curl https://raw.githubusercontent.com/tree-sitter/tree-sitter-cpp/master/src/node-types.json | jq '[.[] | select(.type == "_type_specifier") | .subtypes[].type]'
[
(auto)
(decltype)
(dependent_type)
(template_type)
] @type
;;!! void foo(int value = 0) {}
;;! ^^^^^
;;! ^
(optional_parameter_declaration
declarator: (_) @name @value.leading.endOf
default_value: (_) @value
) @_.domain
(declaration
type: (_) @functionCallee @functionCall.start @_.domain.start
declarator: (init_declarator
value: (argument_list)
) @functionCall.end @_.domain.end
)
(trailing_return_type
"->" @disqualifyDelimiter
)