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