Re: [myhdl-list] " Error in user defined VHDL code" should show line, and column for err
Brought to you by:
jandecaluwe
From: Kevin S. <sta...@gm...> - 2010-07-03 19:37:31
|
Perhaps I am oversimplifying a complex problem, but why couldn't a filter function be written like this: def get_error_line_col(code_str, error_index, line_delimiter='\n'): line_num = 1 col_num = 1 for i in range(0, error_index): if (code_str[i] == line_delimiter): line_num += 1 col_num = 1 else: col_num += 1 return (line_num, col_num) test case I tried on it: test_str = '12345\n6789ABC\nDEFGHIJKLMNOPQ\n' >>> get_error_line_col(test_str, 22) (3, 9) >>> get_error_line_col(test_str, 4) (1, 5) etc. Hope this helps, Kevin Stanton On Jul 3, 2010, at 6:32, Jan Decaluwe <ja...@ja...> wrote: > Angel Ezquerra wrote: >> Jan Decaluwe <jan <at> jandecaluwe.com> writes: >> >>> Error messages are often a weak point, but I thought that in the particular >>> case of user-defined code, it was reasonable. I don't immediately understand >>> what you describe here, a small example welcome. >> >> I got the following error message while trying to use a very long VHDL >> user defined string on one of my myhdl python files: >> >> "raise ToVHDLError("Error in user defined VHDL code", msg, info) >> myhdl.ToVHDLError: in file dsp48e.py, function dsp48e starting on line 3: >> Error in user defined VHDL code: <type 'exceptions.ValueError'>: unsupported >> format character ',' (0x2c) at index 6175" >> >> As you can see, the error indicates "index 6175" as the place where the >> error happened. I assume that that refers to the 6175 character on the >> __vhdl__ string. If that is the case, while it would actually be >> possible to use that information to find where the error happened, >> it is definitelly not very practical to do so! Instead it would be >> much better if the error message told you that the error happened >> on line 89, column 12 of the __vhdl__ string, or, even better, >> on line 101, column 20 of the original python script. > > So you get the exact file, function, error condition, index in the string > and even the offending character, and this is not good enough :-) Mm. > > When something is wrong with the format string evaluation, MyHDL forwards > you whatever exception Python gives it. So this is pretty much what > native python would tell you. There are a myriad things that can go > wrong, and the error may be Python-version dependent. What you are > asking is combining the MyHDL info with the specific Python info, > which is probably unfeasible in practical terms. > > String errors are not normally reported in lines or columns. So for > complex cases like this, I think it's not unreasonable to organize > for easier debugging. For example, by putting the large template > string in a separate file, and use an editor that can move > to buffer positions (emacs has this natively). Or even to debug > the string in Python separately from its use in MyHDL. > > Jan > > -- > Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com > Python as a HDL: http://www.myhdl.org > VHDL development, the modern way: http://www.sigasi.com > Analog design automation: http://www.mephisto-da.com > World-class digital design: http://www.easics.com > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list |