Commit Graph

10 Commits

Author SHA1 Message Date
Charlie Marsh ed3b4eb72b
Add `TextRange` to `Identifier` (#8)
## Summary

This PR adds `TextRange` to `Identifier`. Right now, the AST only
includes ranges for identifiers in certain cases (`Expr::Name`,
`Keyword`, etc.), namely when the identifier comprises an entire AST
node. In Ruff, we do additional ad-hoc lexing to extract identifiers
from source code.

One frequent example: given a function `def f(): ...`, we lex to find
the range of `f`, for use in diagnostics.

Another: `except ValueError as e`, for which the AST doesn't include a
range for `e`.

Note that, as an optimization, we avoid storing the `TextRange` for
`Expr::Name`, since it's already included.
2023-06-20 11:19:27 -04:00
Micha Reiser 192379cede
Move `range` from `Attributed` to `Node`s (#22)
* Move `range` from `Attributed` to `Node`s

* No Attributed + custom for Range PoC

* Generate all located variants, generate enum implementations

* Implement `Copy` on simple enums

* Move `Suite` to `ranged` and `located`

* Update tests
---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2023-05-15 15:08:12 +09:00
Jeong YunWon 455bcc01a0 Give identifier and int ast types 2023-05-10 19:33:39 +09:00
Jeong YunWon 09a6afdd04 Adapt SourceLocation 2023-05-09 20:34:48 +09:00
Micha Reiser 58c35ab458 Replace row/column based Location with byte-offsets. 2023-05-08 03:38:10 +09:00
Jeong YunWon 6d7358090b Refactor ast to hold data as seperated type 2023-05-07 19:20:47 +09:00
harupy ff00460ff4 Fix locations of parethesized expressions 2022-12-18 20:53:30 +09:00
dvermd fa41a1e2f6 Fix ast types' _fields and use 0-based column 2022-10-27 03:09:38 +09:00
Charlie Marsh 952d70b9d1 Add expression context parsing 2022-10-17 15:20:33 -04:00
Charlie Marsh 1cc342e4ed Add end locations to all nodes (#4192) 2022-10-17 13:18:30 +09:00