diff options
Diffstat (limited to 'vendor/librune/gen')
-rwxr-xr-x | vendor/librune/gen/gbrk | 2 | ||||
-rwxr-xr-x | vendor/librune/gen/rtype-cat (renamed from vendor/librune/gen/rtype) | 22 | ||||
-rwxr-xr-x | vendor/librune/gen/rtype-prop | 116 | ||||
-rw-r--r-- | vendor/librune/gen/rtype-prop.awk | 61 |
4 files changed, 187 insertions, 14 deletions
diff --git a/vendor/librune/gen/gbrk b/vendor/librune/gen/gbrk index 72ee2f7..1146327 100755 --- a/vendor/librune/gen/gbrk +++ b/vendor/librune/gen/gbrk @@ -26,8 +26,6 @@ wait cat <<C /* This file is autogenerated by gen/gbrk; DO NOT EDIT. */ -/* TODO: Change tables to constexpr from const when Clangd gets better */ - #ifndef RUNE_INTERNAL_GBRK_LOOKUP_H #define RUNE_INTERNAL_GBRK_LOOKUP_H diff --git a/vendor/librune/gen/rtype b/vendor/librune/gen/rtype-cat index 21916d3..e35fb77 100755 --- a/vendor/librune/gen/rtype +++ b/vendor/librune/gen/rtype-cat @@ -12,26 +12,24 @@ cache() set -e cd "${0%/*}/.." -exec >include/internal/rtype_lookup.h +exec >include/internal/rtype/cat.h readonly URL='https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt' cache "$URL" cat <<C -/* This file is autogenerated by gen/gbrk; DO NOT EDIT. */ +/* This file is autogenerated by gen/rtype-cat; DO NOT EDIT. */ -/* TODO: Change tables to constexpr from const when Clangd gets better */ - -#ifndef RUNE_INTERNAL_RTYPE_LOOKUP_H -#define RUNE_INTERNAL_RTYPE_LOOKUP_H +#ifndef RUNE_INTERNAL_RTYPE_CAT_H +#define RUNE_INTERNAL_RTYPE_CAT_H /* IWYU pragma: private */ /* clang-format off */ -#include "types.h" -#include "../rtype.h" +#include "../types.h" +#include "../../rtype.h" -static const unicat rtype_lat1_tbl[] = { +static const enum unicat rtype_cat_lat1_tbl[] = { C gawk ' @@ -64,7 +62,7 @@ cat <<C static const struct { rune lo, hi; - unicat cat; + enum unicat val; } rtype_cat_tbl[] = { C @@ -88,7 +86,7 @@ BEGIN { } END { - for (i = 0; i <= 0x10FFFF; i++) { + for (i = 0x100; i <= 0x10FFFF; i++) { if (!props[i]) continue lo = i @@ -102,5 +100,5 @@ END { cat <<C }; -#endif /* !RUNE_INTERNAL_RTYPE_LOOKUP_H */ +#endif /* !RUNE_INTERNAL_RTYPE_CAT_H */ C diff --git a/vendor/librune/gen/rtype-prop b/vendor/librune/gen/rtype-prop new file mode 100755 index 0000000..4c62884 --- /dev/null +++ b/vendor/librune/gen/rtype-prop @@ -0,0 +1,116 @@ +#!/bin/sh + +cache() +{ + name="/tmp/librune/rtype/$(basename "$1")" + if test ! -f "$name" + then + mkdir -p /tmp/librune/rtype + wget -q "$1" -O "$name" + fi +} + +cd "${0%/*}/.." + +readonly URL1='https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt' +readonly URL2='https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt' + +cache "$URL1" & +cache "$URL2" & +wait + +props1=' +ASCII_Hex_Digit +Bidi_Control +Dash +Deprecated +Diacritic +Extender +Hex_Digit +ID_Compat_Math_Continue +ID_Compat_Math_Start +Ideographic +IDS_Binary_Operator +IDS_Trinary_Operator +IDS_Unary_Operator +Join_Control +Logical_Order_Exception +Noncharacter_Code_Point +Pattern_Syntax +Pattern_White_Space +Prepended_Concatenation_Mark +Quotation_Mark +Radical +Regional_Indicator +Sentence_Terminal +Soft_Dotted +Terminal_Punctuation +Unified_Ideograph +Variation_Selector +White_Space +' + +props2=' +Alphabetic +Cased +Case_Ignorable +Changes_When_Casefolded +Changes_When_Casemapped +Changes_When_Lowercased +Changes_When_Titlecased +Changes_When_Uppercased +Default_Ignorable_Code_Point +Grapheme_Base +Grapheme_Extend +ID_Continue +ID_Start +Indic_Conjunct_Break +Lowercase +Math +Uppercase +XID_Continue +XID_Start +' +# InCB + +{ + for prop in $props1 + do + lprop=$(echo $prop | tr A-Z a-z) + + printf 'rune_has_prop_%s…' $lprop >&2 + + gawk -M -v prop=$prop -f gen/rtype-prop.awk \ + /tmp/librune/rtype/PropList.txt \ + >lib/rtype/rune_has_prop_$lprop.c + + echo "[[unsequenced]] bool rune_has_prop_$lprop(rune);" + echo ' DONE' >&2 + done + + for prop in $props2 + do + lprop=$(echo $prop | tr A-Z a-z) + + printf 'rune_has_prop_%s…' $lprop >&2 + + gawk -M -v prop=$prop -f gen/rtype-prop.awk \ + /tmp/librune/rtype/DerivedCoreProperties.txt \ + >lib/rtype/rune_has_prop_$lprop.c + + echo "[[unsequenced]] bool rune_has_prop_$lprop(rune);" + echo ' DONE' >&2 + done +} | gawk ' + /PROP PREDICATES END/ { no = 0 } + FILENAME != "-" && !no { print } + FILENAME == "-" { funcs[++i] = $0 } + + /PROP PREDICATES START/ { + no = 1 + asort(funcs) + for (i = 1; i <= length(funcs); i++) + print funcs[i] + } +' - include/rtype.h \ +| sponge include/rtype.h diff --git a/vendor/librune/gen/rtype-prop.awk b/vendor/librune/gen/rtype-prop.awk new file mode 100644 index 0000000..59b4a99 --- /dev/null +++ b/vendor/librune/gen/rtype-prop.awk @@ -0,0 +1,61 @@ +BEGIN { + FS = "( *#.*| +; +)" + + print "/* This file is autogenerated by gen/rtype-prop; DO NOT EDIT. */" + print "" + print "#include \"rtype.h\"" + print "" + print "#include \"internal/common.h\"" + print "" +} + +$2 == prop || (prop == "Indic_Conjunct_Break" && $2 ~ /InCB;/) { + n = split($1, a, /\.\./) + lo = strtonum("0x" a[1]) + hi = strtonum("0x" a[n]) + + for (i = lo; i <= hi; i++) + xs[i] = 1 +} + +END { + for (i = 0; i <= 0xFF; i++) { + if (xs[i]) + mask = or(mask, lshift(1, i)) + } + print "#if BIT_LOOKUP" + printf "static const unsigned _BitInt(LATIN1_MAX + 1) mask = 0x%Xuwb;\n", \ + mask + print "#endif" + print "" + print "static const struct {" + print "\trune lo, hi;" + print "} lookup_tbl[] = {" + + for (i = 0; i <= 0x10FFFF; i++) { + if (!xs[i]) + continue + lo = i + while (xs[i + 1]) + i++ + printf "\t{0x%06X, 0x%06X},\n", lo, i + } + + print "};" + print "" + print "#define TYPE bool" + print "#define TABLE lookup_tbl" + print "#define DEFAULT false" + print "#define HAS_VALUE 0" + print "#include \"internal/rtype/lookup-func.h\"" + print "" + print "bool" + printf "rune_has_prop_%s(rune ch)\n", tolower(prop) + print "{" + print "\treturn" + print "#if BIT_LOOKUP" + print "\t\tch <= LATIN1_MAX ? (mask & ch) :" + print "#endif" + print "\t\tlookup(ch);" + print "}" +} |