diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
| commit | 28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch) | |
| tree | 85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.config/mpv/script-modules/utf8/ends | |
| parent | 8470ff001befcfd0f626dea69a9e76d43aee0511 (diff) | |
updates
Diffstat (limited to 'debian/.config/mpv/script-modules/utf8/ends')
| -rw-r--r-- | debian/.config/mpv/script-modules/utf8/ends/compiletime/parser.lua | 17 | ||||
| -rw-r--r-- | debian/.config/mpv/script-modules/utf8/ends/compiletime/vanilla.lua | 46 |
2 files changed, 63 insertions, 0 deletions
diff --git a/debian/.config/mpv/script-modules/utf8/ends/compiletime/parser.lua b/debian/.config/mpv/script-modules/utf8/ends/compiletime/parser.lua new file mode 100644 index 0000000..f966e94 --- /dev/null +++ b/debian/.config/mpv/script-modules/utf8/ends/compiletime/parser.lua @@ -0,0 +1,17 @@ +return function(utf8) + +utf8.config.ends = utf8.config.ends or { + utf8:require "ends.compiletime.vanilla" +} + +function utf8.regex.compiletime.ends.parse(regex, c, bs, ctx) + for _, m in ipairs(utf8.config.ends) do + local functions, move = m.parse(regex, c, bs, ctx) + utf8.debug("ends", _, c, bs, move, functions) + if functions then + return functions, move + end + end +end + +end diff --git a/debian/.config/mpv/script-modules/utf8/ends/compiletime/vanilla.lua b/debian/.config/mpv/script-modules/utf8/ends/compiletime/vanilla.lua new file mode 100644 index 0000000..5fe7eb3 --- /dev/null +++ b/debian/.config/mpv/script-modules/utf8/ends/compiletime/vanilla.lua @@ -0,0 +1,46 @@ +return function(utf8) + +local matchers = { + any = function() + return [[ + add(function(ctx) -- any + ctx.result.finish = ctx.pos - 1 + ctx:done() + end) +]] + end, + toend = function(ctx) + return [[ + add(function(ctx) -- toend + ctx.result.finish = ctx.pos - 1 + ctx.modified = true + if ctx.pos == utf8len(ctx.str) + 1 then ctx:done() end + end) +]] + end, +} + +local len = utf8.raw.len + +local function default() + return matchers.any() +end + +local function parse(regex, c, bs, ctx) + local functions + local skip = 0 + + if bs == len(regex) and c == '$' then + functions = matchers.toend() + skip = 1 + end + + return functions, skip +end + +return { + parse = parse, + default = default, +} + +end |
