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 |
|
@@ -1,27 +1,28 b'' | |||||
1 |
|
1 | |||
2 | # loops |
|
2 | # loops | |
3 | jump 'ΠΠΎΠ½Π΅Π¦' |
|
3 | jump 'ΠΠΎΠ½Π΅Π¦' | |
4 | p 'ΠΡΠΎ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Π½Π΅ Π±ΡΠ΄Π΅Ρ Π²ΡΠ²Π΅Π΄Π΅Π½ΠΎ' |
|
4 | p 'ΠΡΠΎ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Π½Π΅ Π±ΡΠ΄Π΅Ρ Π²ΡΠ²Π΅Π΄Π΅Π½ΠΎ' | |
5 | :ΠΊΠΎΠ½Π΅Ρ |
|
5 | :ΠΊΠΎΠ½Π΅Ρ | |
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 | - |
@@ -1,93 +1,93 b'' | |||||
1 |
|
1 | |||
2 | (in-package cl-user) |
|
2 | (in-package cl-user) | |
3 |
|
3 | |||
4 | (defpackage :sugar-qsp.js) |
|
4 | (defpackage :sugar-qsp.js) | |
5 |
|
5 | |||
6 | (defpackage :sugar-qsp.main |
|
6 | (defpackage :sugar-qsp.main | |
7 | (:use :cl :ps :sugar-qsp.js) |
|
7 | (:use :cl :ps :sugar-qsp.js) | |
8 | (:export #:api-call #:by-id |
|
8 | (:export #:api-call #:by-id | |
9 | #:root #:in |
|
9 | #:root #:in | |
10 | #:vars #:objs #:current-location |
|
10 | #:vars #:objs #:current-location | |
11 | #:started-at #:timer-interval #:timer-obj |
|
11 | #:started-at #:timer-interval #:timer-obj | |
12 | #:state-stash #:playing #:locals |
|
12 | #:state-stash #:playing #:locals | |
13 | #:acts #:locs)) |
|
13 | #:acts #:locs)) | |
14 |
|
14 | |||
15 | ;;; API functions |
|
15 | ;;; API functions | |
16 | (defpackage :sugar-qsp.api |
|
16 | (defpackage :sugar-qsp.api | |
17 | (:use :cl :ps :sugar-qsp.main :sugar-qsp.js) |
|
17 | (:use :cl :ps :sugar-qsp.main :sugar-qsp.js) | |
18 | (:export #:with-frame #:with-call-args |
|
18 | (:export #:with-frame #:with-call-args | |
19 | #:stash-state |
|
19 | #:stash-state | |
20 |
|
20 | |||
21 | #:report-error #:sleep #:init-dom #:call-serv-loc |
|
21 | #:report-error #:sleep #:init-dom #:call-serv-loc | |
22 | #:newline #:clear-id #:prepare-contents #:get-id #:set-id #:append-id |
|
22 | #:newline #:clear-id #:prepare-contents #:get-id #:set-id #:append-id | |
23 | #:init-args #:get-result #:call-loc #:call-act |
|
23 | #:init-args #:get-result #:call-loc #:call-act | |
24 | #:get-frame #:add-text #:get-text #:clear-text #:enable-frame |
|
24 | #:get-frame #:add-text #:get-text #:clear-text #:enable-frame | |
25 | #:add-act #:del-act #:clear-act #:update-acts |
|
25 | #:add-act #:del-act #:clear-act #:update-acts | |
26 | #:qspfor |
|
26 | #:qspfor | |
27 | #:*var #:new-value #:index-num #:get #:set #:kill |
|
27 | #:*var #:new-value #:index-num #:get #:set #:kill | |
28 | #:var-real-name #:ensure-var #:var-ref #:get-var #:set-var |
|
28 | #:var-real-name #:ensure-var #:var-ref #:get-var #:set-var | |
29 | #:get-array #:set-array #:kill-var #:array-size |
|
29 | #:get-array #:set-array #:kill-var #:array-size | |
30 | #:push-local-frame #:pop-local-frame #:current-local-frame #:new-local |
|
30 | #:push-local-frame #:pop-local-frame #:current-local-frame #:new-local | |
31 | #:update-objs |
|
31 | #:update-objs | |
32 | #:menu |
|
32 | #:menu | |
33 | #:clean-audio |
|
33 | #:clean-audio | |
34 | #:show-image |
|
34 | #:show-image | |
35 | #:opengame #:savegame |
|
35 | #:opengame #:savegame | |
36 | )) |
|
36 | )) | |
37 |
|
37 | |||
38 | ;;; QSP library functions and macros |
|
38 | ;;; QSP library functions and macros | |
39 | (defpackage :sugar-qsp.lib |
|
39 | (defpackage :sugar-qsp.lib | |
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 | |
47 | #:qspver #:curloc |
|
47 | #:qspver #:curloc | |
48 | #:rnd #:qspmax #:qspmin |
|
48 | #:rnd #:qspmax #:qspmin | |
49 | #:arrsize #:len |
|
49 | #:arrsize #:len | |
50 | #:mid #:ucase #:lcase #:trim #:replace #:val #:qspstr |
|
50 | #:mid #:ucase #:lcase #:trim #:replace #:val #:qspstr | |
51 | #:exit #:desc |
|
51 | #:exit #:desc | |
52 | #:showstat #:msg |
|
52 | #:showstat #:msg | |
53 | #:showacts #:delact #:cla |
|
53 | #:showacts #:delact #:cla | |
54 | #:showobjs #:countobj #:getobj |
|
54 | #:showobjs #:countobj #:getobj | |
55 | #:isplay |
|
55 | #:isplay | |
56 | #:view |
|
56 | #:view | |
57 | #:showinput |
|
57 | #:showinput | |
58 | #:wait #:settimer |
|
58 | #:wait #:settimer | |
59 | #:local |
|
59 | #:local | |
60 | #:opengame #:savegame |
|
60 | #:opengame #:savegame | |
61 |
|
61 | |||
62 | #:goto #:xgoto |
|
62 | #:goto #:xgoto | |
63 | #:rand |
|
63 | #:rand | |
64 | #:copyarr #:arrpos #:arrcomp |
|
64 | #:copyarr #:arrpos #:arrcomp | |
65 | #:instr #:isnum #:strcomp #:strfind #:strpos |
|
65 | #:instr #:isnum #:strcomp #:strfind #:strpos | |
66 | #:iif |
|
66 | #:iif | |
67 | #:gosub #:func |
|
67 | #:gosub #:func | |
68 | #:dynamic #:dyneval |
|
68 | #:dynamic #:dyneval | |
69 | #:main-p #:main-pl #:main-nl #:maintxt #:desc #:main-clear |
|
69 | #:main-p #:main-pl #:main-nl #:maintxt #:desc #:main-clear | |
70 | #:stat-p #:stat-pl #:stat-nl #:stattxt #:stat-clear #:cls |
|
70 | #:stat-p #:stat-pl #:stat-nl #:stattxt #:stat-clear #:cls | |
71 | #:curacts |
|
71 | #:curacts | |
72 | #:addobj #:delobj #:killobj |
|
72 | #:addobj #:delobj #:killobj | |
73 | #:menu |
|
73 | #:menu | |
74 | #:play #:close #:closeall |
|
74 | #:play #:close #:closeall | |
75 | #:refint |
|
75 | #:refint | |
76 | #:usertxt #:cmdclear #:input |
|
76 | #:usertxt #:cmdclear #:input | |
77 | #:msecscount |
|
77 | #:msecscount | |
78 | #:rgb |
|
78 | #:rgb | |
79 | #:openqst #:addqst #:killqst |
|
79 | #:openqst #:addqst #:killqst | |
80 | )) |
|
80 | )) | |
81 |
|
81 | |||
82 | ;;; The compiler |
|
82 | ;;; The compiler | |
83 | (defpackage :sugar-qsp |
|
83 | (defpackage :sugar-qsp | |
84 | (:use :cl) |
|
84 | (:use :cl) | |
85 | (:local-nicknames (#:p #:esrap) |
|
85 | (:local-nicknames (#:p #:esrap) | |
86 | (#:lib :sugar-qsp.lib) |
|
86 | (#:lib :sugar-qsp.lib) | |
87 | (#:api :sugar-qsp.api) |
|
87 | (#:api :sugar-qsp.api) | |
88 | (#:main :sugar-qsp.main)) |
|
88 | (#:main :sugar-qsp.main)) | |
89 | (:export #:parse-file #:entry-point)) |
|
89 | (:export #:parse-file #:entry-point)) | |
90 |
|
90 | |||
91 | (setf (ps:ps-package-prefix "SUGAR-QSP.MAIN") "qsp_") |
|
91 | (setf (ps:ps-package-prefix "SUGAR-QSP.MAIN") "qsp_") | |
92 | (setf (ps:ps-package-prefix "SUGAR-QSP.API") "qsp_api_") |
|
92 | (setf (ps:ps-package-prefix "SUGAR-QSP.API") "qsp_api_") | |
93 | (setf (ps:ps-package-prefix "SUGAR-QSP.LIB") "qsp_lib_") |
|
93 | (setf (ps:ps-package-prefix "SUGAR-QSP.LIB") "qsp_lib_") |
@@ -1,162 +1,163 b'' | |||||
1 |
|
1 | |||
2 | (in-package sugar-qsp.lib) |
|
2 | (in-package sugar-qsp.lib) | |
3 |
|
3 | |||
4 | ;;;; Parenscript macros which make the parser's intermediate |
|
4 | ;;;; Parenscript macros which make the parser's intermediate | |
5 | ;;;; representation directly compilable by Parenscript |
|
5 | ;;;; representation directly compilable by Parenscript | |
6 | ;;;; Some utility macros for other .ps sources too. |
|
6 | ;;;; Some utility macros for other .ps sources too. | |
7 |
|
7 | |||
8 | ;;; Utils |
|
8 | ;;; Utils | |
9 |
|
9 | |||
10 | ;;; Common |
|
10 | ;;; Common | |
11 |
|
11 | |||
12 | (defpsmacro label-block (() &body body) |
|
12 | (defpsmacro label-block (() &body body) | |
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 |
|
16 | '((defvar _labels))) | |
17 | (tagbody |
|
17 | (tagbody | |
18 | ,@body |
|
18 | ,@body | |
19 | (void))))) |
|
19 | (void))))) | |
20 |
|
20 | |||
21 | (defpsmacro str (&rest forms) |
|
21 | (defpsmacro str (&rest forms) | |
22 | (cond ((zerop (length forms)) |
|
22 | (cond ((zerop (length forms)) | |
23 | "") |
|
23 | "") | |
24 | ((and (= 1 (length forms)) |
|
24 | ((and (= 1 (length forms)) | |
25 | (stringp (first forms))) |
|
25 | (stringp (first forms))) | |
26 | (first forms)) |
|
26 | (first forms)) | |
27 | (t |
|
27 | (t | |
28 | `(& ,@forms)))) |
|
28 | `(& ,@forms)))) | |
29 |
|
29 | |||
30 | ;;; 1loc |
|
30 | ;;; 1loc | |
31 |
|
31 | |||
32 | (defpsmacro location ((name) &body body) |
|
32 | (defpsmacro location ((name) &body body) | |
33 | `(setf (root locs ,name) |
|
33 | `(setf (root locs ,name) | |
34 | (async-lambda (args) |
|
34 | (async-lambda (args) | |
35 | (label-block () |
|
35 | (label-block () | |
36 | ,@body)))) |
|
36 | ,@body)))) | |
37 |
|
37 | |||
38 | (defpsmacro goto% (target &rest args) |
|
38 | (defpsmacro goto% (target &rest args) | |
39 | `(progn |
|
39 | `(progn | |
40 | (goto ,target ,args) |
|
40 | (goto ,target ,args) | |
41 | (exit))) |
|
41 | (exit))) | |
42 |
|
42 | |||
43 | (defpsmacro xgoto% (target &rest args) |
|
43 | (defpsmacro xgoto% (target &rest args) | |
44 | `(progn |
|
44 | `(progn | |
45 | (xgoto ,target ,args) |
|
45 | (xgoto ,target ,args) | |
46 | (exit))) |
|
46 | (exit))) | |
47 |
|
47 | |||
48 | ;;; 2var |
|
48 | ;;; 2var | |
49 |
|
49 | |||
50 | (defpsmacro qspvar (name index slot) |
|
50 | (defpsmacro qspvar (name index slot) | |
51 | `(api-call get-var ,(string name) ,index ,slot)) |
|
51 | `(api-call get-var ,(string name) ,index ,slot)) | |
52 |
|
52 | |||
53 | (defpsmacro set ((var vname vindex vslot) value) |
|
53 | (defpsmacro set ((var vname vindex vslot) value) | |
54 | (assert (eq var 'qspvar)) |
|
54 | (assert (eq var 'qspvar)) | |
55 | `(api-call set-var ,(string vname) ,vindex ,vslot ,value)) |
|
55 | `(api-call set-var ,(string vname) ,vindex ,vslot ,value)) | |
56 |
|
56 | |||
57 | ;;; 3expr |
|
57 | ;;; 3expr | |
58 |
|
58 | |||
59 | (defpsmacro <> (op1 op2) |
|
59 | (defpsmacro <> (op1 op2) | |
60 | `(not (equal ,op1 ,op2))) |
|
60 | `(not (equal ,op1 ,op2))) | |
61 |
|
61 | |||
62 | (defpsmacro ! (op1 op2) |
|
62 | (defpsmacro ! (op1 op2) | |
63 | `(not (equal ,op1 ,op2))) |
|
63 | `(not (equal ,op1 ,op2))) | |
64 |
|
64 | |||
65 | ;;; 4code |
|
65 | ;;; 4code | |
66 |
|
66 | |||
67 | (defpsmacro exec (&body body) |
|
67 | (defpsmacro exec (&body body) | |
68 | (format nil "javascript: ~{~A~^~%~}" (mapcar #'ps* body))) |
|
68 | (format nil "javascript: ~{~A~^~%~}" (mapcar #'ps* body))) | |
69 |
|
69 | |||
70 | ;;; 5arrays |
|
70 | ;;; 5arrays | |
71 |
|
71 | |||
72 | ;;; 6str |
|
72 | ;;; 6str | |
73 |
|
73 | |||
74 | (defpsmacro & (&rest args) |
|
74 | (defpsmacro & (&rest args) | |
75 | `(chain "" (concat ,@args))) |
|
75 | `(chain "" (concat ,@args))) | |
76 |
|
76 | |||
77 | ;;; 7if |
|
77 | ;;; 7if | |
78 |
|
78 | |||
79 | (defpsmacro qspcond (&rest clauses) |
|
79 | (defpsmacro qspcond (&rest clauses) | |
80 | `(cond ,@(loop :for clause :in clauses |
|
80 | `(cond ,@(loop :for clause :in clauses | |
81 | :collect (list (first clause) |
|
81 | :collect (list (first clause) | |
82 | `(tagbody |
|
82 | `(tagbody | |
83 | ,@(rest clause)))))) |
|
83 | ,@(rest clause)))))) | |
84 |
|
84 | |||
85 | ;;; 8sub |
|
85 | ;;; 8sub | |
86 |
|
86 | |||
87 | ;;; 9loops |
|
87 | ;;; 9loops | |
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 |
|
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 |
|
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))))) | |
103 | (setf (first funcs) (reverse (first funcs))) |
|
103 | (setf (first funcs) (reverse (first funcs))) | |
104 | (setf funcs (reverse funcs)) |
|
104 | (setf funcs (reverse funcs)) | |
105 | (if (= 2 (length funcs)) |
|
105 | (if (= 2 (length funcs)) | |
106 | `(progn |
|
106 | `(progn | |
107 | ,@body) |
|
107 | ,@body) | |
108 | `(progn |
|
108 | `(progn | |
109 |
(setf ,@(loop :for |
|
109 | (setf ,@(loop :for (label code . rest-labels) :on funcs :by #'cddr | |
110 |
:append `((@ |
|
110 | :append `((@ _labels ,label) | |
111 |
(block |
|
111 | (block label-body | |
112 |
|
|
112 | (block ,(intern label) | |
113 |
,@ |
|
113 | ,@code | |
114 |
|
|
114 | ,@(when rest-labels | |
115 |
|
|
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 | |||
120 | (defpsmacro qspblock (&body body) |
|
121 | (defpsmacro qspblock (&body body) | |
121 | `(async-lambda (args) |
|
122 | `(async-lambda (args) | |
122 | (label-block () |
|
123 | (label-block () | |
123 | ,@body))) |
|
124 | ,@body))) | |
124 |
|
125 | |||
125 | ;;; 11main |
|
126 | ;;; 11main | |
126 |
|
127 | |||
127 | (defpsmacro act (name img &body body) |
|
128 | (defpsmacro act (name img &body body) | |
128 | `(api-call add-act ,name ,img |
|
129 | `(api-call add-act ,name ,img | |
129 | (async-lambda () |
|
130 | (async-lambda () | |
130 | (label-block () |
|
131 | (label-block () | |
131 | ,@body)))) |
|
132 | ,@body)))) | |
132 |
|
133 | |||
133 | ;;; 12aux |
|
134 | ;;; 12aux | |
134 |
|
135 | |||
135 | ;;; 13diag |
|
136 | ;;; 13diag | |
136 |
|
137 | |||
137 | ;;; 14act |
|
138 | ;;; 14act | |
138 |
|
139 | |||
139 | ;;; 15objs |
|
140 | ;;; 15objs | |
140 |
|
141 | |||
141 | ;;; 16menu |
|
142 | ;;; 16menu | |
142 |
|
143 | |||
143 | ;;; 17sound |
|
144 | ;;; 17sound | |
144 |
|
145 | |||
145 | ;;; 18img |
|
146 | ;;; 18img | |
146 |
|
147 | |||
147 | ;;; 19input |
|
148 | ;;; 19input | |
148 |
|
149 | |||
149 | ;;; 20time |
|
150 | ;;; 20time | |
150 |
|
151 | |||
151 | ;;; 21local |
|
152 | ;;; 21local | |
152 |
|
153 | |||
153 | ;;; 22for |
|
154 | ;;; 22for | |
154 |
|
155 | |||
155 | (defpsmacro qspfor (var from to step &body body) |
|
156 | (defpsmacro qspfor (var from to step &body body) | |
156 | `((intern "QSPFOR" "API") |
|
157 | `((intern "QSPFOR" "API") | |
157 | ,(string (second var)) ,(third var) ;; name and index |
|
158 | ,(string (second var)) ,(third var) ;; name and index | |
158 | ,from ,to ,step |
|
159 | ,from ,to ,step | |
159 | (lambda () |
|
160 | (lambda () | |
160 | (block nil |
|
161 | (block nil | |
161 | ,@body |
|
162 | ,@body | |
162 | t)))) |
|
163 | t)))) |
General Comments 0
You need to be logged in to leave comments.
Login now