lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I use the following function to have the line like. The comments are in the context of my library, but the code shall almost be what you need. Pil has a good introduction to the debug library (

--- retrieve the file info for the ast node
-- this helps having meaningful error messages or assert in thecode
-- @tparam number upstack the depth of the stack between the user model and the
--                        rule procesing (generally 2)
-- @treturn string "filename":line
function dsl.where(upstack)
    local loc = debug.getinfo((upstack or 0)+1, "Sl")
    return string.format('"%s":%d', loc.short_src, loc.currentline)
  Original Message  
From: Sean Conner
Sent: jeudi 15 mai 2014 23:33
To: Colin; Lua mailing list
Reply To: Lua mailing list

Also, is there an easy way to get the line number in Lua, much like C has
__LINE__? Because it would help me with error reporting with my C compiler
module [1][2].



[2]	Which relies upon the wrapper for TCC: