Fixed some diagnostics warnings
Moved examples to tofix because fixing them is besides the point right now.
This commit is contained in:
parent
52164c82e3
commit
858fe11666
166 changed files with 68 additions and 264 deletions
|
@ -1,30 +0,0 @@
|
|||
local re = require 'relabel'
|
||||
|
||||
local g = re.compile[[
|
||||
S <- Id List
|
||||
List <- !. / Comma Id List
|
||||
Id <- Sp [a-z]+ / %{2}
|
||||
Comma <- Sp ',' / %{3}
|
||||
Sp <- %s*
|
||||
]]
|
||||
|
||||
function mymatch (g, s)
|
||||
local r, e, sfail = g:match(s)
|
||||
if not r then
|
||||
local line, col = re.calcline(s, #s - #sfail)
|
||||
local msg = "Error at line " .. line .. " (col " .. col .. ")"
|
||||
if e == 1 then
|
||||
return r, msg .. ": expecting an identifier before '" .. sfail .. "'"
|
||||
elseif e == 2 then
|
||||
return r, msg .. ": expecting ',' before '" .. sfail .. "'"
|
||||
else
|
||||
return r, msg
|
||||
end
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
print(mymatch(g, "one,two"))
|
||||
print(mymatch(g, "one two"))
|
||||
print(mymatch(g, "one,\n two,\nthree,"))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue