This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients brett.cannon, gvanrossum, levkivskyi, lukasz.langa, rhettinger, serhiy.storchaka, vstinner
Date 2019-01-14.05:33:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547443997.33.0.0224880145977.issue33416@roundup.psfhosted.org>
In-reply-to
Content
This idea seems reasonable.  Most of the AST nodes have a span and it would be nice to know what that is.  I'm sure we will find use cases though I doubt that many compiler syntax errors would benefit (since a syntax error means that we don't have a completely matched grammar rule).

BTW, does this information have to be added by the parser or could there be am AST module function that deduces the end locations from the start location of next sibling node or from the parent node?  If so, it may still be possible get the benefit without slowing down or complicating the parser logic.

Do we know what other languages do (carry the full span info in the AST or deduce the span after the fact)?  I don't know what the best practices are in this regard.

One other thought:  We should be careful not to impair existing AST capabilities that support code rewriting and movement (i.e. refactoring tools).  The copy_location() and fix_missing_locations() functions would need to be updated as well.
History
Date User Action Args
2019-01-14 05:33:18rhettingersetrecipients: + rhettinger, gvanrossum, brett.cannon, vstinner, lukasz.langa, serhiy.storchaka, levkivskyi
2019-01-14 05:33:17rhettingersetmessageid: <1547443997.33.0.0224880145977.issue33416@roundup.psfhosted.org>
2019-01-14 05:33:17rhettingerlinkissue33416 messages
2019-01-14 05:33:17rhettingercreate