Coverage for src/renaissance/integrations/clang/cpp_utils.py: 50%

6 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-11-16 16:04 +0000

1# Copyright (C) 2024-2026 TNO 

2# 

3# Licensed under the terms specified in the LICENSE file in the root directory 

4# of this repository, also available at: 

5# https://github.com/TNO/Renaissance.Py/blob/main/LICENSE 

6 

7"""AI: Helper predicates and constants for working with C/C++ AST node kinds.""" 

8 

9 

10def matches_node_kind(mine, other) -> bool: 

11 """AI: Return True if two nodes share the same semantic kind or parser kind.""" 

12 if mine.semantic_kind.value != "node" and other.semantic_kind.value != "node": 

13 return mine.semantic_kind is other.semantic_kind 

14 return mine.parser_kind == other.parser_kind 

15 

16 

17class CPPUtils: 

18 """AI: Constants and helpers for working with C++ reserved keywords and type names.""" 

19 

20 # a set of cpp reserved keywords in reverse alphabetical order: 

21 RESERVED_KEYWORDS = { 

22 "while", 

23 "wchar_t", 

24 "void", 

25 "volatile", 

26 "virtual", 

27 "unsigned", 

28 "union", 

29 "typename", 

30 "typedef", 

31 "try", 

32 "true", 

33 "throw", 

34 "this", 

35 "template", 

36 "switch", 

37 "struct", 

38 "static_cast", 

39 "static", 

40 "sizeof", 

41 "signed", 

42 "short", 

43 "return", 

44 "reinterpret_cast", 

45 "register", 

46 "public", 

47 "protected", 

48 "private", 

49 "operator", 

50 "or_eq", 

51 "or", 

52 "not_eq", 

53 "not", 

54 "new", 

55 "namespace", 

56 "mutable", 

57 "long", 

58 "inline", 

59 "int", 

60 "if", 

61 "goto", 

62 "friend", 

63 "for", 

64 "float", 

65 "false", 

66 "extern", 

67 "explicit", 

68 "export", 

69 "enum", 

70 "else", 

71 "double", 

72 "do", 

73 "delete", 

74 "default", 

75 "decltype", 

76 "continue", 

77 "const_cast", 

78 "const", 

79 "class", 

80 "char16_t", 

81 "char32_t", 

82 "char", 

83 "catch", 

84 "case", 

85 "break", 

86 "bool", 

87 "bitand", 

88 "bitor", 

89 "auto", 

90 "asm", 

91 "and_eq", 

92 "and", 

93 }