Message 229124 - Python tracker

Message229124

Author Aivar.Annamaa
Recipients Aivar.Annamaa
Date 2014-10-12.07:35:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1413099307.65.0.261518195286.issue22616@psf.upfronthosting.co.za>
In-reply-to
Content
Currently lineno and col_offset attributes in AST nodes have confusing roles. According to documentation they indicate the starting position of node's source text but according to recent developments (#16795) they seem to indicate a position most suitable to use in error messages related to that node (rather narrow goal IMO).

Another problem is that currently the AST nodes don't contain any information about the end position of corresponding source text. Therefore it's very difficult to relate nodes with source. One could want to do this for example in advanced graphical debuggers (https://bitbucket.org/plas/thonny)

I propose adding new attributes to AST nodes which indicate the corresponding source range. If you want to keep nodes lightweight by default, then you could also introduce a flag in ast.parse for getting these attributes.

The range could be given either in token indices or in character positions (or both). This probably needs more discussion. (I would vote against pointers to UTF-8 bytes, as is the case with col_offset currently.)
History
Date User Action Args
2014-10-12 07:35:07Aivar.Annamaasetrecipients: + Aivar.Annamaa
2014-10-12 07:35:07Aivar.Annamaasetmessageid: <1413099307.65.0.261518195286.issue22616@psf.upfronthosting.co.za>
2014-10-12 07:35:07Aivar.Annamaalinkissue22616 messages
2014-10-12 07:35:06Aivar.Annamaacreate