##// END OF EJS Templates
Fix labels
naryl -
r28:77d82154 default
parent child Browse files
Show More
@@ -1,12 +1,14 b''
1
1
2 * Duplicate label error (in the parser)
3 * Reporting error lines in the parser
2 * MENU with async/await
4 * MENU with async/await
3 * Special locations
5 * Special locations
4 * Special variables
6 * Special variables
5 * CLI build for Linux
7 * CLI build for Linux
6 * CLI build for Windows
8 * CLI build for Windows
9 * Storing error lines in the parser to report it in runtime errors
7
10
8 * Build Istreblenie
11 * Build Istreblenie
9 * Windows GUI (for the compiler)
12 * Windows GUI (for the compiler)
10 * Save-load game in slots
13 * Save-load game in slots
11 * Resizable frames
14 * Resizable frames
12 ** modifying it to suit compiler specifics
@@ -6,22 +6,23 b" p '\xd0\xad\xd1\x82\xd0\xbe \xd1\x81\xd0\xbe\xd0\xbe\xd0\xb1\xd1\x89\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5 \xd0\xbd\xd0\xb5 \xd0\xb1\xd1\x83\xd0\xb4\xd0\xb5\xd1\x82 \xd0\xb2\xd1\x8b\xd0\xb2\xd0\xb5\xd0\xb4\xd0\xb5\xd0\xbd\xd0\xbe'"
6 p 'А это сообщСниС ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ ΡƒΠ²ΠΈΠ΄ΠΈΡ‚'
6 p 'А это сообщСниС ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ ΡƒΠ²ΠΈΠ΄ΠΈΡ‚'
7
7
8 s=0
8 s=0
9 :loop
9 :loop1
10 if s<9:
10 if s<9:
11 s=s+1
11 s=s+1
12 pl s
12 pl s
13 jump 'loop'
13 jump 'loop1'
14 end
14 end
15 p 'Всё!'
15 p 'Всё!'
16
16
17 :loop
17 :loop2
18 if y<y0:
18 if y<y0:
19 if x<x0:
19 if x<x0:
20 x=x+1
20 x=x+1
21 jump 'loop'
21 jump 'loop2'
22 end
22 end
23 y=y+1
23 y=y+1
24 x=0
24 x=0
25 jump 'loop'
25 jump 'loop2'
26 if y > y0: exit
26 end
27 end
27 -
28 -
@@ -40,7 +40,7 b''
40 (:use :cl :ps :sugar-qsp.main :sugar-qsp.js)
40 (:use :cl :ps :sugar-qsp.main :sugar-qsp.js)
41 (:local-nicknames (#:api :sugar-qsp.api))
41 (:local-nicknames (#:api :sugar-qsp.api))
42 (:export #:str #:exec #:qspblock #:qspfor #:location
42 (:export #:str #:exec #:qspblock #:qspfor #:location
43 #:qspcond #:qspvar #:set #:local
43 #:qspcond #:qspvar #:set #:local #:jump
44
44
45 #:killvar #:killall
45 #:killvar #:killall
46 #:obj #:loc #:no
46 #:obj #:loc #:no
@@ -13,7 +13,7 b''
13 (let ((has-labels (some #'keywordp body)))
13 (let ((has-labels (some #'keywordp body)))
14 `(block nil
14 `(block nil
15 ,@(when has-labels
15 ,@(when has-labels
16 '((defvar __labels)))
16 '((defvar _labels)))
17 (tagbody
17 (tagbody
18 ,@body
18 ,@body
19 (void)))))
19 (void)))))
@@ -88,15 +88,15 b''
88 ;;; Yep, that's a huge kludge since Javascript doesn't support arbitrary labels
88 ;;; Yep, that's a huge kludge since Javascript doesn't support arbitrary labels
89
89
90 (defpsmacro jump (target)
90 (defpsmacro jump (target)
91 `(return-from ,(intern (string-upcase (second target)))
91 `(return-from label-body
92 (funcall (getprop __labels ,target))))
92 (funcall (getprop _labels ,(string-upcase (second target))))))
93
93
94 (defpsmacro tagbody (&body body)
94 (defpsmacro tagbody (&body body)
95 (let ((funcs (list nil :__nil)))
95 (let ((funcs (list nil "_nil")))
96 (dolist (form body)
96 (dolist (form body)
97 (cond ((keywordp form)
97 (cond ((keywordp form)
98 (setf (first funcs) (reverse (first funcs)))
98 (setf (first funcs) (reverse (first funcs)))
99 (push form funcs)
99 (push (string-upcase form) funcs)
100 (push nil funcs))
100 (push nil funcs))
101 (t
101 (t
102 (push form (first funcs)))))
102 (push form (first funcs)))))
@@ -106,14 +106,15 b''
106 `(progn
106 `(progn
107 ,@body)
107 ,@body)
108 `(progn
108 `(progn
109 (setf ,@(loop :for f :on funcs :by #'cddr
109 (setf ,@(loop :for (label code . rest-labels) :on funcs :by #'cddr
110 :append `((@ __labels ,(first f))
110 :append `((@ _labels ,label)
111 (block ,(intern (string-upcase (string (first f))))
111 (block label-body
112 ,@(second f)
112 (block ,(intern label)
113 ,@(when (third f)
113 ,@code
114 `((funcall
114 ,@(when rest-labels
115 (getprop __labels ,(third f)))))))))
115 `((funcall
116 (jump (str "__nil"))))))
116 (getprop _labels ,(first rest-labels))))))))))
117 (funcall (getprop _labels "_nil"))))))
117
118
118 ;;; 10dynamic
119 ;;; 10dynamic
119
120
General Comments 0
You need to be logged in to leave comments. Login now