[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Line info for Lua Scripts
- From: Philippe Lhoste <PhiLho@...>
- Date: Tue, 19 Jun 2001 14:57:58 +0200 (MEST)
> As I use the literate programming tool noweb
> (http://www.eecs.harvard.edu/~nr/noweb/), source codes are generated from
> the document files. Suppose the document is called 'doc.nw' and the
> generated lua code 'code.lua'. When there is a syntax error, the lua
> interpreter points to the problem line in 'code.lua'. However, the line
> number does not coincides with the actual line number in 'doc.nw'. As the
> document grew, it becomes harder to trace the error message back to the
> actual location in the file 'doc.nw'.
> I usually use lua for scripting. Is there a good way to modify the lua
> interpreter 'lua' such that it is able to handle metainformation such as '
> #line 40 "doc.nw" '? Better still, is there a way to simply add some codes
> within 'code.lua' that modifies the state of dblib's 'currentline'
> appropriately? In the second way, the interpreter need not be modified.
Sorry if this answer is too naive, but can't you just set two global
variables and assign them where you need the information?
line, file = 40, "doc.nw"
line, file = 51, "doc.nw"
Since the line numbers are not the native (Lua code) one but the NoWeb
document ones, I suppose you can generate the above lines.
> >From: Roberto Ierusalimschy <firstname.lastname@example.org>
> > > Does Lua supports some kind of meta line information?
> >The debug library (dblib) has a function that returns (among
> other things)
> >the current line number, but it is not very efficient (it does a kind of
> >search into an internal data structure, and also builds a table to return
> >its results; its main use is for debugging ;-)
> >print(getinfo(1, 'l').currentline)
> twoonkio wrote:
> > Does Lua supports some kind of meta line information?
> > For instance, in C, line information can be included in generated source
> > codes as follows:
> > > #line 40 "doc.nw"
> > > double f(int x)
> > > :
> > Is there any equivalent syntax for Lua scripts?
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
Sent through GMX FreeMail - http://www.gmx.net