diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-09-04 22:42:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-04 22:42:47 +0200 |
commit | 54d357dce0e13408b819a1fe98b6417fad2cdd4c (patch) | |
tree | b98fc09aaeb9786e02d34f140e7c91a74764de11 /runtime/lua/vim/re.lua | |
parent | 069fad6e2df25e6b079879670cf6c68ae7ddb012 (diff) | |
download | rneovim-54d357dce0e13408b819a1fe98b6417fad2cdd4c.tar.gz rneovim-54d357dce0e13408b819a1fe98b6417fad2cdd4c.tar.bz2 rneovim-54d357dce0e13408b819a1fe98b6417fad2cdd4c.zip |
build: bump lpeg to 1.1.0 (#25016)
Release notes indicates it has better UTF8 handling which is relevant
for us.
Diffstat (limited to 'runtime/lua/vim/re.lua')
-rw-r--r-- | runtime/lua/vim/re.lua | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/runtime/lua/vim/re.lua b/runtime/lua/vim/re.lua index dffe37186a..007eb27ed8 100644 --- a/runtime/lua/vim/re.lua +++ b/runtime/lua/vim/re.lua @@ -1,6 +1,8 @@ --- $Id: re.lua $ --- vendored from lpeg-1.0.2 --- Copyright © 2007-2019 Lua.org, PUC-Rio. +-- +-- Copyright 2007-2023, Lua.org & PUC-Rio (see 'lpeg.html' for license) +-- written by Roberto Ierusalimschy +-- +--- vendored from lpeg-1.1.0 -- imported functions and modules local tonumber, type, print, error = tonumber, type, print, error @@ -12,14 +14,14 @@ local m = require"lpeg" -- on 'mm' local mm = m --- pattern's metatable +-- patterns' metatable local mt = getmetatable(mm.P(0)) +local version = _VERSION -- No more global accesses after this point -local version = _VERSION -if version == "Lua 5.2" then _ENV = nil end +_ENV = nil -- does no harm in Lua 5.1 local any = m.P(1) @@ -144,7 +146,7 @@ local item = (defined + Range + m.C(any)) / m.P local Class = "[" * (m.C(m.P"^"^-1)) -- optional complement symbol - * m.Cf(item * (item - "]")^0, mt.__add) / + * (item * ((item % mt.__add) - "]")^0) / function (c, p) return c == "^" and any - p or p end * "]" @@ -170,13 +172,13 @@ end local exp = m.P{ "Exp", Exp = S * ( m.V"Grammar" - + m.Cf(m.V"Seq" * ("/" * S * m.V"Seq")^0, mt.__add) ); - Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix"^0 , mt.__mul) + + m.V"Seq" * ("/" * S * m.V"Seq" % mt.__add)^0 ); + Seq = (m.Cc(m.P"") * (m.V"Prefix" % mt.__mul)^0) * (#seq_follow + patt_error); Prefix = "&" * S * m.V"Prefix" / mt.__len + "!" * S * m.V"Prefix" / mt.__unm + m.V"Suffix"; - Suffix = m.Cf(m.V"Primary" * S * + Suffix = m.V"Primary" * S * ( ( m.P"+" * m.Cc(1, mt.__pow) + m.P"*" * m.Cc(0, mt.__pow) + m.P"?" * m.Cc(-1, mt.__pow) @@ -187,10 +189,11 @@ local exp = m.P{ "Exp", + m.P"{}" * m.Cc(nil, m.Ct) + defwithfunc(mt.__div) ) - + "=>" * S * defwithfunc(m.Cmt) - + "~>" * S * defwithfunc(m.Cf) - ) * S - )^0, function (a,b,f) return f(a,b) end ); + + "=>" * S * defwithfunc(mm.Cmt) + + ">>" * S * defwithfunc(mt.__mod) + + "~>" * S * defwithfunc(mm.Cf) + ) % function (a,b,f) return f(a,b) end * S + )^0; Primary = "(" * m.V"Exp" * ")" + String / mm.P + Class @@ -206,8 +209,7 @@ local exp = m.P{ "Exp", + (name * -arrow + "<" * name * ">") * m.Cb("G") / NT; Definition = name * arrow * m.V"Exp"; Grammar = m.Cg(m.Cc(true), "G") * - m.Cf(m.V"Definition" / firstdef * m.Cg(m.V"Definition")^0, - adddef) / mm.P + ((m.V"Definition" / firstdef) * (m.V"Definition" % adddef)^0) / mm.P } local pattern = S * m.Cg(m.Cc(false), "G") * exp / mm.P * (-any + patt_error) |