scrapscript icon indicating copy to clipboard operation
scrapscript copied to clipboard

Maintain line and character number after parsing

Open gregorybchris opened this issue 2 years ago • 5 comments

Evaluation has many failure cases, many of which have pretty reasonable error messages. However we do not maintain the line and character numbers associated with nodes in the AST. The interpreter can't point to the part of the code associated with a failure that occurs during evaluation.

This feature request is to make code index information available in the evaluation stage.

gregorybchris avatar Jan 10 '24 02:01 gregorybchris

This is a little finicky right now unless we want to store (invalid) line number information on all objects because the AST structures are objects themselves. Perhaps we should separate them out (ehhhh) or find another way to do a mixin or something.

tekknolagi avatar Jan 10 '24 04:01 tekknolagi

Screenshot from 2024-01-10 11-31-29

came across this out of nowhere this morning

tekknolagi avatar Jan 10 '24 16:01 tekknolagi

the reasoning is a little weird but i think we can calculate the line/col from the byte position easily and it's only one number to store

tekknolagi avatar Jan 10 '24 16:01 tekknolagi

I saw/skimmed part of a cool talk that did this for Circle, I think. Perhaps this talk https://www.youtube.com/watch?v=1m_5SVmGA4k

They have some cool tricks

tekknolagi avatar Jan 10 '24 16:01 tekknolagi

Oh, no, lmao, it was Carbon: https://www.youtube.com/watch?v=ZI198eFghJk Starting ~30mins?

tekknolagi avatar Jan 10 '24 16:01 tekknolagi