Debian Codegraph @

Xtree-house/test-grammars/comment/src/tree_sitter_comment/chars.c

raw symbols SCIP
1 #include "chars.h"
2
3 bool is_upper(int32_t c)
4 {
5 const int32_t upper = 65;
6 const int32_t lower = 90;
7 return c >= upper && c <= lower;
8 }
9
10 bool is_digit(int32_t c)
11 {
12 const int32_t upper = 48;
13 const int32_t lower = 57;
14 return c >= upper && c <= lower;
15 }
16
17 bool is_newline(int32_t c)
18 {
19 const int32_t newline_chars[] = {
20 CHAR_EOF,
21 CHAR_NEWLINE,
22 CHAR_CARRIAGE_RETURN,
23 };
24 const int length = sizeof(newline_chars) / sizeof(int32_t);
25 for (int i = 0; i < length; i++) {
26 if (c == newline_chars[i]) {
27 return true;
28 }
29 }
30 return false;
31 }
32
33 bool is_space(int32_t c)
34 {
35 const int32_t space_chars[] = {
36 CHAR_SPACE,
37 CHAR_FORM_FEED,
38 CHAR_TAB,
39 CHAR_VERTICAL_TAB,
40 };
41 const int length = sizeof(space_chars) / sizeof(int32_t);
42 bool is_space_char = false;
43 for (int i = 0; i < length; i++) {
44 if (c == space_chars[i]) {
45 is_space_char = true;
46 break;
47 }
48 }
49 return is_space_char || is_newline(c);
50 }
51
52 /// Check if the character is allowed inside the name.
53 bool is_internal_char(int32_t c)
54 {
55 const int32_t valid_chars[] = {
56 '-',
57 '_',
58 };
59 const int length = sizeof(valid_chars) / sizeof(int32_t);
60 for (int i = 0; i < length; i++) {
61 if (c == valid_chars[i]) {
62 return true;
63 }
64 }
65 return false;
66 }