diff --git a/lips/Preproc.lua b/lips/Preproc.lua index 78308af..469b4d5 100644 --- a/lips/Preproc.lua +++ b/lips/Preproc.lua @@ -1,4 +1,5 @@ local abs = math.abs +local format = string.format local insert = table.insert local path = string.gsub(..., "[^.]+$", "") @@ -13,6 +14,13 @@ function Preproc:init(options) self.options = options or {} end +function Preproc:error(msg, got) + if got ~= nil then + msg = msg..', got '..tostring(got) + end + error(format('%s:%d: Error: %s', self.fn, self.line, msg), 2) +end + function Preproc:iter(statements) assert(statements) local i = 0