Coverage for src/renaissance/integrations/clang/cpp_utils.py: 62%
8 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
1"""AI: Helper predicates and constants for working with C/C++ AST node kinds."""
4def matches_node_kind(mine, other) -> bool:
5 """AI: Return True if two nodes share the same semantic kind or parser kind."""
6 if mine.semantic_kind.value != "node" and other.semantic_kind.value != "node":
7 return mine.semantic_kind is other.semantic_kind
8 return mine.parser_kind == other.parser_kind
11def is_clang_kind(node, *parser_kinds: str) -> bool:
12 """AI: Return True if node's parser_kind matches one of the given kind strings."""
13 return node.parser_kind in parser_kinds
16class CPPUtils:
17 """AI: Constants and helpers for working with C++ reserved keywords and type names."""
19 # a set of cpp reserved keywords in reverse alphabetical order:
20 RESERVED_KEYWORDS = {
21 "while",
22 "wchar_t",
23 "void",
24 "volatile",
25 "virtual",
26 "unsigned",
27 "union",
28 "typename",
29 "typedef",
30 "try",
31 "true",
32 "throw",
33 "this",
34 "template",
35 "switch",
36 "struct",
37 "static_cast",
38 "static",
39 "sizeof",
40 "signed",
41 "short",
42 "return",
43 "reinterpret_cast",
44 "register",
45 "public",
46 "protected",
47 "private",
48 "operator",
49 "or_eq",
50 "or",
51 "not_eq",
52 "not",
53 "new",
54 "namespace",
55 "mutable",
56 "long",
57 "inline",
58 "int",
59 "if",
60 "goto",
61 "friend",
62 "for",
63 "float",
64 "false",
65 "extern",
66 "explicit",
67 "export",
68 "enum",
69 "else",
70 "double",
71 "do",
72 "delete",
73 "default",
74 "decltype",
75 "continue",
76 "const_cast",
77 "const",
78 "class",
79 "char16_t",
80 "char32_t",
81 "char",
82 "catch",
83 "case",
84 "break",
85 "bool",
86 "bitand",
87 "bitor",
88 "auto",
89 "asm",
90 "and_eq",
91 "and",
92 }