xref: /freebsd/contrib/ntp/sntp/libopts/ag-char-map.h (revision a466cc55373fc3cf86837f09da729535b57e69a1)
12b15cb3dSCy Schubert /*
22b15cb3dSCy Schubert  *  29 bits for 46 character classifications
3*a466cc55SCy Schubert  *  generated by char-mapper on 08/26/18 at 10:44:22
42b15cb3dSCy Schubert  *
52b15cb3dSCy Schubert  *  This file contains the character classifications
62b15cb3dSCy Schubert  *  used by AutoGen and AutoOpts for identifying tokens.
72b15cb3dSCy Schubert  *  The table is static scope, so %guard is empty.
82b15cb3dSCy Schubert  *
92b15cb3dSCy Schubert  *  This file is part of AutoOpts, a companion to AutoGen.
102b15cb3dSCy Schubert  *  AutoOpts is free software.
11*a466cc55SCy Schubert  *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
122b15cb3dSCy Schubert  *
132b15cb3dSCy Schubert  *  AutoOpts is available under any one of two licenses.  The license
142b15cb3dSCy Schubert  *  in use must be one of these two and the choice is under the control
152b15cb3dSCy Schubert  *  of the user of the license.
162b15cb3dSCy Schubert  *
172b15cb3dSCy Schubert  *  The GNU Lesser General Public License, version 3 or later
182b15cb3dSCy Schubert  *  See the files "COPYING.lgplv3" and "COPYING.gplv3"
192b15cb3dSCy Schubert  *
202b15cb3dSCy Schubert  *  The Modified Berkeley Software Distribution License
212b15cb3dSCy Schubert  *  See the file "COPYING.mbsd"
222b15cb3dSCy Schubert  *
232b15cb3dSCy Schubert  *  These files have the following sha256 sums:
242b15cb3dSCy Schubert  *
252b15cb3dSCy Schubert  *  8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95  COPYING.gplv3
262b15cb3dSCy Schubert  *  4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b  COPYING.lgplv3
272b15cb3dSCy Schubert  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
282b15cb3dSCy Schubert  */
292b15cb3dSCy Schubert #ifndef AG_CHAR_MAP_H_GUARD
302b15cb3dSCy Schubert #define AG_CHAR_MAP_H_GUARD 1
312b15cb3dSCy Schubert 
322b15cb3dSCy Schubert #ifdef HAVE_CONFIG_H
332b15cb3dSCy Schubert # if defined(HAVE_INTTYPES_H)
342b15cb3dSCy Schubert #   include <inttypes.h>
352b15cb3dSCy Schubert 
362b15cb3dSCy Schubert # elif defined(HAVE_STDINT_H)
372b15cb3dSCy Schubert #   include <stdint.h>
382b15cb3dSCy Schubert 
392b15cb3dSCy Schubert # elif !defined(HAVE_UINT32_T)
402b15cb3dSCy Schubert #   if SIZEOF_INT == 4
412b15cb3dSCy Schubert       typedef unsigned int    uint32_t;
422b15cb3dSCy Schubert #   elif SIZEOF_LONG == 4
432b15cb3dSCy Schubert       typedef unsigned long   uint32_t;
442b15cb3dSCy Schubert #   endif
452b15cb3dSCy Schubert # endif /* HAVE_*INT*_H header */
462b15cb3dSCy Schubert 
472b15cb3dSCy Schubert #else /* not HAVE_CONFIG_H -- */
482b15cb3dSCy Schubert # include <inttypes.h>
492b15cb3dSCy Schubert #endif /* HAVE_CONFIG_H */
502b15cb3dSCy Schubert 
512b15cb3dSCy Schubert #if 0 /* mapping specification source (from autogen.map) */
522b15cb3dSCy Schubert //
532b15cb3dSCy Schubert // %guard
542b15cb3dSCy Schubert // %file           ag-char-map.h
552b15cb3dSCy Schubert // %backup
562b15cb3dSCy Schubert // %optimize
572b15cb3dSCy Schubert //
582b15cb3dSCy Schubert // %comment -- see above
592b15cb3dSCy Schubert // %
602b15cb3dSCy Schubert //
612b15cb3dSCy Schubert // newline         "\n"
622b15cb3dSCy Schubert // nul-byte        "\x00"
632b15cb3dSCy Schubert // dir-sep         "/\\"
642b15cb3dSCy Schubert // percent         "%"
652b15cb3dSCy Schubert // comma           ","
662b15cb3dSCy Schubert // colon           ":"
672b15cb3dSCy Schubert // underscore      "_"
682b15cb3dSCy Schubert // plus            "+"
692b15cb3dSCy Schubert // dollar          "$"
702b15cb3dSCy Schubert // option-marker   "-"
712b15cb3dSCy Schubert //
722b15cb3dSCy Schubert // horiz-white     "\t "
732b15cb3dSCy Schubert // alt-white       "\v\f\r\b"
742b15cb3dSCy Schubert // whitespace      +horiz-white  +newline +alt-white
752b15cb3dSCy Schubert // non-nl-white    +horiz-white  +alt-white
762b15cb3dSCy Schubert // quote           "'\""
772b15cb3dSCy Schubert // parentheses     "()"
782b15cb3dSCy Schubert //
792b15cb3dSCy Schubert // graphic         "!-~"
802b15cb3dSCy Schubert // inversion       "~-"
812b15cb3dSCy Schubert // oct-digit       "0-7"
822b15cb3dSCy Schubert // dec-digit       "89"          +oct-digit
832b15cb3dSCy Schubert // hex-digit       "a-fA-F"      +dec-digit
842b15cb3dSCy Schubert // lower-case      "a-z"
852b15cb3dSCy Schubert // upper-case      "A-Z"
862b15cb3dSCy Schubert // alphabetic      +lower-case   +upper-case
872b15cb3dSCy Schubert // alphanumeric    +alphabetic   +dec-digit
882b15cb3dSCy Schubert // var-first       +underscore   +alphabetic
892b15cb3dSCy Schubert // variable-name   +var-first    +dec-digit
902b15cb3dSCy Schubert // option-name     "^-"          +variable-name
912b15cb3dSCy Schubert // value-name      +colon        +option-name
922b15cb3dSCy Schubert // name-sep        "[.]"
932b15cb3dSCy Schubert // compound-name   +value-name   +name-sep +horiz-white
942b15cb3dSCy Schubert // scheme-note     +parentheses  +quote
952b15cb3dSCy Schubert //
962b15cb3dSCy Schubert // unquotable      "!-~"         -"#,;<=>[\\]`{}?*" -quote -parentheses
972b15cb3dSCy Schubert // end-xml-token   "/>"          +whitespace
982b15cb3dSCy Schubert // plus-n-space    +plus         +whitespace
992b15cb3dSCy Schubert // punctuation     "!-~"         -alphanumeric -"_"
1002b15cb3dSCy Schubert // suffix          "-._"         +alphanumeric
1012b15cb3dSCy Schubert // suffix-fmt      +percent      +suffix +dir-sep
1022b15cb3dSCy Schubert // false-type      "nNfF0"       +nul-byte
1032b15cb3dSCy Schubert // file-name       +dir-sep      +suffix
1042b15cb3dSCy Schubert // end-token       +nul-byte     +whitespace
1052b15cb3dSCy Schubert // end-list-entry  +comma        +end-token
1062b15cb3dSCy Schubert // set-separator   "|+-!"        +end-list-entry
1072b15cb3dSCy Schubert // signed-number   +inversion    +dec-digit
1082b15cb3dSCy Schubert // make-script     +dollar       +newline
1092b15cb3dSCy Schubert // load-line-skip  +horiz-white  +option-marker
1102b15cb3dSCy Schubert //
1112b15cb3dSCy Schubert #endif /* 0 -- mapping spec. source */
1122b15cb3dSCy Schubert 
1132b15cb3dSCy Schubert 
1142b15cb3dSCy Schubert typedef uint32_t ag_char_map_mask_t;
1152b15cb3dSCy Schubert 
1162b15cb3dSCy Schubert #define  IS_NEWLINE_CHAR( _c)          is_ag_char_map_char((char)(_c), 0x00000001)
1172b15cb3dSCy Schubert #define SPN_NEWLINE_CHARS(_s)         spn_ag_char_map_chars(_s, 0)
1182b15cb3dSCy Schubert #define BRK_NEWLINE_CHARS(_s)         brk_ag_char_map_chars(_s, 0)
1192b15cb3dSCy Schubert #define SPN_NEWLINE_BACK(s,e)         spn_ag_char_map_back(s, e, 0)
1202b15cb3dSCy Schubert #define BRK_NEWLINE_BACK(s,e)         brk_ag_char_map_back(s, e, 0)
1212b15cb3dSCy Schubert #define  IS_NUL_BYTE_CHAR( _c)         is_ag_char_map_char((char)(_c), 0x00000002)
1222b15cb3dSCy Schubert #define SPN_NUL_BYTE_CHARS(_s)        spn_ag_char_map_chars(_s, 1)
1232b15cb3dSCy Schubert #define BRK_NUL_BYTE_CHARS(_s)        brk_ag_char_map_chars(_s, 1)
1242b15cb3dSCy Schubert #define SPN_NUL_BYTE_BACK(s,e)        spn_ag_char_map_back(s, e, 1)
1252b15cb3dSCy Schubert #define BRK_NUL_BYTE_BACK(s,e)        brk_ag_char_map_back(s, e, 1)
1262b15cb3dSCy Schubert #define  IS_DIR_SEP_CHAR( _c)          is_ag_char_map_char((char)(_c), 0x00000004)
1272b15cb3dSCy Schubert #define SPN_DIR_SEP_CHARS(_s)         spn_ag_char_map_chars(_s, 2)
1282b15cb3dSCy Schubert #define BRK_DIR_SEP_CHARS(_s)         brk_ag_char_map_chars(_s, 2)
1292b15cb3dSCy Schubert #define SPN_DIR_SEP_BACK(s,e)         spn_ag_char_map_back(s, e, 2)
1302b15cb3dSCy Schubert #define BRK_DIR_SEP_BACK(s,e)         brk_ag_char_map_back(s, e, 2)
1312b15cb3dSCy Schubert #define  IS_PERCENT_CHAR( _c)          is_ag_char_map_char((char)(_c), 0x00000008)
1322b15cb3dSCy Schubert #define SPN_PERCENT_CHARS(_s)         spn_ag_char_map_chars(_s, 3)
1332b15cb3dSCy Schubert #define BRK_PERCENT_CHARS(_s)         brk_ag_char_map_chars(_s, 3)
1342b15cb3dSCy Schubert #define SPN_PERCENT_BACK(s,e)         spn_ag_char_map_back(s, e, 3)
1352b15cb3dSCy Schubert #define BRK_PERCENT_BACK(s,e)         brk_ag_char_map_back(s, e, 3)
1362b15cb3dSCy Schubert #define  IS_COMMA_CHAR( _c)            is_ag_char_map_char((char)(_c), 0x00000010)
1372b15cb3dSCy Schubert #define SPN_COMMA_CHARS(_s)           spn_ag_char_map_chars(_s, 4)
1382b15cb3dSCy Schubert #define BRK_COMMA_CHARS(_s)           brk_ag_char_map_chars(_s, 4)
1392b15cb3dSCy Schubert #define SPN_COMMA_BACK(s,e)           spn_ag_char_map_back(s, e, 4)
1402b15cb3dSCy Schubert #define BRK_COMMA_BACK(s,e)           brk_ag_char_map_back(s, e, 4)
1412b15cb3dSCy Schubert #define  IS_COLON_CHAR( _c)            is_ag_char_map_char((char)(_c), 0x00000020)
1422b15cb3dSCy Schubert #define SPN_COLON_CHARS(_s)           spn_ag_char_map_chars(_s, 5)
1432b15cb3dSCy Schubert #define BRK_COLON_CHARS(_s)           brk_ag_char_map_chars(_s, 5)
1442b15cb3dSCy Schubert #define SPN_COLON_BACK(s,e)           spn_ag_char_map_back(s, e, 5)
1452b15cb3dSCy Schubert #define BRK_COLON_BACK(s,e)           brk_ag_char_map_back(s, e, 5)
1462b15cb3dSCy Schubert #define  IS_UNDERSCORE_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x00000040)
1472b15cb3dSCy Schubert #define SPN_UNDERSCORE_CHARS(_s)      spn_ag_char_map_chars(_s, 6)
1482b15cb3dSCy Schubert #define BRK_UNDERSCORE_CHARS(_s)      brk_ag_char_map_chars(_s, 6)
1492b15cb3dSCy Schubert #define SPN_UNDERSCORE_BACK(s,e)      spn_ag_char_map_back(s, e, 6)
1502b15cb3dSCy Schubert #define BRK_UNDERSCORE_BACK(s,e)      brk_ag_char_map_back(s, e, 6)
1512b15cb3dSCy Schubert #define  IS_PLUS_CHAR( _c)             is_ag_char_map_char((char)(_c), 0x00000080)
1522b15cb3dSCy Schubert #define SPN_PLUS_CHARS(_s)            spn_ag_char_map_chars(_s, 7)
1532b15cb3dSCy Schubert #define BRK_PLUS_CHARS(_s)            brk_ag_char_map_chars(_s, 7)
1542b15cb3dSCy Schubert #define SPN_PLUS_BACK(s,e)            spn_ag_char_map_back(s, e, 7)
1552b15cb3dSCy Schubert #define BRK_PLUS_BACK(s,e)            brk_ag_char_map_back(s, e, 7)
1562b15cb3dSCy Schubert #define  IS_DOLLAR_CHAR( _c)           is_ag_char_map_char((char)(_c), 0x00000100)
1572b15cb3dSCy Schubert #define SPN_DOLLAR_CHARS(_s)          spn_ag_char_map_chars(_s, 8)
1582b15cb3dSCy Schubert #define BRK_DOLLAR_CHARS(_s)          brk_ag_char_map_chars(_s, 8)
1592b15cb3dSCy Schubert #define SPN_DOLLAR_BACK(s,e)          spn_ag_char_map_back(s, e, 8)
1602b15cb3dSCy Schubert #define BRK_DOLLAR_BACK(s,e)          brk_ag_char_map_back(s, e, 8)
1612b15cb3dSCy Schubert #define  IS_OPTION_MARKER_CHAR( _c)    is_ag_char_map_char((char)(_c), 0x00000200)
1622b15cb3dSCy Schubert #define SPN_OPTION_MARKER_CHARS(_s)   spn_ag_char_map_chars(_s, 9)
1632b15cb3dSCy Schubert #define BRK_OPTION_MARKER_CHARS(_s)   brk_ag_char_map_chars(_s, 9)
1642b15cb3dSCy Schubert #define SPN_OPTION_MARKER_BACK(s,e)   spn_ag_char_map_back(s, e, 9)
1652b15cb3dSCy Schubert #define BRK_OPTION_MARKER_BACK(s,e)   brk_ag_char_map_back(s, e, 9)
1662b15cb3dSCy Schubert #define  IS_HORIZ_WHITE_CHAR( _c)      is_ag_char_map_char((char)(_c), 0x00000400)
1672b15cb3dSCy Schubert #define SPN_HORIZ_WHITE_CHARS(_s)     spn_ag_char_map_chars(_s, 10)
1682b15cb3dSCy Schubert #define BRK_HORIZ_WHITE_CHARS(_s)     brk_ag_char_map_chars(_s, 10)
1692b15cb3dSCy Schubert #define SPN_HORIZ_WHITE_BACK(s,e)     spn_ag_char_map_back(s, e, 10)
1702b15cb3dSCy Schubert #define BRK_HORIZ_WHITE_BACK(s,e)     brk_ag_char_map_back(s, e, 10)
1712b15cb3dSCy Schubert #define  IS_ALT_WHITE_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x00000800)
1722b15cb3dSCy Schubert #define SPN_ALT_WHITE_CHARS(_s)       spn_ag_char_map_chars(_s, 11)
1732b15cb3dSCy Schubert #define BRK_ALT_WHITE_CHARS(_s)       brk_ag_char_map_chars(_s, 11)
1742b15cb3dSCy Schubert #define SPN_ALT_WHITE_BACK(s,e)       spn_ag_char_map_back(s, e, 11)
1752b15cb3dSCy Schubert #define BRK_ALT_WHITE_BACK(s,e)       brk_ag_char_map_back(s, e, 11)
1762b15cb3dSCy Schubert #define  IS_WHITESPACE_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x00000C01)
1772b15cb3dSCy Schubert #define SPN_WHITESPACE_CHARS(_s)      spn_ag_char_map_chars(_s, 12)
1782b15cb3dSCy Schubert #define BRK_WHITESPACE_CHARS(_s)      brk_ag_char_map_chars(_s, 12)
1792b15cb3dSCy Schubert #define SPN_WHITESPACE_BACK(s,e)      spn_ag_char_map_back(s, e, 12)
1802b15cb3dSCy Schubert #define BRK_WHITESPACE_BACK(s,e)      brk_ag_char_map_back(s, e, 12)
1812b15cb3dSCy Schubert #define  IS_NON_NL_WHITE_CHAR( _c)     is_ag_char_map_char((char)(_c), 0x00000C00)
1822b15cb3dSCy Schubert #define SPN_NON_NL_WHITE_CHARS(_s)    spn_ag_char_map_chars(_s, 13)
1832b15cb3dSCy Schubert #define BRK_NON_NL_WHITE_CHARS(_s)    brk_ag_char_map_chars(_s, 13)
1842b15cb3dSCy Schubert #define SPN_NON_NL_WHITE_BACK(s,e)    spn_ag_char_map_back(s, e, 13)
1852b15cb3dSCy Schubert #define BRK_NON_NL_WHITE_BACK(s,e)    brk_ag_char_map_back(s, e, 13)
1862b15cb3dSCy Schubert #define  IS_QUOTE_CHAR( _c)            is_ag_char_map_char((char)(_c), 0x00001000)
1872b15cb3dSCy Schubert #define SPN_QUOTE_CHARS(_s)           spn_ag_char_map_chars(_s, 14)
1882b15cb3dSCy Schubert #define BRK_QUOTE_CHARS(_s)           brk_ag_char_map_chars(_s, 14)
1892b15cb3dSCy Schubert #define SPN_QUOTE_BACK(s,e)           spn_ag_char_map_back(s, e, 14)
1902b15cb3dSCy Schubert #define BRK_QUOTE_BACK(s,e)           brk_ag_char_map_back(s, e, 14)
1912b15cb3dSCy Schubert #define  IS_PARENTHESES_CHAR( _c)      is_ag_char_map_char((char)(_c), 0x00002000)
1922b15cb3dSCy Schubert #define SPN_PARENTHESES_CHARS(_s)     spn_ag_char_map_chars(_s, 15)
1932b15cb3dSCy Schubert #define BRK_PARENTHESES_CHARS(_s)     brk_ag_char_map_chars(_s, 15)
1942b15cb3dSCy Schubert #define SPN_PARENTHESES_BACK(s,e)     spn_ag_char_map_back(s, e, 15)
1952b15cb3dSCy Schubert #define BRK_PARENTHESES_BACK(s,e)     brk_ag_char_map_back(s, e, 15)
1962b15cb3dSCy Schubert #define  IS_GRAPHIC_CHAR( _c)          is_ag_char_map_char((char)(_c), 0x00004000)
1972b15cb3dSCy Schubert #define SPN_GRAPHIC_CHARS(_s)         spn_ag_char_map_chars(_s, 16)
1982b15cb3dSCy Schubert #define BRK_GRAPHIC_CHARS(_s)         brk_ag_char_map_chars(_s, 16)
1992b15cb3dSCy Schubert #define SPN_GRAPHIC_BACK(s,e)         spn_ag_char_map_back(s, e, 16)
2002b15cb3dSCy Schubert #define BRK_GRAPHIC_BACK(s,e)         brk_ag_char_map_back(s, e, 16)
2012b15cb3dSCy Schubert #define  IS_INVERSION_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x00008000)
2022b15cb3dSCy Schubert #define SPN_INVERSION_CHARS(_s)       spn_ag_char_map_chars(_s, 17)
2032b15cb3dSCy Schubert #define BRK_INVERSION_CHARS(_s)       brk_ag_char_map_chars(_s, 17)
2042b15cb3dSCy Schubert #define SPN_INVERSION_BACK(s,e)       spn_ag_char_map_back(s, e, 17)
2052b15cb3dSCy Schubert #define BRK_INVERSION_BACK(s,e)       brk_ag_char_map_back(s, e, 17)
2062b15cb3dSCy Schubert #define  IS_OCT_DIGIT_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x00010000)
2072b15cb3dSCy Schubert #define SPN_OCT_DIGIT_CHARS(_s)       spn_ag_char_map_chars(_s, 18)
2082b15cb3dSCy Schubert #define BRK_OCT_DIGIT_CHARS(_s)       brk_ag_char_map_chars(_s, 18)
2092b15cb3dSCy Schubert #define SPN_OCT_DIGIT_BACK(s,e)       spn_ag_char_map_back(s, e, 18)
2102b15cb3dSCy Schubert #define BRK_OCT_DIGIT_BACK(s,e)       brk_ag_char_map_back(s, e, 18)
2112b15cb3dSCy Schubert #define  IS_DEC_DIGIT_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x00030000)
2122b15cb3dSCy Schubert #define SPN_DEC_DIGIT_CHARS(_s)       spn_ag_char_map_chars(_s, 19)
2132b15cb3dSCy Schubert #define BRK_DEC_DIGIT_CHARS(_s)       brk_ag_char_map_chars(_s, 19)
2142b15cb3dSCy Schubert #define SPN_DEC_DIGIT_BACK(s,e)       spn_ag_char_map_back(s, e, 19)
2152b15cb3dSCy Schubert #define BRK_DEC_DIGIT_BACK(s,e)       brk_ag_char_map_back(s, e, 19)
2162b15cb3dSCy Schubert #define  IS_HEX_DIGIT_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x00070000)
2172b15cb3dSCy Schubert #define SPN_HEX_DIGIT_CHARS(_s)       spn_ag_char_map_chars(_s, 20)
2182b15cb3dSCy Schubert #define BRK_HEX_DIGIT_CHARS(_s)       brk_ag_char_map_chars(_s, 20)
2192b15cb3dSCy Schubert #define SPN_HEX_DIGIT_BACK(s,e)       spn_ag_char_map_back(s, e, 20)
2202b15cb3dSCy Schubert #define BRK_HEX_DIGIT_BACK(s,e)       brk_ag_char_map_back(s, e, 20)
2212b15cb3dSCy Schubert #define  IS_LOWER_CASE_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x00080000)
2222b15cb3dSCy Schubert #define SPN_LOWER_CASE_CHARS(_s)      spn_ag_char_map_chars(_s, 21)
2232b15cb3dSCy Schubert #define BRK_LOWER_CASE_CHARS(_s)      brk_ag_char_map_chars(_s, 21)
2242b15cb3dSCy Schubert #define SPN_LOWER_CASE_BACK(s,e)      spn_ag_char_map_back(s, e, 21)
2252b15cb3dSCy Schubert #define BRK_LOWER_CASE_BACK(s,e)      brk_ag_char_map_back(s, e, 21)
2262b15cb3dSCy Schubert #define  IS_UPPER_CASE_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x00100000)
2272b15cb3dSCy Schubert #define SPN_UPPER_CASE_CHARS(_s)      spn_ag_char_map_chars(_s, 22)
2282b15cb3dSCy Schubert #define BRK_UPPER_CASE_CHARS(_s)      brk_ag_char_map_chars(_s, 22)
2292b15cb3dSCy Schubert #define SPN_UPPER_CASE_BACK(s,e)      spn_ag_char_map_back(s, e, 22)
2302b15cb3dSCy Schubert #define BRK_UPPER_CASE_BACK(s,e)      brk_ag_char_map_back(s, e, 22)
2312b15cb3dSCy Schubert #define  IS_ALPHABETIC_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x00180000)
2322b15cb3dSCy Schubert #define SPN_ALPHABETIC_CHARS(_s)      spn_ag_char_map_chars(_s, 23)
2332b15cb3dSCy Schubert #define BRK_ALPHABETIC_CHARS(_s)      brk_ag_char_map_chars(_s, 23)
2342b15cb3dSCy Schubert #define SPN_ALPHABETIC_BACK(s,e)      spn_ag_char_map_back(s, e, 23)
2352b15cb3dSCy Schubert #define BRK_ALPHABETIC_BACK(s,e)      brk_ag_char_map_back(s, e, 23)
2362b15cb3dSCy Schubert #define  IS_ALPHANUMERIC_CHAR( _c)     is_ag_char_map_char((char)(_c), 0x001B0000)
2372b15cb3dSCy Schubert #define SPN_ALPHANUMERIC_CHARS(_s)    spn_ag_char_map_chars(_s, 24)
2382b15cb3dSCy Schubert #define BRK_ALPHANUMERIC_CHARS(_s)    brk_ag_char_map_chars(_s, 24)
2392b15cb3dSCy Schubert #define SPN_ALPHANUMERIC_BACK(s,e)    spn_ag_char_map_back(s, e, 24)
2402b15cb3dSCy Schubert #define BRK_ALPHANUMERIC_BACK(s,e)    brk_ag_char_map_back(s, e, 24)
2412b15cb3dSCy Schubert #define  IS_VAR_FIRST_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x00180040)
2422b15cb3dSCy Schubert #define SPN_VAR_FIRST_CHARS(_s)       spn_ag_char_map_chars(_s, 25)
2432b15cb3dSCy Schubert #define BRK_VAR_FIRST_CHARS(_s)       brk_ag_char_map_chars(_s, 25)
2442b15cb3dSCy Schubert #define SPN_VAR_FIRST_BACK(s,e)       spn_ag_char_map_back(s, e, 25)
2452b15cb3dSCy Schubert #define BRK_VAR_FIRST_BACK(s,e)       brk_ag_char_map_back(s, e, 25)
2462b15cb3dSCy Schubert #define  IS_VARIABLE_NAME_CHAR( _c)    is_ag_char_map_char((char)(_c), 0x001B0040)
2472b15cb3dSCy Schubert #define SPN_VARIABLE_NAME_CHARS(_s)   spn_ag_char_map_chars(_s, 26)
2482b15cb3dSCy Schubert #define BRK_VARIABLE_NAME_CHARS(_s)   brk_ag_char_map_chars(_s, 26)
2492b15cb3dSCy Schubert #define SPN_VARIABLE_NAME_BACK(s,e)   spn_ag_char_map_back(s, e, 26)
2502b15cb3dSCy Schubert #define BRK_VARIABLE_NAME_BACK(s,e)   brk_ag_char_map_back(s, e, 26)
2512b15cb3dSCy Schubert #define  IS_OPTION_NAME_CHAR( _c)      is_ag_char_map_char((char)(_c), 0x003B0040)
2522b15cb3dSCy Schubert #define SPN_OPTION_NAME_CHARS(_s)     spn_ag_char_map_chars(_s, 27)
2532b15cb3dSCy Schubert #define BRK_OPTION_NAME_CHARS(_s)     brk_ag_char_map_chars(_s, 27)
2542b15cb3dSCy Schubert #define SPN_OPTION_NAME_BACK(s,e)     spn_ag_char_map_back(s, e, 27)
2552b15cb3dSCy Schubert #define BRK_OPTION_NAME_BACK(s,e)     brk_ag_char_map_back(s, e, 27)
2562b15cb3dSCy Schubert #define  IS_VALUE_NAME_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x003B0060)
2572b15cb3dSCy Schubert #define SPN_VALUE_NAME_CHARS(_s)      spn_ag_char_map_chars(_s, 28)
2582b15cb3dSCy Schubert #define BRK_VALUE_NAME_CHARS(_s)      brk_ag_char_map_chars(_s, 28)
2592b15cb3dSCy Schubert #define SPN_VALUE_NAME_BACK(s,e)      spn_ag_char_map_back(s, e, 28)
2602b15cb3dSCy Schubert #define BRK_VALUE_NAME_BACK(s,e)      brk_ag_char_map_back(s, e, 28)
2612b15cb3dSCy Schubert #define  IS_NAME_SEP_CHAR( _c)         is_ag_char_map_char((char)(_c), 0x00400000)
2622b15cb3dSCy Schubert #define SPN_NAME_SEP_CHARS(_s)        spn_ag_char_map_chars(_s, 29)
2632b15cb3dSCy Schubert #define BRK_NAME_SEP_CHARS(_s)        brk_ag_char_map_chars(_s, 29)
2642b15cb3dSCy Schubert #define SPN_NAME_SEP_BACK(s,e)        spn_ag_char_map_back(s, e, 29)
2652b15cb3dSCy Schubert #define BRK_NAME_SEP_BACK(s,e)        brk_ag_char_map_back(s, e, 29)
2662b15cb3dSCy Schubert #define  IS_COMPOUND_NAME_CHAR( _c)    is_ag_char_map_char((char)(_c), 0x007B0460)
2672b15cb3dSCy Schubert #define SPN_COMPOUND_NAME_CHARS(_s)   spn_ag_char_map_chars(_s, 30)
2682b15cb3dSCy Schubert #define BRK_COMPOUND_NAME_CHARS(_s)   brk_ag_char_map_chars(_s, 30)
2692b15cb3dSCy Schubert #define SPN_COMPOUND_NAME_BACK(s,e)   spn_ag_char_map_back(s, e, 30)
2702b15cb3dSCy Schubert #define BRK_COMPOUND_NAME_BACK(s,e)   brk_ag_char_map_back(s, e, 30)
2712b15cb3dSCy Schubert #define  IS_SCHEME_NOTE_CHAR( _c)      is_ag_char_map_char((char)(_c), 0x00003000)
2722b15cb3dSCy Schubert #define SPN_SCHEME_NOTE_CHARS(_s)     spn_ag_char_map_chars(_s, 31)
2732b15cb3dSCy Schubert #define BRK_SCHEME_NOTE_CHARS(_s)     brk_ag_char_map_chars(_s, 31)
2742b15cb3dSCy Schubert #define SPN_SCHEME_NOTE_BACK(s,e)     spn_ag_char_map_back(s, e, 31)
2752b15cb3dSCy Schubert #define BRK_SCHEME_NOTE_BACK(s,e)     brk_ag_char_map_back(s, e, 31)
2762b15cb3dSCy Schubert #define  IS_UNQUOTABLE_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x00800000)
2772b15cb3dSCy Schubert #define SPN_UNQUOTABLE_CHARS(_s)      spn_ag_char_map_chars(_s, 32)
2782b15cb3dSCy Schubert #define BRK_UNQUOTABLE_CHARS(_s)      brk_ag_char_map_chars(_s, 32)
2792b15cb3dSCy Schubert #define SPN_UNQUOTABLE_BACK(s,e)      spn_ag_char_map_back(s, e, 32)
2802b15cb3dSCy Schubert #define BRK_UNQUOTABLE_BACK(s,e)      brk_ag_char_map_back(s, e, 32)
2812b15cb3dSCy Schubert #define  IS_END_XML_TOKEN_CHAR( _c)    is_ag_char_map_char((char)(_c), 0x01000C01)
2822b15cb3dSCy Schubert #define SPN_END_XML_TOKEN_CHARS(_s)   spn_ag_char_map_chars(_s, 33)
2832b15cb3dSCy Schubert #define BRK_END_XML_TOKEN_CHARS(_s)   brk_ag_char_map_chars(_s, 33)
2842b15cb3dSCy Schubert #define SPN_END_XML_TOKEN_BACK(s,e)   spn_ag_char_map_back(s, e, 33)
2852b15cb3dSCy Schubert #define BRK_END_XML_TOKEN_BACK(s,e)   brk_ag_char_map_back(s, e, 33)
2862b15cb3dSCy Schubert #define  IS_PLUS_N_SPACE_CHAR( _c)     is_ag_char_map_char((char)(_c), 0x00000C81)
2872b15cb3dSCy Schubert #define SPN_PLUS_N_SPACE_CHARS(_s)    spn_ag_char_map_chars(_s, 34)
2882b15cb3dSCy Schubert #define BRK_PLUS_N_SPACE_CHARS(_s)    brk_ag_char_map_chars(_s, 34)
2892b15cb3dSCy Schubert #define SPN_PLUS_N_SPACE_BACK(s,e)    spn_ag_char_map_back(s, e, 34)
2902b15cb3dSCy Schubert #define BRK_PLUS_N_SPACE_BACK(s,e)    brk_ag_char_map_back(s, e, 34)
2912b15cb3dSCy Schubert #define  IS_PUNCTUATION_CHAR( _c)      is_ag_char_map_char((char)(_c), 0x02000000)
2922b15cb3dSCy Schubert #define SPN_PUNCTUATION_CHARS(_s)     spn_ag_char_map_chars(_s, 35)
2932b15cb3dSCy Schubert #define BRK_PUNCTUATION_CHARS(_s)     brk_ag_char_map_chars(_s, 35)
2942b15cb3dSCy Schubert #define SPN_PUNCTUATION_BACK(s,e)     spn_ag_char_map_back(s, e, 35)
2952b15cb3dSCy Schubert #define BRK_PUNCTUATION_BACK(s,e)     brk_ag_char_map_back(s, e, 35)
2962b15cb3dSCy Schubert #define  IS_SUFFIX_CHAR( _c)           is_ag_char_map_char((char)(_c), 0x041B0000)
2972b15cb3dSCy Schubert #define SPN_SUFFIX_CHARS(_s)          spn_ag_char_map_chars(_s, 36)
2982b15cb3dSCy Schubert #define BRK_SUFFIX_CHARS(_s)          brk_ag_char_map_chars(_s, 36)
2992b15cb3dSCy Schubert #define SPN_SUFFIX_BACK(s,e)          spn_ag_char_map_back(s, e, 36)
3002b15cb3dSCy Schubert #define BRK_SUFFIX_BACK(s,e)          brk_ag_char_map_back(s, e, 36)
3012b15cb3dSCy Schubert #define  IS_SUFFIX_FMT_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x041B000C)
3022b15cb3dSCy Schubert #define SPN_SUFFIX_FMT_CHARS(_s)      spn_ag_char_map_chars(_s, 37)
3032b15cb3dSCy Schubert #define BRK_SUFFIX_FMT_CHARS(_s)      brk_ag_char_map_chars(_s, 37)
3042b15cb3dSCy Schubert #define SPN_SUFFIX_FMT_BACK(s,e)      spn_ag_char_map_back(s, e, 37)
3052b15cb3dSCy Schubert #define BRK_SUFFIX_FMT_BACK(s,e)      brk_ag_char_map_back(s, e, 37)
3062b15cb3dSCy Schubert #define  IS_FALSE_TYPE_CHAR( _c)       is_ag_char_map_char((char)(_c), 0x08000002)
3072b15cb3dSCy Schubert #define SPN_FALSE_TYPE_CHARS(_s)      spn_ag_char_map_chars(_s, 38)
3082b15cb3dSCy Schubert #define BRK_FALSE_TYPE_CHARS(_s)      brk_ag_char_map_chars(_s, 38)
3092b15cb3dSCy Schubert #define SPN_FALSE_TYPE_BACK(s,e)      spn_ag_char_map_back(s, e, 38)
3102b15cb3dSCy Schubert #define BRK_FALSE_TYPE_BACK(s,e)      brk_ag_char_map_back(s, e, 38)
3112b15cb3dSCy Schubert #define  IS_FILE_NAME_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x041B0004)
3122b15cb3dSCy Schubert #define SPN_FILE_NAME_CHARS(_s)       spn_ag_char_map_chars(_s, 39)
3132b15cb3dSCy Schubert #define BRK_FILE_NAME_CHARS(_s)       brk_ag_char_map_chars(_s, 39)
3142b15cb3dSCy Schubert #define SPN_FILE_NAME_BACK(s,e)       spn_ag_char_map_back(s, e, 39)
3152b15cb3dSCy Schubert #define BRK_FILE_NAME_BACK(s,e)       brk_ag_char_map_back(s, e, 39)
3162b15cb3dSCy Schubert #define  IS_END_TOKEN_CHAR( _c)        is_ag_char_map_char((char)(_c), 0x00000C03)
3172b15cb3dSCy Schubert #define SPN_END_TOKEN_CHARS(_s)       spn_ag_char_map_chars(_s, 40)
3182b15cb3dSCy Schubert #define BRK_END_TOKEN_CHARS(_s)       brk_ag_char_map_chars(_s, 40)
3192b15cb3dSCy Schubert #define SPN_END_TOKEN_BACK(s,e)       spn_ag_char_map_back(s, e, 40)
3202b15cb3dSCy Schubert #define BRK_END_TOKEN_BACK(s,e)       brk_ag_char_map_back(s, e, 40)
3212b15cb3dSCy Schubert #define  IS_END_LIST_ENTRY_CHAR( _c)   is_ag_char_map_char((char)(_c), 0x00000C13)
3222b15cb3dSCy Schubert #define SPN_END_LIST_ENTRY_CHARS(_s)  spn_ag_char_map_chars(_s, 41)
3232b15cb3dSCy Schubert #define BRK_END_LIST_ENTRY_CHARS(_s)  brk_ag_char_map_chars(_s, 41)
3242b15cb3dSCy Schubert #define SPN_END_LIST_ENTRY_BACK(s,e)  spn_ag_char_map_back(s, e, 41)
3252b15cb3dSCy Schubert #define BRK_END_LIST_ENTRY_BACK(s,e)  brk_ag_char_map_back(s, e, 41)
3262b15cb3dSCy Schubert #define  IS_SET_SEPARATOR_CHAR( _c)    is_ag_char_map_char((char)(_c), 0x10000C13)
3272b15cb3dSCy Schubert #define SPN_SET_SEPARATOR_CHARS(_s)   spn_ag_char_map_chars(_s, 42)
3282b15cb3dSCy Schubert #define BRK_SET_SEPARATOR_CHARS(_s)   brk_ag_char_map_chars(_s, 42)
3292b15cb3dSCy Schubert #define SPN_SET_SEPARATOR_BACK(s,e)   spn_ag_char_map_back(s, e, 42)
3302b15cb3dSCy Schubert #define BRK_SET_SEPARATOR_BACK(s,e)   brk_ag_char_map_back(s, e, 42)
3312b15cb3dSCy Schubert #define  IS_SIGNED_NUMBER_CHAR( _c)    is_ag_char_map_char((char)(_c), 0x00038000)
3322b15cb3dSCy Schubert #define SPN_SIGNED_NUMBER_CHARS(_s)   spn_ag_char_map_chars(_s, 43)
3332b15cb3dSCy Schubert #define BRK_SIGNED_NUMBER_CHARS(_s)   brk_ag_char_map_chars(_s, 43)
3342b15cb3dSCy Schubert #define SPN_SIGNED_NUMBER_BACK(s,e)   spn_ag_char_map_back(s, e, 43)
3352b15cb3dSCy Schubert #define BRK_SIGNED_NUMBER_BACK(s,e)   brk_ag_char_map_back(s, e, 43)
3362b15cb3dSCy Schubert #define  IS_MAKE_SCRIPT_CHAR( _c)      is_ag_char_map_char((char)(_c), 0x00000101)
3372b15cb3dSCy Schubert #define SPN_MAKE_SCRIPT_CHARS(_s)     spn_ag_char_map_chars(_s, 44)
3382b15cb3dSCy Schubert #define BRK_MAKE_SCRIPT_CHARS(_s)     brk_ag_char_map_chars(_s, 44)
3392b15cb3dSCy Schubert #define SPN_MAKE_SCRIPT_BACK(s,e)     spn_ag_char_map_back(s, e, 44)
3402b15cb3dSCy Schubert #define BRK_MAKE_SCRIPT_BACK(s,e)     brk_ag_char_map_back(s, e, 44)
3412b15cb3dSCy Schubert #define  IS_LOAD_LINE_SKIP_CHAR( _c)   is_ag_char_map_char((char)(_c), 0x00000600)
3422b15cb3dSCy Schubert #define SPN_LOAD_LINE_SKIP_CHARS(_s)  spn_ag_char_map_chars(_s, 45)
3432b15cb3dSCy Schubert #define BRK_LOAD_LINE_SKIP_CHARS(_s)  brk_ag_char_map_chars(_s, 45)
3442b15cb3dSCy Schubert #define SPN_LOAD_LINE_SKIP_BACK(s,e)  spn_ag_char_map_back(s, e, 45)
3452b15cb3dSCy Schubert #define BRK_LOAD_LINE_SKIP_BACK(s,e)  brk_ag_char_map_back(s, e, 45)
3462b15cb3dSCy Schubert 
3472b15cb3dSCy Schubert static ag_char_map_mask_t const ag_char_map_table[128] = {
3482b15cb3dSCy Schubert   /*NUL*/ 0x00000002, /*x01*/ 0x00000000, /*x02*/ 0x00000000, /*x03*/ 0x00000000,
3492b15cb3dSCy Schubert   /*x04*/ 0x00000000, /*x05*/ 0x00000000, /*x06*/ 0x00000000, /*BEL*/ 0x00000000,
3502b15cb3dSCy Schubert   /* BS*/ 0x00000800, /* HT*/ 0x00000400, /* NL*/ 0x00000001, /* VT*/ 0x00000800,
3512b15cb3dSCy Schubert   /* FF*/ 0x00000800, /* CR*/ 0x00000800, /*x0E*/ 0x00000000, /*x0F*/ 0x00000000,
3522b15cb3dSCy Schubert   /*x10*/ 0x00000000, /*x11*/ 0x00000000, /*x12*/ 0x00000000, /*x13*/ 0x00000000,
3532b15cb3dSCy Schubert   /*x14*/ 0x00000000, /*x15*/ 0x00000000, /*x16*/ 0x00000000, /*x17*/ 0x00000000,
3542b15cb3dSCy Schubert   /*x18*/ 0x00000000, /*x19*/ 0x00000000, /*x1A*/ 0x00000000, /*ESC*/ 0x00000000,
3552b15cb3dSCy Schubert   /*x1C*/ 0x00000000, /*x1D*/ 0x00000000, /*x1E*/ 0x00000000, /*x1F*/ 0x00000000,
3562b15cb3dSCy Schubert   /*   */ 0x00000400, /* ! */ 0x02804000, /* " */ 0x02005000, /* # */ 0x02004000,
3572b15cb3dSCy Schubert   /* $ */ 0x02804100, /* % */ 0x02804008, /* & */ 0x02804000, /* ' */ 0x02005000,
3582b15cb3dSCy Schubert   /* ( */ 0x02006000, /* ) */ 0x02006000, /* * */ 0x02004000, /* + */ 0x12804080,
3592b15cb3dSCy Schubert   /* , */ 0x02004010, /* - */ 0x06A0C200, /* . */ 0x06C04000, /* / */ 0x03804004,
3602b15cb3dSCy Schubert   /* 0 */ 0x08814000, /* 1 */ 0x00814000, /* 2 */ 0x00814000, /* 3 */ 0x00814000,
3612b15cb3dSCy Schubert   /* 4 */ 0x00814000, /* 5 */ 0x00814000, /* 6 */ 0x00814000, /* 7 */ 0x00814000,
3622b15cb3dSCy Schubert   /* 8 */ 0x00824000, /* 9 */ 0x00824000, /* : */ 0x02804020, /* ; */ 0x02004000,
3632b15cb3dSCy Schubert   /* < */ 0x02004000, /* = */ 0x02004000, /* > */ 0x03004000, /* ? */ 0x02004000,
3642b15cb3dSCy Schubert   /* @ */ 0x02804000, /* A */ 0x00944000, /* B */ 0x00944000, /* C */ 0x00944000,
3652b15cb3dSCy Schubert   /* D */ 0x00944000, /* E */ 0x00944000, /* F */ 0x08944000, /* G */ 0x00904000,
3662b15cb3dSCy Schubert   /* H */ 0x00904000, /* I */ 0x00904000, /* J */ 0x00904000, /* K */ 0x00904000,
3672b15cb3dSCy Schubert   /* L */ 0x00904000, /* M */ 0x00904000, /* N */ 0x08904000, /* O */ 0x00904000,
3682b15cb3dSCy Schubert   /* P */ 0x00904000, /* Q */ 0x00904000, /* R */ 0x00904000, /* S */ 0x00904000,
3692b15cb3dSCy Schubert   /* T */ 0x00904000, /* U */ 0x00904000, /* V */ 0x00904000, /* W */ 0x00904000,
3702b15cb3dSCy Schubert   /* X */ 0x00904000, /* Y */ 0x00904000, /* Z */ 0x00904000, /* [ */ 0x02404000,
3712b15cb3dSCy Schubert   /* \ */ 0x02004004, /* ] */ 0x02404000, /* ^ */ 0x02A04000, /* _ */ 0x04804040,
3722b15cb3dSCy Schubert   /* ` */ 0x02004000, /* a */ 0x008C4000, /* b */ 0x008C4000, /* c */ 0x008C4000,
3732b15cb3dSCy Schubert   /* d */ 0x008C4000, /* e */ 0x008C4000, /* f */ 0x088C4000, /* g */ 0x00884000,
3742b15cb3dSCy Schubert   /* h */ 0x00884000, /* i */ 0x00884000, /* j */ 0x00884000, /* k */ 0x00884000,
3752b15cb3dSCy Schubert   /* l */ 0x00884000, /* m */ 0x00884000, /* n */ 0x08884000, /* o */ 0x00884000,
3762b15cb3dSCy Schubert   /* p */ 0x00884000, /* q */ 0x00884000, /* r */ 0x00884000, /* s */ 0x00884000,
3772b15cb3dSCy Schubert   /* t */ 0x00884000, /* u */ 0x00884000, /* v */ 0x00884000, /* w */ 0x00884000,
3782b15cb3dSCy Schubert   /* x */ 0x00884000, /* y */ 0x00884000, /* z */ 0x00884000, /* { */ 0x02004000,
3792b15cb3dSCy Schubert   /* | */ 0x12804000, /* } */ 0x02004000, /* ~ */ 0x0280C000, /*x7F*/ 0x00000000
3802b15cb3dSCy Schubert };
3812b15cb3dSCy Schubert 
3822b15cb3dSCy Schubert #include <stdio.h>
3832b15cb3dSCy Schubert #include <stdlib.h>
3842b15cb3dSCy Schubert #include <string.h>
3852b15cb3dSCy Schubert 
3862b15cb3dSCy Schubert #ifndef _
3872b15cb3dSCy Schubert # define _(_s) _s
3882b15cb3dSCy Schubert #endif
3892b15cb3dSCy Schubert 
3902b15cb3dSCy Schubert static unsigned char const * ag_char_map_spanners[46];
3912b15cb3dSCy Schubert /**
3922b15cb3dSCy Schubert  *  Character category masks.  Some categories may have multiple bits,
3932b15cb3dSCy Schubert  *  if their definition incorporates other character categories.
3942b15cb3dSCy Schubert  *  This mask array is only used by calc_ag_char_map_spanners().
3952b15cb3dSCy Schubert  */
3962b15cb3dSCy Schubert static ag_char_map_mask_t const ag_char_map_masks[46] = {
3972b15cb3dSCy Schubert     0x00000001, /* NEWLINE         */
3982b15cb3dSCy Schubert     0x00000002, /* NUL_BYTE        */
3992b15cb3dSCy Schubert     0x00000004, /* DIR_SEP         */
4002b15cb3dSCy Schubert     0x00000008, /* PERCENT         */
4012b15cb3dSCy Schubert     0x00000010, /* COMMA           */
4022b15cb3dSCy Schubert     0x00000020, /* COLON           */
4032b15cb3dSCy Schubert     0x00000040, /* UNDERSCORE      */
4042b15cb3dSCy Schubert     0x00000080, /* PLUS            */
4052b15cb3dSCy Schubert     0x00000100, /* DOLLAR          */
4062b15cb3dSCy Schubert     0x00000200, /* OPTION_MARKER   */
4072b15cb3dSCy Schubert     0x00000400, /* HORIZ_WHITE     */
4082b15cb3dSCy Schubert     0x00000800, /* ALT_WHITE       */
4092b15cb3dSCy Schubert     0x00000C01, /* WHITESPACE      */
4102b15cb3dSCy Schubert     0x00000C00, /* NON_NL_WHITE    */
4112b15cb3dSCy Schubert     0x00001000, /* QUOTE           */
4122b15cb3dSCy Schubert     0x00002000, /* PARENTHESES     */
4132b15cb3dSCy Schubert     0x00004000, /* GRAPHIC         */
4142b15cb3dSCy Schubert     0x00008000, /* INVERSION       */
4152b15cb3dSCy Schubert     0x00010000, /* OCT_DIGIT       */
4162b15cb3dSCy Schubert     0x00030000, /* DEC_DIGIT       */
4172b15cb3dSCy Schubert     0x00070000, /* HEX_DIGIT       */
4182b15cb3dSCy Schubert     0x00080000, /* LOWER_CASE      */
4192b15cb3dSCy Schubert     0x00100000, /* UPPER_CASE      */
4202b15cb3dSCy Schubert     0x00180000, /* ALPHABETIC      */
4212b15cb3dSCy Schubert     0x001B0000, /* ALPHANUMERIC    */
4222b15cb3dSCy Schubert     0x00180040, /* VAR_FIRST       */
4232b15cb3dSCy Schubert     0x001B0040, /* VARIABLE_NAME   */
4242b15cb3dSCy Schubert     0x003B0040, /* OPTION_NAME     */
4252b15cb3dSCy Schubert     0x003B0060, /* VALUE_NAME      */
4262b15cb3dSCy Schubert     0x00400000, /* NAME_SEP        */
4272b15cb3dSCy Schubert     0x007B0460, /* COMPOUND_NAME   */
4282b15cb3dSCy Schubert     0x00003000, /* SCHEME_NOTE     */
4292b15cb3dSCy Schubert     0x00800000, /* UNQUOTABLE      */
4302b15cb3dSCy Schubert     0x01000C01, /* END_XML_TOKEN   */
4312b15cb3dSCy Schubert     0x00000C81, /* PLUS_N_SPACE    */
4322b15cb3dSCy Schubert     0x02000000, /* PUNCTUATION     */
4332b15cb3dSCy Schubert     0x041B0000, /* SUFFIX          */
4342b15cb3dSCy Schubert     0x041B000C, /* SUFFIX_FMT      */
4352b15cb3dSCy Schubert     0x08000002, /* FALSE_TYPE      */
4362b15cb3dSCy Schubert     0x041B0004, /* FILE_NAME       */
4372b15cb3dSCy Schubert     0x00000C03, /* END_TOKEN       */
4382b15cb3dSCy Schubert     0x00000C13, /* END_LIST_ENTRY  */
4392b15cb3dSCy Schubert     0x10000C13, /* SET_SEPARATOR   */
4402b15cb3dSCy Schubert     0x00038000, /* SIGNED_NUMBER   */
4412b15cb3dSCy Schubert     0x00000101, /* MAKE_SCRIPT     */
4422b15cb3dSCy Schubert     0x00000600, /* LOAD_LINE_SKIP  */
4432b15cb3dSCy Schubert };
4442b15cb3dSCy Schubert #undef LOCK_SPANNER_TABLES
4452b15cb3dSCy Schubert 
4462b15cb3dSCy Schubert static unsigned char const *
calc_ag_char_map_spanners(unsigned int mask_ix)4472b15cb3dSCy Schubert calc_ag_char_map_spanners(unsigned int mask_ix)
4482b15cb3dSCy Schubert {
4492b15cb3dSCy Schubert #ifdef LOCK_SPANNER_TABLES
4502b15cb3dSCy Schubert     if (ag_char_map_spanners[mask_ix] != NULL)
4512b15cb3dSCy Schubert         return ag_char_map_spanners[mask_ix];
4522b15cb3dSCy Schubert 
4532b15cb3dSCy Schubert     pthread_mutex_lock(&ag_char_map_mutex);
4542b15cb3dSCy Schubert     if (ag_char_map_spanners[mask_ix] == NULL)
4552b15cb3dSCy Schubert #endif
4562b15cb3dSCy Schubert     {
4572b15cb3dSCy Schubert         int ix = 1;
4582b15cb3dSCy Schubert         ag_char_map_mask_t mask = ag_char_map_masks[mask_ix];
4592b15cb3dSCy Schubert         unsigned char * res = malloc(256 /* 1 << NBBY */);
4602b15cb3dSCy Schubert         if (res == NULL) {
4612b15cb3dSCy Schubert             fputs(_("no memory for char-mapper span map\n"), stderr);
4622b15cb3dSCy Schubert             exit(EXIT_FAILURE);
4632b15cb3dSCy Schubert         }
4642b15cb3dSCy Schubert 
4652b15cb3dSCy Schubert         memset(res, 0, 256);
4662b15cb3dSCy Schubert         for (; ix < 128; ix++)
4672b15cb3dSCy Schubert             if (ag_char_map_table[ix] & mask)
4682b15cb3dSCy Schubert                 res[ix] = 1;
4692b15cb3dSCy Schubert         ag_char_map_spanners[mask_ix] = res;
4702b15cb3dSCy Schubert     }
4712b15cb3dSCy Schubert #ifdef LOCK_SPANNER_TABLES
4722b15cb3dSCy Schubert     pthread_mutex_unlock(&ag_char_map_mutex);
4732b15cb3dSCy Schubert #endif
4742b15cb3dSCy Schubert     return ag_char_map_spanners[mask_ix];
4752b15cb3dSCy Schubert }
4762b15cb3dSCy Schubert #define ag_char_map_masks POISONED_ag_char_map_masks
4772b15cb3dSCy Schubert 
4782b15cb3dSCy Schubert static inline int
is_ag_char_map_char(char ch,ag_char_map_mask_t mask)4792b15cb3dSCy Schubert is_ag_char_map_char(char ch, ag_char_map_mask_t mask)
4802b15cb3dSCy Schubert {
4812b15cb3dSCy Schubert     unsigned int ix = (unsigned char)ch;
4822b15cb3dSCy Schubert     return ((ix < 128) && ((ag_char_map_table[ix] & mask) != 0));
4832b15cb3dSCy Schubert }
4842b15cb3dSCy Schubert 
4852b15cb3dSCy Schubert static inline char *
spn_ag_char_map_chars(char const * p,unsigned int mask_ix)4862b15cb3dSCy Schubert spn_ag_char_map_chars(char const * p, unsigned int mask_ix)
4872b15cb3dSCy Schubert {
4882b15cb3dSCy Schubert     unsigned char const * v = ag_char_map_spanners[mask_ix];
4892b15cb3dSCy Schubert     if (v == NULL)
4902b15cb3dSCy Schubert         v = calc_ag_char_map_spanners(mask_ix);
4912b15cb3dSCy Schubert     while (v[(unsigned char)*p])  p++;
4922b15cb3dSCy Schubert     return (char *)(uintptr_t)p;
4932b15cb3dSCy Schubert }
4942b15cb3dSCy Schubert 
4952b15cb3dSCy Schubert static inline char *
brk_ag_char_map_chars(char const * p,unsigned int mask_ix)4962b15cb3dSCy Schubert brk_ag_char_map_chars(char const * p, unsigned int mask_ix)
4972b15cb3dSCy Schubert {
4982b15cb3dSCy Schubert     unsigned char const * v = ag_char_map_spanners[mask_ix];
4992b15cb3dSCy Schubert     if (v == NULL)
5002b15cb3dSCy Schubert         v = calc_ag_char_map_spanners(mask_ix);
5012b15cb3dSCy Schubert     while ((*p != '\0') && (! v[(unsigned char)*p]))  p++;
5022b15cb3dSCy Schubert     return (char *)(uintptr_t)p;
5032b15cb3dSCy Schubert }
5042b15cb3dSCy Schubert 
5052b15cb3dSCy Schubert static inline char *
spn_ag_char_map_back(char const * s,char const * e,unsigned int mask_ix)5062b15cb3dSCy Schubert spn_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix)
5072b15cb3dSCy Schubert {
5082b15cb3dSCy Schubert     unsigned char const * v = ag_char_map_spanners[mask_ix];
5092b15cb3dSCy Schubert     if (v == NULL)
5102b15cb3dSCy Schubert         v = calc_ag_char_map_spanners(mask_ix);
5112b15cb3dSCy Schubert     if (s >= e) e = s + strlen(s);
5122b15cb3dSCy Schubert     while ((e > s) && v[(unsigned char)e[-1]])  e--;
5132b15cb3dSCy Schubert     return (char *)(uintptr_t)e;
5142b15cb3dSCy Schubert }
5152b15cb3dSCy Schubert 
5162b15cb3dSCy Schubert static inline char *
brk_ag_char_map_back(char const * s,char const * e,unsigned int mask_ix)5172b15cb3dSCy Schubert brk_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix)
5182b15cb3dSCy Schubert {
5192b15cb3dSCy Schubert     unsigned char const * v = ag_char_map_spanners[mask_ix];
5202b15cb3dSCy Schubert     if (v == NULL)
5212b15cb3dSCy Schubert         v = calc_ag_char_map_spanners(mask_ix);
5222b15cb3dSCy Schubert     if (s == e) e += strlen(e);
5232b15cb3dSCy Schubert     while ((e > s) && (! v[(unsigned char)e[-1]]))  e--;
5242b15cb3dSCy Schubert     return (char *)(uintptr_t)e;
5252b15cb3dSCy Schubert }
5262b15cb3dSCy Schubert #endif /* AG_CHAR_MAP_H_GUARD */
527