summaryrefslogtreecommitdiff
path: root/mac/.config/mpv/script-modules/utf8/charclass/compiletime/range.lua
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
commit07d294425a98ee5d1e22d03e2b24ae2c76e487c0 (patch)
treea6818f0d64438c5fdb88b00a35d944f80c056213 /mac/.config/mpv/script-modules/utf8/charclass/compiletime/range.lua
parent6fc28cdb3529ca8ee864cb5c41674cb0a4af72a1 (diff)
updates
Diffstat (limited to 'mac/.config/mpv/script-modules/utf8/charclass/compiletime/range.lua')
-rw-r--r--mac/.config/mpv/script-modules/utf8/charclass/compiletime/range.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/mac/.config/mpv/script-modules/utf8/charclass/compiletime/range.lua b/mac/.config/mpv/script-modules/utf8/charclass/compiletime/range.lua
new file mode 100644
index 0000000..2996234
--- /dev/null
+++ b/mac/.config/mpv/script-modules/utf8/charclass/compiletime/range.lua
@@ -0,0 +1,44 @@
+return function(utf8)
+
+local cl = utf8.regex.compiletime.charclass.builder
+
+local next = utf8.util.next
+
+return function(str, c, bs, ctx)
+ if not ctx.internal then return end
+
+ local nbs = bs
+
+ local r1, r2
+
+ local c, nbs = c, bs
+ if c == '%' then
+ c, nbs = next(str, nbs)
+ r1 = c
+ else
+ r1 = c
+ end
+
+ utf8.debug("range r1", r1, nbs)
+
+ c, nbs = next(str, nbs)
+ if c ~= '-' then return end
+
+ c, nbs = next(str, nbs)
+ if c == '%' then
+ c, nbs = next(str, nbs)
+ r2 = c
+ elseif c ~= '' and c ~= ']' then
+ r2 = c
+ end
+
+ utf8.debug("range r2", r2, nbs)
+
+ if r1 and r2 then
+ return cl.new():with_ranges{utf8.byte(r1), utf8.byte(r2)}, utf8.next(str, nbs) - bs
+ else
+ return
+ end
+end
+
+end