Add end offsets to AST and source map #1557
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
Added end offsets for the Vyper AST nodes and the source map.
How I did it
asttokens
library.end_lineno
andend_col_offset
attributes to the final Vyper AST. (Attributes with these names are included in the standard ast library as of Python 3.8)LLLnode
objects, and add their values to the source map.How to verify it
I've checked it manually but tests still need to be written, as well existing tests will need updating. I will do so if and when the concept is finalized / approved.
Comments / Thoughts
This PR is meant as a proof of concept. I assume it will need some discussion and work before it can be merged. The following questions come to mind:
asttokens
library as a requirement? If not, I can instead take heavy inspiration from it and include the same functionality without requiring the import.(lineno, col_offset, end_lineno, end_col_offset)
. This is effectively a breaking change for any program expecting exactly a two item tuple. Other approaches could be:[(lineno, col_offset), (end_lineno, end_col_offset)]
(start, length)
- more in line with solc output but less-so with python ASTs. Also a larger deviation from the current output and so a larger breaking change.Cute Animal Picture