stefnotch / quantum-sheet

QuantumSheet - A user friendly mathematics worksheet and solver
https://stefnotch.github.io/quantum-sheet/
GNU General Public License v3.0
55 stars 5 forks source link

Scopes #19

Open stefnotch opened 3 years ago

stefnotch commented 3 years ago

Some interesting stuff regarding name resolution and scopes https://github.com/github/stack-graphs https://pl.ewi.tudelft.nl/research/projects/scope-graphs/

stefnotch commented 2 years ago

https://github.com/stefnotch/quantum-sheet/blob/db44f029e008d79e30d37ecf5d692b9a2035e71e/src/model/document/document-element.ts#L45-L47

So, basically, we have this

Document

When we add or move a block, we first figure out the target index. (Binary search over the block positions) Then, we can check if the target index has changed at all. If not, we can instantly return. Then, we take the block above it. If its a normal block, we can just use its scope as our scope If its a scope end block, we jump to the scope start block. And then we use its scope as our scope. Then, we tell the scope about all the variables that we want to 'get' (e.g. 3x+5=) Then, we tell the scope about the 'variables' that we want to provide (e.g. a:=7)

This can trivially be extended to work with nested scopes