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