summaryrefslogtreecommitdiff
path: root/queries/cpp.scm
blob: fedc40a5e77affb5d5b0a695c4760cb49bb44050 (plain)
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
; Inherit C queries
(function_declarator (identifier) @function)
(call_expression (identifier) @function)
(parameter_declaration (primitive_type) @type)
(parameter_declaration (identifier) @variable)
(declaration (primitive_type) @type)
(declaration (identifier) @variable)
(string_literal) @string
(number_literal) @number
(char_literal) @string
(comment) @comment
(field_identifier) @property
((identifier) @boolean (#eq? @boolean "true"))
((identifier) @boolean (#eq? @boolean "false"))
(null) @null
((identifier) @keyword (#match? @keyword "^(static_cast|dynamic_cast|const_cast|reinterpret_cast|friend|inline|decltype|explicit|export|mutable|asm|auto|bool|nullptr)$"))

; C++ specific
(template_declaration) @type
(virtual) @keyword
(this) @keyword
(class_specifier name: (type_identifier) @type)
(namespace_definition name: (namespace_identifier) @type)
(using_declaration (qualified_identifier) @type)
(destructor_name) @function
(function_declarator (field_identifier) @function)
(function_definition declarator: (function_declarator declarator: (field_identifier) @function))

[
  "return"
  "if"
  "else"
  "for"
  "while"
  "do"
  "switch"
  "case"
  "default"
  "break"
  "continue"
  "struct"
  "enum"
  "union"
  "typedef"
  "extern"
  "static"
  "const"
  "signed"
  "unsigned"
  "volatile"
  
  ; C++ keywords
  "new"
  "delete"
  "operator"
  "throw"
  "try"
  "catch"
  "class"
  "constexpr"
  "template"
  "typename"
  "using"
  "namespace"
  "public"
  "private"
  "protected"

  "#include"
  "#define"
  "#ifdef"
  "#ifndef"
  "#endif"
] @keyword