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,39 +0,0 @@
|
|||
local m = require'lpeglabel'
|
||||
local re = require'relabel'
|
||||
|
||||
local terror = {}
|
||||
|
||||
local function newError(s)
|
||||
table.insert(terror, s)
|
||||
return #terror
|
||||
end
|
||||
|
||||
local errUndef = newError("undefined")
|
||||
local errId = newError("expecting an identifier")
|
||||
local errComma = newError("expecting ','")
|
||||
|
||||
local id = m.R'az'^1
|
||||
|
||||
local g = m.P{
|
||||
"S",
|
||||
S = m.V"Id" * m.V"List",
|
||||
List = -m.P(1) + m.V"Comma" * m.V"Id" * m.V"List",
|
||||
Id = m.V"Sp" * id + m.T(errId),
|
||||
Comma = m.V"Sp" * "," + m.T(errComma),
|
||||
Sp = m.S" \n\t"^0,
|
||||
}
|
||||
|
||||
|
||||
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 .. "): "
|
||||
return r, msg .. terror[e] .. " before '" .. sfail .. "'"
|
||||
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