enderpy
enderpy copied to clipboard
Support simple flag in annotate assignment
Annotated assignment statements have a flag called simple. This is hardcoded but should be assigned based on the following spec: https://docs.python.org/3/library/ast.html#ast.AnnAssign
Flag is set on this field: https://github.com/Glyphack/enderpy/blob/4589a3b2d16071a07ceae372a7910258fa188596/parser/src/parser/ast.rs#L137
Here we need to match lhs agains Name nodes and check if it is inside "()" or not: https://github.com/Glyphack/enderpy/blob/4589a3b2d16071a07ceae372a7910258fa188596/parser/src/parser/parser.rs#L1275
Thanks. I went down a rabbit hole yesterday trying to figure out where lhs gets initialized as an Expression::Name. I figure that's probably not that important, but now I'm curious as I can't seem to follow the stack trace. It must go something like:
~~parse_assignment_or_expression_statement -> parse_expressions -> parse_expression -> parse_conditional_expression -> ?~~
EDIT: Nevermind. I printed a backtrace so now I see how this works. The parser "cascades" down through various checks, eventually landing on parse_identifier.
I suppose it might actually be important if we don't track tokens by offset, or some other way to look up a token at a particular index. I'm assuming we don't want to add a surrounded_by_parens or similar field to the Name struct?