1/* 2 * 29 bits for 46 character classifications 3 * generated by char-mapper on 04/25/15 at 09:53:03 4 * 5 * This file contains the character classifications 6 * used by AutoGen and AutoOpts for identifying tokens. 7 * The table is static scope, so %guard is empty. 8 * 9 * This file is part of AutoOpts, a companion to AutoGen. 10 * AutoOpts is free software. 11 * AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved 12 * 13 * AutoOpts is available under any one of two licenses. The license 14 * in use must be one of these two and the choice is under the control 15 * of the user of the license. 16 * 17 * The GNU Lesser General Public License, version 3 or later 18 * See the files "COPYING.lgplv3" and "COPYING.gplv3" 19 * 20 * The Modified Berkeley Software Distribution License 21 * See the file "COPYING.mbsd" 22 * 23 * These files have the following sha256 sums: 24 * 25 * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3 26 * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3 27 * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd 28 */ 29#ifndef AG_CHAR_MAP_H_GUARD 30#define AG_CHAR_MAP_H_GUARD 1 31 32#ifdef HAVE_CONFIG_H 33# if defined(HAVE_INTTYPES_H) 34# include <inttypes.h> 35 36# elif defined(HAVE_STDINT_H) 37# include <stdint.h> 38 39# elif !defined(HAVE_UINT32_T) 40# if SIZEOF_INT == 4 41 typedef unsigned int uint32_t; 42# elif SIZEOF_LONG == 4 43 typedef unsigned long uint32_t; 44# endif 45# endif /* HAVE_*INT*_H header */ 46 47#else /* not HAVE_CONFIG_H -- */ 48# include <inttypes.h> 49#endif /* HAVE_CONFIG_H */ 50 51#if 0 /* mapping specification source (from autogen.map) */ 52// 53// %guard 54// %file ag-char-map.h 55// %backup 56// %optimize 57// 58// %comment -- see above 59// % 60// 61// newline "\n" 62// nul-byte "\x00" 63// dir-sep "/\\" 64// percent "%" 65// comma "," 66// colon ":" 67// underscore "_" 68// plus "+" 69// dollar "$" 70// option-marker "-" 71// 72// horiz-white "\t " 73// alt-white "\v\f\r\b" 74// whitespace +horiz-white +newline +alt-white 75// non-nl-white +horiz-white +alt-white 76// quote "'\"" 77// parentheses "()" 78// 79// graphic "!-~" 80// inversion "~-" 81// oct-digit "0-7" 82// dec-digit "89" +oct-digit 83// hex-digit "a-fA-F" +dec-digit 84// lower-case "a-z" 85// upper-case "A-Z" 86// alphabetic +lower-case +upper-case 87// alphanumeric +alphabetic +dec-digit 88// var-first +underscore +alphabetic 89// variable-name +var-first +dec-digit 90// option-name "^-" +variable-name 91// value-name +colon +option-name 92// name-sep "[.]" 93// compound-name +value-name +name-sep +horiz-white 94// scheme-note +parentheses +quote 95// 96// unquotable "!-~" -"#,;<=>[\\]`{}?*" -quote -parentheses 97// end-xml-token "/>" +whitespace 98// plus-n-space +plus +whitespace 99// punctuation "!-~" -alphanumeric -"_" 100// suffix "-._" +alphanumeric 101// suffix-fmt +percent +suffix +dir-sep 102// false-type "nNfF0" +nul-byte 103// file-name +dir-sep +suffix 104// end-token +nul-byte +whitespace 105// end-list-entry +comma +end-token 106// set-separator "|+-!" +end-list-entry 107// signed-number +inversion +dec-digit 108// make-script +dollar +newline 109// load-line-skip +horiz-white +option-marker 110// 111#endif /* 0 -- mapping spec. source */ 112 113 114typedef uint32_t ag_char_map_mask_t; 115 116#define IS_NEWLINE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000001) 117#define SPN_NEWLINE_CHARS(_s) spn_ag_char_map_chars(_s, 0) 118#define BRK_NEWLINE_CHARS(_s) brk_ag_char_map_chars(_s, 0) 119#define SPN_NEWLINE_BACK(s,e) spn_ag_char_map_back(s, e, 0) 120#define BRK_NEWLINE_BACK(s,e) brk_ag_char_map_back(s, e, 0) 121#define IS_NUL_BYTE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000002) 122#define SPN_NUL_BYTE_CHARS(_s) spn_ag_char_map_chars(_s, 1) 123#define BRK_NUL_BYTE_CHARS(_s) brk_ag_char_map_chars(_s, 1) 124#define SPN_NUL_BYTE_BACK(s,e) spn_ag_char_map_back(s, e, 1) 125#define BRK_NUL_BYTE_BACK(s,e) brk_ag_char_map_back(s, e, 1) 126#define IS_DIR_SEP_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000004) 127#define SPN_DIR_SEP_CHARS(_s) spn_ag_char_map_chars(_s, 2) 128#define BRK_DIR_SEP_CHARS(_s) brk_ag_char_map_chars(_s, 2) 129#define SPN_DIR_SEP_BACK(s,e) spn_ag_char_map_back(s, e, 2) 130#define BRK_DIR_SEP_BACK(s,e) brk_ag_char_map_back(s, e, 2) 131#define IS_PERCENT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000008) 132#define SPN_PERCENT_CHARS(_s) spn_ag_char_map_chars(_s, 3) 133#define BRK_PERCENT_CHARS(_s) brk_ag_char_map_chars(_s, 3) 134#define SPN_PERCENT_BACK(s,e) spn_ag_char_map_back(s, e, 3) 135#define BRK_PERCENT_BACK(s,e) brk_ag_char_map_back(s, e, 3) 136#define IS_COMMA_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000010) 137#define SPN_COMMA_CHARS(_s) spn_ag_char_map_chars(_s, 4) 138#define BRK_COMMA_CHARS(_s) brk_ag_char_map_chars(_s, 4) 139#define SPN_COMMA_BACK(s,e) spn_ag_char_map_back(s, e, 4) 140#define BRK_COMMA_BACK(s,e) brk_ag_char_map_back(s, e, 4) 141#define IS_COLON_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000020) 142#define SPN_COLON_CHARS(_s) spn_ag_char_map_chars(_s, 5) 143#define BRK_COLON_CHARS(_s) brk_ag_char_map_chars(_s, 5) 144#define SPN_COLON_BACK(s,e) spn_ag_char_map_back(s, e, 5) 145#define BRK_COLON_BACK(s,e) brk_ag_char_map_back(s, e, 5) 146#define IS_UNDERSCORE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000040) 147#define SPN_UNDERSCORE_CHARS(_s) spn_ag_char_map_chars(_s, 6) 148#define BRK_UNDERSCORE_CHARS(_s) brk_ag_char_map_chars(_s, 6) 149#define SPN_UNDERSCORE_BACK(s,e) spn_ag_char_map_back(s, e, 6) 150#define BRK_UNDERSCORE_BACK(s,e) brk_ag_char_map_back(s, e, 6) 151#define IS_PLUS_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000080) 152#define SPN_PLUS_CHARS(_s) spn_ag_char_map_chars(_s, 7) 153#define BRK_PLUS_CHARS(_s) brk_ag_char_map_chars(_s, 7) 154#define SPN_PLUS_BACK(s,e) spn_ag_char_map_back(s, e, 7) 155#define BRK_PLUS_BACK(s,e) brk_ag_char_map_back(s, e, 7) 156#define IS_DOLLAR_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000100) 157#define SPN_DOLLAR_CHARS(_s) spn_ag_char_map_chars(_s, 8) 158#define BRK_DOLLAR_CHARS(_s) brk_ag_char_map_chars(_s, 8) 159#define SPN_DOLLAR_BACK(s,e) spn_ag_char_map_back(s, e, 8) 160#define BRK_DOLLAR_BACK(s,e) brk_ag_char_map_back(s, e, 8) 161#define IS_OPTION_MARKER_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000200) 162#define SPN_OPTION_MARKER_CHARS(_s) spn_ag_char_map_chars(_s, 9) 163#define BRK_OPTION_MARKER_CHARS(_s) brk_ag_char_map_chars(_s, 9) 164#define SPN_OPTION_MARKER_BACK(s,e) spn_ag_char_map_back(s, e, 9) 165#define BRK_OPTION_MARKER_BACK(s,e) brk_ag_char_map_back(s, e, 9) 166#define IS_HORIZ_WHITE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000400) 167#define SPN_HORIZ_WHITE_CHARS(_s) spn_ag_char_map_chars(_s, 10) 168#define BRK_HORIZ_WHITE_CHARS(_s) brk_ag_char_map_chars(_s, 10) 169#define SPN_HORIZ_WHITE_BACK(s,e) spn_ag_char_map_back(s, e, 10) 170#define BRK_HORIZ_WHITE_BACK(s,e) brk_ag_char_map_back(s, e, 10) 171#define IS_ALT_WHITE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000800) 172#define SPN_ALT_WHITE_CHARS(_s) spn_ag_char_map_chars(_s, 11) 173#define BRK_ALT_WHITE_CHARS(_s) brk_ag_char_map_chars(_s, 11) 174#define SPN_ALT_WHITE_BACK(s,e) spn_ag_char_map_back(s, e, 11) 175#define BRK_ALT_WHITE_BACK(s,e) brk_ag_char_map_back(s, e, 11) 176#define IS_WHITESPACE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C01) 177#define SPN_WHITESPACE_CHARS(_s) spn_ag_char_map_chars(_s, 12) 178#define BRK_WHITESPACE_CHARS(_s) brk_ag_char_map_chars(_s, 12) 179#define SPN_WHITESPACE_BACK(s,e) spn_ag_char_map_back(s, e, 12) 180#define BRK_WHITESPACE_BACK(s,e) brk_ag_char_map_back(s, e, 12) 181#define IS_NON_NL_WHITE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C00) 182#define SPN_NON_NL_WHITE_CHARS(_s) spn_ag_char_map_chars(_s, 13) 183#define BRK_NON_NL_WHITE_CHARS(_s) brk_ag_char_map_chars(_s, 13) 184#define SPN_NON_NL_WHITE_BACK(s,e) spn_ag_char_map_back(s, e, 13) 185#define BRK_NON_NL_WHITE_BACK(s,e) brk_ag_char_map_back(s, e, 13) 186#define IS_QUOTE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00001000) 187#define SPN_QUOTE_CHARS(_s) spn_ag_char_map_chars(_s, 14) 188#define BRK_QUOTE_CHARS(_s) brk_ag_char_map_chars(_s, 14) 189#define SPN_QUOTE_BACK(s,e) spn_ag_char_map_back(s, e, 14) 190#define BRK_QUOTE_BACK(s,e) brk_ag_char_map_back(s, e, 14) 191#define IS_PARENTHESES_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00002000) 192#define SPN_PARENTHESES_CHARS(_s) spn_ag_char_map_chars(_s, 15) 193#define BRK_PARENTHESES_CHARS(_s) brk_ag_char_map_chars(_s, 15) 194#define SPN_PARENTHESES_BACK(s,e) spn_ag_char_map_back(s, e, 15) 195#define BRK_PARENTHESES_BACK(s,e) brk_ag_char_map_back(s, e, 15) 196#define IS_GRAPHIC_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00004000) 197#define SPN_GRAPHIC_CHARS(_s) spn_ag_char_map_chars(_s, 16) 198#define BRK_GRAPHIC_CHARS(_s) brk_ag_char_map_chars(_s, 16) 199#define SPN_GRAPHIC_BACK(s,e) spn_ag_char_map_back(s, e, 16) 200#define BRK_GRAPHIC_BACK(s,e) brk_ag_char_map_back(s, e, 16) 201#define IS_INVERSION_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00008000) 202#define SPN_INVERSION_CHARS(_s) spn_ag_char_map_chars(_s, 17) 203#define BRK_INVERSION_CHARS(_s) brk_ag_char_map_chars(_s, 17) 204#define SPN_INVERSION_BACK(s,e) spn_ag_char_map_back(s, e, 17) 205#define BRK_INVERSION_BACK(s,e) brk_ag_char_map_back(s, e, 17) 206#define IS_OCT_DIGIT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00010000) 207#define SPN_OCT_DIGIT_CHARS(_s) spn_ag_char_map_chars(_s, 18) 208#define BRK_OCT_DIGIT_CHARS(_s) brk_ag_char_map_chars(_s, 18) 209#define SPN_OCT_DIGIT_BACK(s,e) spn_ag_char_map_back(s, e, 18) 210#define BRK_OCT_DIGIT_BACK(s,e) brk_ag_char_map_back(s, e, 18) 211#define IS_DEC_DIGIT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00030000) 212#define SPN_DEC_DIGIT_CHARS(_s) spn_ag_char_map_chars(_s, 19) 213#define BRK_DEC_DIGIT_CHARS(_s) brk_ag_char_map_chars(_s, 19) 214#define SPN_DEC_DIGIT_BACK(s,e) spn_ag_char_map_back(s, e, 19) 215#define BRK_DEC_DIGIT_BACK(s,e) brk_ag_char_map_back(s, e, 19) 216#define IS_HEX_DIGIT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00070000) 217#define SPN_HEX_DIGIT_CHARS(_s) spn_ag_char_map_chars(_s, 20) 218#define BRK_HEX_DIGIT_CHARS(_s) brk_ag_char_map_chars(_s, 20) 219#define SPN_HEX_DIGIT_BACK(s,e) spn_ag_char_map_back(s, e, 20) 220#define BRK_HEX_DIGIT_BACK(s,e) brk_ag_char_map_back(s, e, 20) 221#define IS_LOWER_CASE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00080000) 222#define SPN_LOWER_CASE_CHARS(_s) spn_ag_char_map_chars(_s, 21) 223#define BRK_LOWER_CASE_CHARS(_s) brk_ag_char_map_chars(_s, 21) 224#define SPN_LOWER_CASE_BACK(s,e) spn_ag_char_map_back(s, e, 21) 225#define BRK_LOWER_CASE_BACK(s,e) brk_ag_char_map_back(s, e, 21) 226#define IS_UPPER_CASE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00100000) 227#define SPN_UPPER_CASE_CHARS(_s) spn_ag_char_map_chars(_s, 22) 228#define BRK_UPPER_CASE_CHARS(_s) brk_ag_char_map_chars(_s, 22) 229#define SPN_UPPER_CASE_BACK(s,e) spn_ag_char_map_back(s, e, 22) 230#define BRK_UPPER_CASE_BACK(s,e) brk_ag_char_map_back(s, e, 22) 231#define IS_ALPHABETIC_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00180000) 232#define SPN_ALPHABETIC_CHARS(_s) spn_ag_char_map_chars(_s, 23) 233#define BRK_ALPHABETIC_CHARS(_s) brk_ag_char_map_chars(_s, 23) 234#define SPN_ALPHABETIC_BACK(s,e) spn_ag_char_map_back(s, e, 23) 235#define BRK_ALPHABETIC_BACK(s,e) brk_ag_char_map_back(s, e, 23) 236#define IS_ALPHANUMERIC_CHAR( _c) is_ag_char_map_char((char)(_c), 0x001B0000) 237#define SPN_ALPHANUMERIC_CHARS(_s) spn_ag_char_map_chars(_s, 24) 238#define BRK_ALPHANUMERIC_CHARS(_s) brk_ag_char_map_chars(_s, 24) 239#define SPN_ALPHANUMERIC_BACK(s,e) spn_ag_char_map_back(s, e, 24) 240#define BRK_ALPHANUMERIC_BACK(s,e) brk_ag_char_map_back(s, e, 24) 241#define IS_VAR_FIRST_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00180040) 242#define SPN_VAR_FIRST_CHARS(_s) spn_ag_char_map_chars(_s, 25) 243#define BRK_VAR_FIRST_CHARS(_s) brk_ag_char_map_chars(_s, 25) 244#define SPN_VAR_FIRST_BACK(s,e) spn_ag_char_map_back(s, e, 25) 245#define BRK_VAR_FIRST_BACK(s,e) brk_ag_char_map_back(s, e, 25) 246#define IS_VARIABLE_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x001B0040) 247#define SPN_VARIABLE_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 26) 248#define BRK_VARIABLE_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 26) 249#define SPN_VARIABLE_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 26) 250#define BRK_VARIABLE_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 26) 251#define IS_OPTION_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x003B0040) 252#define SPN_OPTION_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 27) 253#define BRK_OPTION_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 27) 254#define SPN_OPTION_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 27) 255#define BRK_OPTION_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 27) 256#define IS_VALUE_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x003B0060) 257#define SPN_VALUE_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 28) 258#define BRK_VALUE_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 28) 259#define SPN_VALUE_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 28) 260#define BRK_VALUE_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 28) 261#define IS_NAME_SEP_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00400000) 262#define SPN_NAME_SEP_CHARS(_s) spn_ag_char_map_chars(_s, 29) 263#define BRK_NAME_SEP_CHARS(_s) brk_ag_char_map_chars(_s, 29) 264#define SPN_NAME_SEP_BACK(s,e) spn_ag_char_map_back(s, e, 29) 265#define BRK_NAME_SEP_BACK(s,e) brk_ag_char_map_back(s, e, 29) 266#define IS_COMPOUND_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x007B0460) 267#define SPN_COMPOUND_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 30) 268#define BRK_COMPOUND_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 30) 269#define SPN_COMPOUND_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 30) 270#define BRK_COMPOUND_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 30) 271#define IS_SCHEME_NOTE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00003000) 272#define SPN_SCHEME_NOTE_CHARS(_s) spn_ag_char_map_chars(_s, 31) 273#define BRK_SCHEME_NOTE_CHARS(_s) brk_ag_char_map_chars(_s, 31) 274#define SPN_SCHEME_NOTE_BACK(s,e) spn_ag_char_map_back(s, e, 31) 275#define BRK_SCHEME_NOTE_BACK(s,e) brk_ag_char_map_back(s, e, 31) 276#define IS_UNQUOTABLE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00800000) 277#define SPN_UNQUOTABLE_CHARS(_s) spn_ag_char_map_chars(_s, 32) 278#define BRK_UNQUOTABLE_CHARS(_s) brk_ag_char_map_chars(_s, 32) 279#define SPN_UNQUOTABLE_BACK(s,e) spn_ag_char_map_back(s, e, 32) 280#define BRK_UNQUOTABLE_BACK(s,e) brk_ag_char_map_back(s, e, 32) 281#define IS_END_XML_TOKEN_CHAR( _c) is_ag_char_map_char((char)(_c), 0x01000C01) 282#define SPN_END_XML_TOKEN_CHARS(_s) spn_ag_char_map_chars(_s, 33) 283#define BRK_END_XML_TOKEN_CHARS(_s) brk_ag_char_map_chars(_s, 33) 284#define SPN_END_XML_TOKEN_BACK(s,e) spn_ag_char_map_back(s, e, 33) 285#define BRK_END_XML_TOKEN_BACK(s,e) brk_ag_char_map_back(s, e, 33) 286#define IS_PLUS_N_SPACE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C81) 287#define SPN_PLUS_N_SPACE_CHARS(_s) spn_ag_char_map_chars(_s, 34) 288#define BRK_PLUS_N_SPACE_CHARS(_s) brk_ag_char_map_chars(_s, 34) 289#define SPN_PLUS_N_SPACE_BACK(s,e) spn_ag_char_map_back(s, e, 34) 290#define BRK_PLUS_N_SPACE_BACK(s,e) brk_ag_char_map_back(s, e, 34) 291#define IS_PUNCTUATION_CHAR( _c) is_ag_char_map_char((char)(_c), 0x02000000) 292#define SPN_PUNCTUATION_CHARS(_s) spn_ag_char_map_chars(_s, 35) 293#define BRK_PUNCTUATION_CHARS(_s) brk_ag_char_map_chars(_s, 35) 294#define SPN_PUNCTUATION_BACK(s,e) spn_ag_char_map_back(s, e, 35) 295#define BRK_PUNCTUATION_BACK(s,e) brk_ag_char_map_back(s, e, 35) 296#define IS_SUFFIX_CHAR( _c) is_ag_char_map_char((char)(_c), 0x041B0000) 297#define SPN_SUFFIX_CHARS(_s) spn_ag_char_map_chars(_s, 36) 298#define BRK_SUFFIX_CHARS(_s) brk_ag_char_map_chars(_s, 36) 299#define SPN_SUFFIX_BACK(s,e) spn_ag_char_map_back(s, e, 36) 300#define BRK_SUFFIX_BACK(s,e) brk_ag_char_map_back(s, e, 36) 301#define IS_SUFFIX_FMT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x041B000C) 302#define SPN_SUFFIX_FMT_CHARS(_s) spn_ag_char_map_chars(_s, 37) 303#define BRK_SUFFIX_FMT_CHARS(_s) brk_ag_char_map_chars(_s, 37) 304#define SPN_SUFFIX_FMT_BACK(s,e) spn_ag_char_map_back(s, e, 37) 305#define BRK_SUFFIX_FMT_BACK(s,e) brk_ag_char_map_back(s, e, 37) 306#define IS_FALSE_TYPE_CHAR( _c) is_ag_char_map_char((char)(_c), 0x08000002) 307#define SPN_FALSE_TYPE_CHARS(_s) spn_ag_char_map_chars(_s, 38) 308#define BRK_FALSE_TYPE_CHARS(_s) brk_ag_char_map_chars(_s, 38) 309#define SPN_FALSE_TYPE_BACK(s,e) spn_ag_char_map_back(s, e, 38) 310#define BRK_FALSE_TYPE_BACK(s,e) brk_ag_char_map_back(s, e, 38) 311#define IS_FILE_NAME_CHAR( _c) is_ag_char_map_char((char)(_c), 0x041B0004) 312#define SPN_FILE_NAME_CHARS(_s) spn_ag_char_map_chars(_s, 39) 313#define BRK_FILE_NAME_CHARS(_s) brk_ag_char_map_chars(_s, 39) 314#define SPN_FILE_NAME_BACK(s,e) spn_ag_char_map_back(s, e, 39) 315#define BRK_FILE_NAME_BACK(s,e) brk_ag_char_map_back(s, e, 39) 316#define IS_END_TOKEN_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C03) 317#define SPN_END_TOKEN_CHARS(_s) spn_ag_char_map_chars(_s, 40) 318#define BRK_END_TOKEN_CHARS(_s) brk_ag_char_map_chars(_s, 40) 319#define SPN_END_TOKEN_BACK(s,e) spn_ag_char_map_back(s, e, 40) 320#define BRK_END_TOKEN_BACK(s,e) brk_ag_char_map_back(s, e, 40) 321#define IS_END_LIST_ENTRY_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000C13) 322#define SPN_END_LIST_ENTRY_CHARS(_s) spn_ag_char_map_chars(_s, 41) 323#define BRK_END_LIST_ENTRY_CHARS(_s) brk_ag_char_map_chars(_s, 41) 324#define SPN_END_LIST_ENTRY_BACK(s,e) spn_ag_char_map_back(s, e, 41) 325#define BRK_END_LIST_ENTRY_BACK(s,e) brk_ag_char_map_back(s, e, 41) 326#define IS_SET_SEPARATOR_CHAR( _c) is_ag_char_map_char((char)(_c), 0x10000C13) 327#define SPN_SET_SEPARATOR_CHARS(_s) spn_ag_char_map_chars(_s, 42) 328#define BRK_SET_SEPARATOR_CHARS(_s) brk_ag_char_map_chars(_s, 42) 329#define SPN_SET_SEPARATOR_BACK(s,e) spn_ag_char_map_back(s, e, 42) 330#define BRK_SET_SEPARATOR_BACK(s,e) brk_ag_char_map_back(s, e, 42) 331#define IS_SIGNED_NUMBER_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00038000) 332#define SPN_SIGNED_NUMBER_CHARS(_s) spn_ag_char_map_chars(_s, 43) 333#define BRK_SIGNED_NUMBER_CHARS(_s) brk_ag_char_map_chars(_s, 43) 334#define SPN_SIGNED_NUMBER_BACK(s,e) spn_ag_char_map_back(s, e, 43) 335#define BRK_SIGNED_NUMBER_BACK(s,e) brk_ag_char_map_back(s, e, 43) 336#define IS_MAKE_SCRIPT_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000101) 337#define SPN_MAKE_SCRIPT_CHARS(_s) spn_ag_char_map_chars(_s, 44) 338#define BRK_MAKE_SCRIPT_CHARS(_s) brk_ag_char_map_chars(_s, 44) 339#define SPN_MAKE_SCRIPT_BACK(s,e) spn_ag_char_map_back(s, e, 44) 340#define BRK_MAKE_SCRIPT_BACK(s,e) brk_ag_char_map_back(s, e, 44) 341#define IS_LOAD_LINE_SKIP_CHAR( _c) is_ag_char_map_char((char)(_c), 0x00000600) 342#define SPN_LOAD_LINE_SKIP_CHARS(_s) spn_ag_char_map_chars(_s, 45) 343#define BRK_LOAD_LINE_SKIP_CHARS(_s) brk_ag_char_map_chars(_s, 45) 344#define SPN_LOAD_LINE_SKIP_BACK(s,e) spn_ag_char_map_back(s, e, 45) 345#define BRK_LOAD_LINE_SKIP_BACK(s,e) brk_ag_char_map_back(s, e, 45) 346 347static ag_char_map_mask_t const ag_char_map_table[128] = { 348 /*NUL*/ 0x00000002, /*x01*/ 0x00000000, /*x02*/ 0x00000000, /*x03*/ 0x00000000, 349 /*x04*/ 0x00000000, /*x05*/ 0x00000000, /*x06*/ 0x00000000, /*BEL*/ 0x00000000, 350 /* BS*/ 0x00000800, /* HT*/ 0x00000400, /* NL*/ 0x00000001, /* VT*/ 0x00000800, 351 /* FF*/ 0x00000800, /* CR*/ 0x00000800, /*x0E*/ 0x00000000, /*x0F*/ 0x00000000, 352 /*x10*/ 0x00000000, /*x11*/ 0x00000000, /*x12*/ 0x00000000, /*x13*/ 0x00000000, 353 /*x14*/ 0x00000000, /*x15*/ 0x00000000, /*x16*/ 0x00000000, /*x17*/ 0x00000000, 354 /*x18*/ 0x00000000, /*x19*/ 0x00000000, /*x1A*/ 0x00000000, /*ESC*/ 0x00000000, 355 /*x1C*/ 0x00000000, /*x1D*/ 0x00000000, /*x1E*/ 0x00000000, /*x1F*/ 0x00000000, 356 /* */ 0x00000400, /* ! */ 0x02804000, /* " */ 0x02005000, /* # */ 0x02004000, 357 /* $ */ 0x02804100, /* % */ 0x02804008, /* & */ 0x02804000, /* ' */ 0x02005000, 358 /* ( */ 0x02006000, /* ) */ 0x02006000, /* * */ 0x02004000, /* + */ 0x12804080, 359 /* , */ 0x02004010, /* - */ 0x06A0C200, /* . */ 0x06C04000, /* / */ 0x03804004, 360 /* 0 */ 0x08814000, /* 1 */ 0x00814000, /* 2 */ 0x00814000, /* 3 */ 0x00814000, 361 /* 4 */ 0x00814000, /* 5 */ 0x00814000, /* 6 */ 0x00814000, /* 7 */ 0x00814000, 362 /* 8 */ 0x00824000, /* 9 */ 0x00824000, /* : */ 0x02804020, /* ; */ 0x02004000, 363 /* < */ 0x02004000, /* = */ 0x02004000, /* > */ 0x03004000, /* ? */ 0x02004000, 364 /* @ */ 0x02804000, /* A */ 0x00944000, /* B */ 0x00944000, /* C */ 0x00944000, 365 /* D */ 0x00944000, /* E */ 0x00944000, /* F */ 0x08944000, /* G */ 0x00904000, 366 /* H */ 0x00904000, /* I */ 0x00904000, /* J */ 0x00904000, /* K */ 0x00904000, 367 /* L */ 0x00904000, /* M */ 0x00904000, /* N */ 0x08904000, /* O */ 0x00904000, 368 /* P */ 0x00904000, /* Q */ 0x00904000, /* R */ 0x00904000, /* S */ 0x00904000, 369 /* T */ 0x00904000, /* U */ 0x00904000, /* V */ 0x00904000, /* W */ 0x00904000, 370 /* X */ 0x00904000, /* Y */ 0x00904000, /* Z */ 0x00904000, /* [ */ 0x02404000, 371 /* \ */ 0x02004004, /* ] */ 0x02404000, /* ^ */ 0x02A04000, /* _ */ 0x04804040, 372 /* ` */ 0x02004000, /* a */ 0x008C4000, /* b */ 0x008C4000, /* c */ 0x008C4000, 373 /* d */ 0x008C4000, /* e */ 0x008C4000, /* f */ 0x088C4000, /* g */ 0x00884000, 374 /* h */ 0x00884000, /* i */ 0x00884000, /* j */ 0x00884000, /* k */ 0x00884000, 375 /* l */ 0x00884000, /* m */ 0x00884000, /* n */ 0x08884000, /* o */ 0x00884000, 376 /* p */ 0x00884000, /* q */ 0x00884000, /* r */ 0x00884000, /* s */ 0x00884000, 377 /* t */ 0x00884000, /* u */ 0x00884000, /* v */ 0x00884000, /* w */ 0x00884000, 378 /* x */ 0x00884000, /* y */ 0x00884000, /* z */ 0x00884000, /* { */ 0x02004000, 379 /* | */ 0x12804000, /* } */ 0x02004000, /* ~ */ 0x0280C000, /*x7F*/ 0x00000000 380}; 381 382#include <stdio.h> 383#include <stdlib.h> 384#include <string.h> 385 386#ifndef _ 387# define _(_s) _s 388#endif 389 390static unsigned char const * ag_char_map_spanners[46]; 391/** 392 * Character category masks. Some categories may have multiple bits, 393 * if their definition incorporates other character categories. 394 * This mask array is only used by calc_ag_char_map_spanners(). 395 */ 396static ag_char_map_mask_t const ag_char_map_masks[46] = { 397 0x00000001, /* NEWLINE */ 398 0x00000002, /* NUL_BYTE */ 399 0x00000004, /* DIR_SEP */ 400 0x00000008, /* PERCENT */ 401 0x00000010, /* COMMA */ 402 0x00000020, /* COLON */ 403 0x00000040, /* UNDERSCORE */ 404 0x00000080, /* PLUS */ 405 0x00000100, /* DOLLAR */ 406 0x00000200, /* OPTION_MARKER */ 407 0x00000400, /* HORIZ_WHITE */ 408 0x00000800, /* ALT_WHITE */ 409 0x00000C01, /* WHITESPACE */ 410 0x00000C00, /* NON_NL_WHITE */ 411 0x00001000, /* QUOTE */ 412 0x00002000, /* PARENTHESES */ 413 0x00004000, /* GRAPHIC */ 414 0x00008000, /* INVERSION */ 415 0x00010000, /* OCT_DIGIT */ 416 0x00030000, /* DEC_DIGIT */ 417 0x00070000, /* HEX_DIGIT */ 418 0x00080000, /* LOWER_CASE */ 419 0x00100000, /* UPPER_CASE */ 420 0x00180000, /* ALPHABETIC */ 421 0x001B0000, /* ALPHANUMERIC */ 422 0x00180040, /* VAR_FIRST */ 423 0x001B0040, /* VARIABLE_NAME */ 424 0x003B0040, /* OPTION_NAME */ 425 0x003B0060, /* VALUE_NAME */ 426 0x00400000, /* NAME_SEP */ 427 0x007B0460, /* COMPOUND_NAME */ 428 0x00003000, /* SCHEME_NOTE */ 429 0x00800000, /* UNQUOTABLE */ 430 0x01000C01, /* END_XML_TOKEN */ 431 0x00000C81, /* PLUS_N_SPACE */ 432 0x02000000, /* PUNCTUATION */ 433 0x041B0000, /* SUFFIX */ 434 0x041B000C, /* SUFFIX_FMT */ 435 0x08000002, /* FALSE_TYPE */ 436 0x041B0004, /* FILE_NAME */ 437 0x00000C03, /* END_TOKEN */ 438 0x00000C13, /* END_LIST_ENTRY */ 439 0x10000C13, /* SET_SEPARATOR */ 440 0x00038000, /* SIGNED_NUMBER */ 441 0x00000101, /* MAKE_SCRIPT */ 442 0x00000600, /* LOAD_LINE_SKIP */ 443}; 444#undef LOCK_SPANNER_TABLES 445 446static unsigned char const * 447calc_ag_char_map_spanners(unsigned int mask_ix) 448{ 449#ifdef LOCK_SPANNER_TABLES 450 if (ag_char_map_spanners[mask_ix] != NULL) 451 return ag_char_map_spanners[mask_ix]; 452 453 pthread_mutex_lock(&ag_char_map_mutex); 454 if (ag_char_map_spanners[mask_ix] == NULL) 455#endif 456 { 457 int ix = 1; 458 ag_char_map_mask_t mask = ag_char_map_masks[mask_ix]; 459 unsigned char * res = malloc(256 /* 1 << NBBY */); 460 if (res == NULL) { 461 fputs(_("no memory for char-mapper span map\n"), stderr); 462 exit(EXIT_FAILURE); 463 } 464 465 memset(res, 0, 256); 466 for (; ix < 128; ix++) 467 if (ag_char_map_table[ix] & mask) 468 res[ix] = 1; 469 ag_char_map_spanners[mask_ix] = res; 470 } 471#ifdef LOCK_SPANNER_TABLES 472 pthread_mutex_unlock(&ag_char_map_mutex); 473#endif 474 return ag_char_map_spanners[mask_ix]; 475} 476#define ag_char_map_masks POISONED_ag_char_map_masks 477 478static inline int 479is_ag_char_map_char(char ch, ag_char_map_mask_t mask) 480{ 481 unsigned int ix = (unsigned char)ch; 482 return ((ix < 128) && ((ag_char_map_table[ix] & mask) != 0)); 483} 484 485static inline char * 486spn_ag_char_map_chars(char const * p, unsigned int mask_ix) 487{ 488 unsigned char const * v = ag_char_map_spanners[mask_ix]; 489 if (v == NULL) 490 v = calc_ag_char_map_spanners(mask_ix); 491 while (v[(unsigned char)*p]) p++; 492 return (char *)(uintptr_t)p; 493} 494 495static inline char * 496brk_ag_char_map_chars(char const * p, unsigned int mask_ix) 497{ 498 unsigned char const * v = ag_char_map_spanners[mask_ix]; 499 if (v == NULL) 500 v = calc_ag_char_map_spanners(mask_ix); 501 while ((*p != '\0') && (! v[(unsigned char)*p])) p++; 502 return (char *)(uintptr_t)p; 503} 504 505static inline char * 506spn_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix) 507{ 508 unsigned char const * v = ag_char_map_spanners[mask_ix]; 509 if (v == NULL) 510 v = calc_ag_char_map_spanners(mask_ix); 511 if (s >= e) e = s + strlen(s); 512 while ((e > s) && v[(unsigned char)e[-1]]) e--; 513 return (char *)(uintptr_t)e; 514} 515 516static inline char * 517brk_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix) 518{ 519 unsigned char const * v = ag_char_map_spanners[mask_ix]; 520 if (v == NULL) 521 v = calc_ag_char_map_spanners(mask_ix); 522 if (s == e) e += strlen(e); 523 while ((e > s) && (! v[(unsigned char)e[-1]])) e--; 524 return (char *)(uintptr_t)e; 525} 526#endif /* AG_CHAR_MAP_H_GUARD */ 527