Show More
@@ -35,10 +35,10 b' 1. **\xd0\x9f\xd1\x80\xd0\xbe\xd1\x81\xd1\x82\xd0\xbe \xd1\x81\xd0\xbe\xd0\xb1\xd0\xb5\xd1\x80\xd0\xb8 \xd0\xbc\xd0\xbd\xd0\xb5 \xd0\xb8\xd0\xb3\xd1\x80\xd1\x83**:<br/>' | |||||
35 |
|
35 | |||
36 | 2. **Я знаю что делаю**:<br/> |
|
36 | 2. **Я знаю что делаю**:<br/> | |
37 | `sugar-qsp game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`<br/> |
|
37 | `sugar-qsp game.txt -o game.html --body body.html --js jquery.js my-js-library.js --css styles/*.css`<br/> | |
38 | Если вы знаете что делаете, то для вас смысл опций очевиден. `body.html` |
|
38 | Если вы знаете что делаете, то для вас смысл опций очевиден. `body.html` и `default.css` | |
39 |
|
|
39 | лежат в каталоге `extras`. | |
40 |
|
40 | |||
41 | 3. **Я - фронтендер!**<br/> |
|
41 | 3. **Я - фронтендер!**<br/> | |
42 | `sugar-qsp game.txt -c -o game.js`<br/> |
|
42 | `sugar-qsp game.txt -c -o game.js`<br/> | |
43 | Просто соберёт игру в Javascript файл который вы можете разместить на своём |
|
43 | Просто соберёт игру в Javascript файл который вы можете разместить на своём | |
44 | сайте как вам угодно. Для запуска игры вызовите `SugarQSP.start()`. |
|
44 | сайте как вам угодно. |
@@ -37,10 +37,14 b'' | |||||
37 | `(funcall (root lib rand) 1 1000)) |
|
37 | `(funcall (root lib rand) 1 1000)) | |
38 |
|
38 | |||
39 | (ps:defpsmacro qspmax (&rest args) |
|
39 | (ps:defpsmacro qspmax (&rest args) | |
40 | `(max ,@args)) |
|
40 | (if (= 1 (length args)) | |
|
41 | `(*math.max.apply nil ,@args) | |||
|
42 | `(*math.max ,@args))) | |||
41 |
|
43 | |||
42 | (ps:defpsmacro qspmin (&rest args) |
|
44 | (ps:defpsmacro qspmin (&rest args) | |
43 | `(min ,@args)) |
|
45 | (if (= 1 (length args)) | |
|
46 | `(*math.min.apply nil ,@args) | |||
|
47 | `(*math.min ,@args))) | |||
44 |
|
48 | |||
45 | ;;; 5arrays |
|
49 | ;;; 5arrays | |
46 |
|
50 |
@@ -103,13 +103,18 b'' | |||||
103 | ;;; Identifiers |
|
103 | ;;; Identifiers | |
104 |
|
104 | |||
105 | ;; From the official docs |
|
105 | ;; From the official docs | |
106 |
(defparameter *keywords* '(act addlib addobj addqst and arrcomp arrpos arrsize cla clear *clear close clr *clr cls cmdclear cmdclr copyarr |
|
106 | (defparameter *keywords* '(act addlib addobj addqst and arrcomp arrpos arrsize cla clear *clear close clr *clr cls cmdclear cmdclr copyarr counter countobj curacts curloc debug delact dellib delobj desc disablescroll disablesubex dynamic dyneval else elseif end exit fcolor fname freelib fsize func getobj gosub goto gs gt if iif inclib input instr isnum isplay jump killall killobj killqst killvar lcase lcolor len let loc maintxt max menu mid min mod msecscount msg nl *nl no nosave obj onactsel ongload ongsave onnewloc onobjadd onobjdel onobjsel opengame openqst or p *p pl *pl play qspver rand refint replace rgb rnd savegame selact selobj set settimer showacts showinput showobjs showstat stattxt str strcomp strfind strpos trim ucase unsel unselect usercom user_text usrtxt val view wait xgoto xgt)) | |
|
107 | ||||
|
108 | (defun trim-$ (str) | |||
|
109 | (if (char= #\$ (elt str 0)) | |||
|
110 | (subseq str 1) | |||
|
111 | str)) | |||
107 |
|
112 | |||
108 | (defun qsp-keyword-p (id) |
|
113 | (defun qsp-keyword-p (id) | |
109 | (member (intern (string-upcase id)) *keywords*)) |
|
114 | (member (intern (trim-$ (string-upcase id))) *keywords*)) | |
110 |
|
115 | |||
111 | (defun not-qsp-keyword-p (id) |
|
116 | (defun not-qsp-keyword-p (id) | |
112 | (not (member (intern (string-upcase id)) *keywords*))) |
|
117 | (not (member (intern (trim-$ (string-upcase id))) *keywords*))) | |
113 |
|
118 | |||
114 | (p:defrule qsp-keyword (qsp-keyword-p identifier-raw)) |
|
119 | (p:defrule qsp-keyword (qsp-keyword-p identifier-raw)) | |
115 |
|
120 | |||
@@ -118,10 +123,7 b'' | |||||
118 | (digit-char-p character))) |
|
123 | (digit-char-p character))) | |
119 | (p:defrule identifier-raw (and id-first (* id-next)) |
|
124 | (p:defrule identifier-raw (and id-first (* id-next)) | |
120 | (:lambda (list) |
|
125 | (:lambda (list) | |
121 |
( |
|
126 | (intern (string-upcase (p:text list))))) | |
122 | (when (member id *keywords*) |
|
|||
123 | (error "~A is a keyword" id)) |
|
|||
124 | (intern (string-upcase id))))) |
|
|||
125 |
|
127 | |||
126 | (p:defrule identifier (not-qsp-keyword-p identifier-raw)) |
|
128 | (p:defrule identifier (not-qsp-keyword-p identifier-raw)) | |
127 |
|
129 | |||
@@ -250,7 +252,10 b'' | |||||
250 | (:lambda (list) |
|
252 | (:lambda (list) | |
251 | (intern (string (second list)) :keyword))) |
|
253 | (intern (string (second list)) :keyword))) | |
252 |
|
254 | |||
253 |
(p:defrule comment (and #\! (* (or |
|
255 | (p:defrule comment (and #\! (* (or qsp-string brace-comment text-spaces not-newline))) | |
|
256 | (:constant nil)) | |||
|
257 | ||||
|
258 | (p:defrule brace-comment (and #\{ (* (not-brace character)) #\}) | |||
254 | (:constant nil)) |
|
259 | (:constant nil)) | |
255 |
|
260 | |||
256 | ;;; Blocks |
|
261 | ;;; Blocks | |
@@ -346,11 +351,15 b'' | |||||
346 | (:function third)) |
|
351 | (:function third)) | |
347 | (p:defrule plain-arguments (and spaces base-arguments) |
|
352 | (p:defrule plain-arguments (and spaces base-arguments) | |
348 | (:function second)) |
|
353 | (:function second)) | |
349 |
(p:defrule no-arguments (or spaces (p:& #\newline) |
|
354 | (p:defrule no-arguments (or (and spaces? (p:& #\newline)) | |
|
355 | (and spaces? (p:& #\&)) | |||
|
356 | spaces?) | |||
350 | (:constant nil)) |
|
357 | (:constant nil)) | |
351 | (p:defrule base-arguments (and first-argument (* next-argument)) |
|
358 | (p:defrule base-arguments (or (and first-argument (* next-argument)) spaces?) | |
352 | (:destructure (first rest) |
|
359 | (:lambda (list) | |
353 | (list* first rest))) |
|
360 | (if (null list) | |
|
361 | nil | |||
|
362 | (list* (first list) (second list))))) | |||
354 |
|
363 | |||
355 | ;;; Intrinsics |
|
364 | ;;; Intrinsics | |
356 |
|
365 | |||
@@ -437,17 +446,17 b'' | |||||
437 | (dynamic nil 1 10) |
|
446 | (dynamic nil 1 10) | |
438 | (dyneval t 1 10) |
|
447 | (dyneval t 1 10) | |
439 | ;; Main window |
|
448 | ;; Main window | |
440 | (main-p nil 1 1 "*p") |
|
|||
441 | (main-pl nil 1 1 "*pl") |
|
449 | (main-pl nil 1 1 "*pl") | |
442 | (main-nl nil 0 1 "*nl") |
|
450 | (main-nl nil 0 1 "*nl") | |
|
451 | (main-p nil 1 1 "*p") | |||
443 | (maintxt t 0 0) |
|
452 | (maintxt t 0 0) | |
444 | (desc t 1 1) |
|
453 | (desc t 1 1) | |
445 | (main-clear nil 0 0 "*clear" "*clr") |
|
454 | (main-clear nil 0 0 "*clear" "*clr") | |
446 | ;; Aux window |
|
455 | ;; Aux window | |
447 | (showstat nil 1 1) |
|
456 | (showstat nil 1 1) | |
448 | (stat-p nil 1 1 "p") |
|
|||
449 | (stat-pl nil 1 1 "pl") |
|
457 | (stat-pl nil 1 1 "pl") | |
450 | (stat-nl nil 0 1 "nl") |
|
458 | (stat-nl nil 0 1 "nl") | |
|
459 | (stat-p nil 1 1 "p") | |||
451 | (stattxt t 0 0) |
|
460 | (stattxt t 0 0) | |
452 | (stat-clear nil 0 0 "clear" "clr") |
|
461 | (stat-clear nil 0 0 "clear" "clr") | |
453 | (cls nil 0 0) |
|
462 | (cls nil 0 0) | |
@@ -503,17 +512,11 b'' | |||||
503 | (p:defrule and-expr (and eq-expr (* (and spaces? and-op spaces? eq-expr))) |
|
512 | (p:defrule and-expr (and eq-expr (* (and spaces? and-op spaces? eq-expr))) | |
504 | (:function do-binop)) |
|
513 | (:function do-binop)) | |
505 |
|
514 | |||
506 |
(p:defrule eq-expr (and |
|
515 | (p:defrule eq-expr (and sum-expr (* (and spaces? (or "<=" ">=" "=<" "=>" "<>" | |
507 |
|
|
516 | "=" "<" ">" "!") | |
508 | spaces? cat-expr))) |
|
517 | spaces? cat-expr))) | |
509 | (:function do-binop)) |
|
518 | (:function do-binop)) | |
510 |
|
519 | |||
511 | (p:defrule cat-expr (and sum-expr (* (and spaces? #\& spaces? (p:! expr-stopper) sum-expr))) |
|
|||
512 | (:lambda (list) |
|
|||
513 | (do-binop (list (first list) (mapcar (lambda (l) |
|
|||
514 | (remove-nth l 3)) |
|
|||
515 | (second list)))))) |
|
|||
516 |
|
||||
517 | (p:defrule sum-expr (and mod-expr (* (and spaces? (or #\+ #\-) spaces? mod-expr))) |
|
520 | (p:defrule sum-expr (and mod-expr (* (and spaces? (or #\+ #\-) spaces? mod-expr))) | |
518 | (:function do-binop)) |
|
521 | (:function do-binop)) | |
519 |
|
522 | |||
@@ -552,15 +555,21 b'' | |||||
552 | (:lambda (list) |
|
555 | (:lambda (list) | |
553 | (or (third list) :end))) |
|
556 | (or (third list) :end))) | |
554 |
|
557 | |||
555 | (p:defrule assignment (or kw-assignment plain-assignment) |
|
558 | (p:defrule assignment (or kw-assignment plain-assignment op-assignment) | |
556 | (:destructure (var eq expr) |
|
559 | (:destructure (var eq expr) | |
557 | (declare (ignore eq)) |
|
560 | (declare (ignore eq)) | |
558 | (list 'set var expr))) |
|
561 | (list 'set var expr))) | |
559 |
|
562 | |||
|
563 | (p:defrule kw-assignment (and (or (p:~ "let") (p:~ "set")) spaces? (or op-assignment plain-assignment)) | |||
|
564 | (:function third)) | |||
|
565 | ||||
|
566 | (p:defrule op-assignment (and variable spaces? (or "+" "-" "*" "/") #\= spaces? expression) | |||
|
567 | (:destructure (var ws1 op eq ws2 expr) | |||
|
568 | (declare (ignore ws1 ws2)) | |||
|
569 | (list var eq (intern-first (list op var expr))))) | |||
|
570 | ||||
560 | (p:defrule plain-assignment (and variable spaces? #\= spaces? expression) |
|
571 | (p:defrule plain-assignment (and variable spaces? #\= spaces? expression) | |
561 | (:function remove-nil)) |
|
572 | (:function remove-nil)) | |
562 | (p:defrule kw-assignment (and (or (p:~ "let") (p:~ "set")) spaces? plain-assignment) |
|
|||
563 | (:function third)) |
|
|||
564 |
|
573 | |||
565 | ;;; Non-string literals |
|
574 | ;;; Non-string literals | |
566 |
|
575 |
General Comments 0
You need to be logged in to leave comments.
Login now