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 levkivskyi
Recipients brett.cannon, gvanrossum, levkivskyi, lukasz.langa, rhettinger, serhiy.storchaka, vstinner
Date 2019-01-14.11:18:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547464719.54.0.893022516515.issue33416@roundup.psfhosted.org>
In-reply-to
Content
> 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).

This is mostly useful for code analysis tools and IDEs.

> 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?

There may be some other ways to do it, but currently I am adding both `end_lineno` and `end_col_offset` to AST, and `n_end_lineno` and `n_end_col_offset` in CST. The latter are needed to easily take care of situations like `a + (b )`, and other corner cases. I could imagine it is possible to live with only end position information in AST to save some memory, but then the code will be much harder to maintain. We can discuss details in the PR.

> Do we know what other languages do (carry the full span info in the AST or deduce the span after the fact)?

I didn't do real research, but quick browsing shows carrying the end position info is quite common. But more importantly as Serhiy noted, deducing might be just not possible in some situations.

> It is up to you Ivan.

OK, I will close the other one as superseded by this issue.
History
Date User Action Args
2019-01-14 11:18:41levkivskyisetrecipients: + levkivskyi, gvanrossum, brett.cannon, rhettinger, vstinner, lukasz.langa, serhiy.storchaka
2019-01-14 11:18:39levkivskyisetmessageid: <1547464719.54.0.893022516515.issue33416@roundup.psfhosted.org>
2019-01-14 11:18:39levkivskyilinkissue33416 messages
2019-01-14 11:18:39levkivskyicreate