Skip to content

Commit

Permalink
Include all codepoints in the ABNF; add Other_Alphabetic
Browse files Browse the repository at this point in the history
Per comments; also commit the script used to generate the ABNF ranges.
Probably want to replace that with something less, ehm, crap, so it's
easier for people to modify and run ... This was just quick and easy to
write for me now.
  • Loading branch information
arp242 committed Sep 23, 2023
1 parent 2543ac3 commit 611af82
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 9 deletions.
52 changes: 52 additions & 0 deletions scripts/list-rng.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/zsh
set -euC

IFS=$'\n'
groups=(cat:Lu cat:Ll cat:Lt cat:Lm cat:Lo cat:Nd Other_Alphabetic)
typeset -A names=(
cat:Lu 'Uppercase_Letter (Lu)'
cat:Ll 'Lowercase_Letter (Ll)'
cat:Lt 'Titlecase_Letter (Lt)'
cat:Lm 'Modifier_Letter (Lm)'
cat:Lo 'Other_Letter (Lo)'
cat:Nd 'Decimal_Number (Nd)'
Other_Alphabetic 'Other_Alphabetic'
)
for g in $groups; do
start=0
prev=0
indent=' '
g2=${g#cat:}
for (( i=1; i<=$#g2; i++ )); indent+=' '
l=$(( $#g2 + 2 ))
print '\n;' $names[$g]
print -n "$g2 = "
for line in $(uni -quiet print $g); do
line=(${(s: :)line})
if (( $prev == 0 )); then
prev=$line[3]
start=$line[3]
continue
fi
if (( $prev + 1 == $line[3] )); then
prev=$line[3]
continue
fi
if [[ $start != $prev ]]; then
x=$(print -f '%%x%x-%x / ' $start $prev)
else
x=$(print -f '%%x%x / ' $start)
fi
print -n $x
l=$(( l + $#x ))
if (( $l > 114 )); then
l=0
print
print -n $indent
fi

prev=$line[3]
start=$line[3]
done
print -f '%%x%x-%x\n' $start $prev
done
Loading

0 comments on commit 611af82

Please sign in to comment.