Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Tracking down errors in data from input files.

by moritz (Cardinal)
on Mar 07, 2008 at 11:32 UTC ( [id://672740]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Tracking down errors in data from input files.
in thread Tracking down errors in data from input files.

Object Orientation in Perl

My idea was inspired by compilers. They usually build a parse tree where the nodes store the matched text, logical information (what kind of token is this?) and the position in the source file.

Now if that parse tree is converted to an abstrac syntax tree, they still keep that line information, so if there is an execution error (let's say division by zero) the compiler can tell you which line of code caused that error.

So you can create a class "Traceable" that stores a string and its position in an input file to keep track of where it comes from.

It might be a bit overkill in your project, but for larger projects (parser, compiler) that is common practice.

(BTW it's nice to see that the quality of your questions improve over time ;)

  • Comment on Re^3: Tracking down errors in data from input files.

Replies are listed 'Best First'.
Re^4: Tracking down errors in data from input files.
by why_bird (Pilgrim) on Mar 14, 2008 at 09:50 UTC

    Thanks moritz---I think I got (some of) that, I don't think I can justify doing this for my current work project. (which doesn't neccessarily mean I won't try to do it anyway :) ). I might try it at home when I get some time, but think I have a way to go with OO before attempting something like that..

    But if the compiler knows what calls what and from where (since it prints that kind of stuff in error messages) is there a way to hi-jack that information?

    Also.. did you mean my questions were getting clearer or less stupid? :P

    Cheers why_bird
    ........
    Those are my principles. If you don't like them I have others.
    -- Groucho Marx
    .......

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://672740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-19 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found