Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm rewriting Querylet, and in the process, I want to add better error messages. The problem is that Querylet is a source filter which translates (for example):
into
This works very well, but if there is a runtime error, say an error in ->connect(), Perl will claim an error in line 4 of the resulting code instead of line 3 of the original code. What I want to do is add appropriate #line nnn comments (see perlsyn) that match up the line numbers in the generated code back to the line numbers in the original code:
The only, minor snag in this scheme is that I haven't found a way to get at the current offset in the input stream to find out at which offset the current Querylet section starts. So my question boils down to these alternatives, or a better approach that I completely missed:
I don't care much for the fragility of the approach, as Querylet likely is the only source filter in action. Update: As I realize just after reviewing and posting, the offset only needs to work for the first use Querylet; statement, as Querylet transforms the complete rest of the program, passing through everything it does not recognize. I keep track of the line numbers there myself, but I lack the initial offset where the source filter starts.
|
|