-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindentation_python.lisp
83 lines (73 loc) · 1.71 KB
/
indentation_python.lisp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
;Date: 06/08/2022
;Author: Claude Roux
;Description: We add a end# where an indented structure ends
(defmacro espace(x) (size (takelist (\(c) (eq c " ")) x)))
(defmacro inc(i) (+= (@ i 0) 1))
(defun skip(code i v)
(setq ligne (@ code (car i)))
(check
(or
(eq (count ligne "\"\"\"") 1)
(eq (count ligne "'''") 1)
)
(push v ligne)
(inc i)
(setq ligne (@ code (car i)))
(while
(and
(not (in ligne "\"\"\""))
(not (in ligne "'''"))
)
(inc i)
(push v ligne)
(setq ligne (@ code (car i)))
)
(push v ligne)
(inc i)
(setq ligne (@ code (car i)))
)
(while (eq (trim ligne) "")
(inc i)
(setq ligne (@ code (car i)))
)
ligne
)
(defun insert_label (code i v)
(check (< (car i) (size code))
(setq ligne (skip code i v))
(setq cpt (espace ligne))
(push v ligne)
(setq ref cpt)
(inc i)
(setq colon 0)
(while (< (car i) (size code))
(setq ligne (skip code i v))
(if (eq (last (trim ligne)) ":")
(+= colon 1)
)
(setq cpt (espace ligne))
(cond
((< cpt ref)
(break)
)
((eq cpt ref)
(inc i)
(push v ligne)
)
(true
(insert_label code i v)
(check colon
(push v (+ (join (to_list " " ref) "") "end#"))
(-= colon 1)
)
)
)
)
)
)
(setq code (split (fread (+ _current "descent.py")) "\n"))
(setq v ())
(insert_label code '(0) v)
(loop r v
(println r)
)