| 1 |
/* |
| 2 |
* 7 bits for 7 character classifications |
| 3 |
* generated by char-mapper on 10/13/20 at 12:18:56 |
| 4 |
* |
| 5 |
* This file contains the caracter classifications used by the |
| 6 |
* code complexity measurement tool. |
| 7 |
*/ |
| 8 |
#ifndef CHAR_TYPES_H_GUARD |
| 9 |
#define CHAR_TYPES_H_GUARD 1 |
| 10 |
|
| 11 |
#ifdef HAVE_CONFIG_H |
| 12 |
# if defined(HAVE_INTTYPES_H) |
| 13 |
# include <inttypes.h> |
| 14 |
|
| 15 |
# elif defined(HAVE_STDINT_H) |
| 16 |
# include <stdint.h> |
| 17 |
|
| 18 |
# elif !defined(HAVE_UINT8_T) |
| 19 |
typedef unsigned char uint8_t; |
| 20 |
# endif /* HAVE_*INT*_H header */ |
| 21 |
|
| 22 |
#else /* not HAVE_CONFIG_H -- */ |
| 23 |
# include <inttypes.h> |
| 24 |
#endif /* HAVE_CONFIG_H */ |
| 25 |
|
| 26 |
#if 0 /* mapping specification source (from char-types.map) */ |
| 27 |
// |
| 28 |
// # This file is part of Complexity. |
| 29 |
// # Complexity Copyright (c) 2011-2016 by Bruce Korb - all rights reserved |
| 30 |
// # |
| 31 |
// # Complexity is free software: you can redistribute it and/or modify it |
| 32 |
// # under the terms of the GNU General Public License as published by the |
| 33 |
// # Free Software Foundation, either version 3 of the License, or |
| 34 |
// # (at your option) any later version. |
| 35 |
// # |
| 36 |
// # Complexity is distributed in the hope that it will be useful, but |
| 37 |
// # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 38 |
// # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 39 |
// # See the GNU General Public License for more details. |
| 40 |
// # |
| 41 |
// # You should have received a copy of the GNU General Public License along |
| 42 |
// # with this program. If not, see <http://www.gnu.org/licenses/>. |
| 43 |
// |
| 44 |
// %guard define-cplx-char-type |
| 45 |
// %file char-types.h |
| 46 |
// %table cplx-char-type |
| 47 |
// |
| 48 |
// %comment -- see above |
| 49 |
// % |
| 50 |
// |
| 51 |
// alpha "a-zA-Z" |
| 52 |
// digit "0-9" |
| 53 |
// name-start "_$" +alpha |
| 54 |
// name "$" +name-start +digit |
| 55 |
// space " \t\b\r\v\f\n" |
| 56 |
// end-of-line "\n\r\0" |
| 57 |
// star-or-nl "*" +end-of-line |
| 58 |
// |
| 59 |
#endif /* 0 -- mapping spec. source */ |
| 60 |
|
| 61 |
|
| 62 |
typedef uint8_t cplx_char_type_mask_t; |
| 63 |
|
| 64 |
#define IS_ALPHA_CHAR( _c) is_cplx_char_type_char((char)(_c), 0x01) |
| 65 |
#define SPN_ALPHA_CHARS(_s) spn_cplx_char_type_chars(_s, 0x01) |
| 66 |
#define BRK_ALPHA_CHARS(_s) brk_cplx_char_type_chars(_s, 0x01) |
| 67 |
#define IS_DIGIT_CHAR( _c) is_cplx_char_type_char((char)(_c), 0x02) |
| 68 |
#define SPN_DIGIT_CHARS(_s) spn_cplx_char_type_chars(_s, 0x02) |
| 69 |
#define BRK_DIGIT_CHARS(_s) brk_cplx_char_type_chars(_s, 0x02) |
| 70 |
#define IS_NAME_START_CHAR( _c) is_cplx_char_type_char((char)(_c), 0x05) |
| 71 |
#define SPN_NAME_START_CHARS(_s) spn_cplx_char_type_chars(_s, 0x05) |
| 72 |
#define BRK_NAME_START_CHARS(_s) brk_cplx_char_type_chars(_s, 0x05) |
| 73 |
#define IS_NAME_CHAR( _c) is_cplx_char_type_char((char)(_c), 0x0F) |
| 74 |
#define SPN_NAME_CHARS(_s) spn_cplx_char_type_chars(_s, 0x0F) |
| 75 |
#define BRK_NAME_CHARS(_s) brk_cplx_char_type_chars(_s, 0x0F) |
| 76 |
#define IS_SPACE_CHAR( _c) is_cplx_char_type_char((char)(_c), 0x10) |
| 77 |
#define SPN_SPACE_CHARS(_s) spn_cplx_char_type_chars(_s, 0x10) |
| 78 |
#define BRK_SPACE_CHARS(_s) brk_cplx_char_type_chars(_s, 0x10) |
| 79 |
#define IS_END_OF_LINE_CHAR( _c) is_cplx_char_type_char((char)(_c), 0x20) |
| 80 |
#define SPN_END_OF_LINE_CHARS(_s) spn_cplx_char_type_chars(_s, 0x20) |
| 81 |
#define BRK_END_OF_LINE_CHARS(_s) brk_cplx_char_type_chars(_s, 0x20) |
| 82 |
#define IS_STAR_OR_NL_CHAR( _c) is_cplx_char_type_char((char)(_c), 0x60) |
| 83 |
#define SPN_STAR_OR_NL_CHARS(_s) spn_cplx_char_type_chars(_s, 0x60) |
| 84 |
#define BRK_STAR_OR_NL_CHARS(_s) brk_cplx_char_type_chars(_s, 0x60) |
| 85 |
|
| 86 |
#ifdef DEFINE_CPLX_CHAR_TYPE |
| 87 |
cplx_char_type_mask_t const cplx_char_type[128] = { |
| 88 |
/*NUL*/ 0x20, /*x01*/ 0x00, /*x02*/ 0x00, /*x03*/ 0x00, |
| 89 |
/*x04*/ 0x00, /*x05*/ 0x00, /*x06*/ 0x00, /*BEL*/ 0x00, |
| 90 |
/* BS*/ 0x10, /* HT*/ 0x10, /* NL*/ 0x30, /* VT*/ 0x10, |
| 91 |
/* FF*/ 0x10, /* CR*/ 0x30, /*x0E*/ 0x00, /*x0F*/ 0x00, |
| 92 |
/*x10*/ 0x00, /*x11*/ 0x00, /*x12*/ 0x00, /*x13*/ 0x00, |
| 93 |
/*x14*/ 0x00, /*x15*/ 0x00, /*x16*/ 0x00, /*x17*/ 0x00, |
| 94 |
/*x18*/ 0x00, /*x19*/ 0x00, /*x1A*/ 0x00, /*ESC*/ 0x00, |
| 95 |
/*x1C*/ 0x00, /*x1D*/ 0x00, /*x1E*/ 0x00, /*x1F*/ 0x00, |
| 96 |
/* */ 0x10, /* ! */ 0x00, /* " */ 0x00, /* # */ 0x00, |
| 97 |
/* $ */ 0x0C, /* % */ 0x00, /* & */ 0x00, /* ' */ 0x00, |
| 98 |
/* ( */ 0x00, /* ) */ 0x00, /* * */ 0x40, /* + */ 0x00, |
| 99 |
/* , */ 0x00, /* - */ 0x00, /* . */ 0x00, /* / */ 0x00, |
| 100 |
/* 0 */ 0x02, /* 1 */ 0x02, /* 2 */ 0x02, /* 3 */ 0x02, |
| 101 |
/* 4 */ 0x02, /* 5 */ 0x02, /* 6 */ 0x02, /* 7 */ 0x02, |
| 102 |
/* 8 */ 0x02, /* 9 */ 0x02, /* : */ 0x00, /* ; */ 0x00, |
| 103 |
/* < */ 0x00, /* = */ 0x00, /* > */ 0x00, /* ? */ 0x00, |
| 104 |
/* @ */ 0x00, /* A */ 0x01, /* B */ 0x01, /* C */ 0x01, |
| 105 |
/* D */ 0x01, /* E */ 0x01, /* F */ 0x01, /* G */ 0x01, |
| 106 |
/* H */ 0x01, /* I */ 0x01, /* J */ 0x01, /* K */ 0x01, |
| 107 |
/* L */ 0x01, /* M */ 0x01, /* N */ 0x01, /* O */ 0x01, |
| 108 |
/* P */ 0x01, /* Q */ 0x01, /* R */ 0x01, /* S */ 0x01, |
| 109 |
/* T */ 0x01, /* U */ 0x01, /* V */ 0x01, /* W */ 0x01, |
| 110 |
/* X */ 0x01, /* Y */ 0x01, /* Z */ 0x01, /* [ */ 0x00, |
| 111 |
/* \ */ 0x00, /* ] */ 0x00, /* ^ */ 0x00, /* _ */ 0x04, |
| 112 |
/* ` */ 0x00, /* a */ 0x01, /* b */ 0x01, /* c */ 0x01, |
| 113 |
/* d */ 0x01, /* e */ 0x01, /* f */ 0x01, /* g */ 0x01, |
| 114 |
/* h */ 0x01, /* i */ 0x01, /* j */ 0x01, /* k */ 0x01, |
| 115 |
/* l */ 0x01, /* m */ 0x01, /* n */ 0x01, /* o */ 0x01, |
| 116 |
/* p */ 0x01, /* q */ 0x01, /* r */ 0x01, /* s */ 0x01, |
| 117 |
/* t */ 0x01, /* u */ 0x01, /* v */ 0x01, /* w */ 0x01, |
| 118 |
/* x */ 0x01, /* y */ 0x01, /* z */ 0x01, /* { */ 0x00, |
| 119 |
/* | */ 0x00, /* } */ 0x00, /* ~ */ 0x00, /*x7F*/ 0x00 |
| 120 |
}; |
| 121 |
#endif /* DEFINE_CPLX_CHAR_TYPE */ |
| 122 |
extern cplx_char_type_mask_t const cplx_char_type[128]; |
| 123 |
static inline int |
| 124 |
is_cplx_char_type_char(char ch, cplx_char_type_mask_t mask) |
| 125 |
{ |
| 126 |
unsigned int ix = (unsigned char)ch; |
| 127 |
return ((ix < 128) && ((cplx_char_type[ix] & mask) != 0)); |
| 128 |
} |
| 129 |
|
| 130 |
static inline char * |
| 131 |
spn_cplx_char_type_chars(char const * p, cplx_char_type_mask_t mask) |
| 132 |
{ |
| 133 |
while ((*p != '\0') && is_cplx_char_type_char(*p, mask)) p++; |
| 134 |
return (char *)(uintptr_t)p; |
| 135 |
} |
| 136 |
|
| 137 |
static inline char * |
| 138 |
brk_cplx_char_type_chars(char const * p, cplx_char_type_mask_t mask) |
| 139 |
{ |
| 140 |
while ((*p != '\0') && (! is_cplx_char_type_char(*p, mask))) p++; |
| 141 |
return (char *)(uintptr_t)p; |
| 142 |
} |
| 143 |
#endif /* CHAR_TYPES_H_GUARD */ |
| 144 |
/* sum: char-types.map = 55763.2 */ |