Open LeonB opened 4 months ago
Looked into goyacc but I don't see an obvious way to pass the offset into Query/AST.
Hey! that would be nice. jq-lsp uses a modified version of gojq's parser to keep track of token positions, might be a start. To get positions for runtime errors i think you would also have to pass along things while compiling.
@wader thanks! I'll look into it.
gojq is executing bytecodes which I didn't know. Adding offset to every bytecode would be a bit much I expect, so I think something like a symbol table should be implemented where we link opcodes to the corresponding symbols and offsets. The codeinfo
would be a nice start.
@wader do you have any thoughts about how to implement something like that?
No good ideas really, i would guess some kind of location info needs to be tracked on the stack during execution? maybe @itchyny has some ideas? looking at the codeinfo stuff atm it seems to be debug only, so maybe also needs to consider how much performance impact it would have
Would it be feasible and wanted to add files/line/column to things like iterator errors?
I had something in mind like: