##// END OF EJS Templates
FOR loop
naryl -
r17:44cead28 default
parent child Browse files
Show More
@@ -0,0 +1,18 b''
1
2 # for
3 FOR k1=0 TO 5:
4 *PL k1
5 IF k1=3: EXIT
6 END
7
8 FOR номер_нпц = 1 TO количество_нпц: GS 'инициализировать нпц', номер_нпц
9
10 стоимость['меч'] = 10
11 стоимость['доспех'] = 250
12 стоимость['щит'] = 15
13 стоимость_снаряжения = 0
14 FOR номер_предмета = 0 TO ARRSIZE('стоимость')-1: стоимость_снаряжения += стоимость[номер_предмета]
15
16 FOR i = 1 TO 10 STEP 2: *PL i
17
18 -
@@ -1,6 +1,10 b''
1 1
2 * Finish lib
3 * CLI build for Linux
4 * CLI build for Windows
5
6 * Build Istreblenie
2 7 * Windows GUI (for the compiler)
3 8 * Save-load game in slots
4 9 * Resizable frames
5 * Build Istreblenie
6 10 ** modifying it to suit compiler specifics No newline at end of file
@@ -78,6 +78,9 b''
78 78 (p:defrule colon #\:
79 79 (:constant nil))
80 80
81 (p:defrule equal #\=
82 (:constant nil))
83
81 84 (p:defrule alphanumeric (alphanumericp character))
82 85
83 86 (p:defrule not-newline (not-newline character))
@@ -102,8 +105,7 b''
102 105
103 106 ;;; Identifiers
104 107
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 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 local 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))
108 (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 for 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 local 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 step str strcomp strfind strpos to trim ucase unsel unselect usercom user_text usrtxt val view wait xgoto xgt))
107 109
108 110 (defun trim-$ (str)
109 111 (if (char= #\$ (elt str 0))
@@ -266,7 +268,7 b''
266 268
267 269 ;;; Blocks
268 270
269 (p:defrule block (or block-act block-if))
271 (p:defrule block (or block-act block-if block-for))
270 272
271 273 (p:defrule block-if (and block-if-head block-if-body)
272 274 (:destructure (head body)
@@ -325,12 +327,6 b''
325 327 (:lambda (list)
326 328 (apply #'append list)))
327 329
328 (p:defrule block-act-sl line-body)
329
330 (p:defrule block-act-ml (and newline-block-body block-act-end)
331 (:lambda (list)
332 (apply #'list* (butlast list))))
333
334 330 (p:defrule block-act-head (and (p:~ "act") spaces qsp-string spaces?
335 331 (p:? block-act-head-img)
336 332 colon spaces?)
@@ -343,7 +339,36 b''
343 339 (:lambda (list)
344 340 (or (third list) "")))
345 341
346 (p:defrule block-act-end (and (p:~ "end"))
342 (p:defrule block-for (and block-for-head (or block-ml block-sl))
343 (:lambda (list)
344 (apply #'append list)))
345
346 (p:defrule block-for-head (and (p:~ "for") spaces variable spaces? equal spaces? expression
347 (p:~ "to") spaces expression
348 block-for-head-step
349 colon spaces?)
350 (:lambda (list)
351 (unless (eq (fourth (third list)) :num)
352 (error "For counter variable must be numeric."))
353 (list 'qspfor
354 (elt list 2)
355 (elt list 6)
356 (elt list 9)
357 (elt list 10))))
358
359 (p:defrule block-for-head-step (p:? (and (p:~ "step") spaces expression spaces?))
360 (:lambda (list)
361 (if list
362 (third list)
363 1)))
364
365 (p:defrule block-sl line-body)
366
367 (p:defrule block-ml (and newline-block-body block-end)
368 (:lambda (list)
369 (apply #'list* (butlast list))))
370
371 (p:defrule block-end (and (p:~ "end"))
347 372 (:constant nil))
348 373
349 374 ;;; Calls
@@ -191,3 +191,13 b''
191 191 ;;; 20time
192 192
193 193 ;;; 21local
194
195 ;;; 22for
196
197 (ps:defpsmacro qspfor (var from to step &body body)
198 `(block nil
199 (set ,var ,from)
200 (ps:for ()
201 ((< ,var ,to))
202 ((set ,var (+ ,var ,step)))
203 ,@body)))
General Comments 0
You need to be logged in to leave comments. Login now