-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval.lobster
51 lines (45 loc) · 1.3 KB
/
eval.lobster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import print_f
import navigation
import parse
import selection
import modify
// ts_goto_selection()
// ts_set_text("hello")
// find first cell with EVAL text
def main():
var x,y=subgrid_size()
ts_goto_child(0)
let exec_code=[]::string
find_eval(x,y)
build_recursive_code(exec_code)
exec_code.push("\"0\"")
ts_goto_selection()
let exec_text=concat_string(exec_code,"\n")
let a,b=compile_run_code(exec_text,[])
ts_set_status_message("return {a} ; message {b}")
def find_eval(x,y):
for(y)j:
for(x)i:
move_in_grid(i,j)
if(ts_get_text()=="EVAL"):
if(not has_subgrid()):
ts_set_status_message("no subgrid")
return from main
else:
ts_goto_child(0)
return
ts_set_status_message("no eval found")
return from main
def build_recursive_code(exec_code,depth=0)->void:
let x,y=current_grid_size()
for(y)j:
for(x)i:
move_in_grid(i,j)
if(length(ts_get_text())):
exec_code.push(repeat_string(" ",depth)+ts_get_text())
if(has_subgrid()):
ts_goto_child(0)
build_recursive_code(exec_code,depth+1)
ts_goto_parent()
return
main()