-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservecommon.fs
36 lines (34 loc) · 1.04 KB
/
servecommon.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
CREATE input-word 0 C, 255 ALLOT
: fix-percent ( addr len )
0 ?DO
DUP I + C@
DUP [CHAR] % = IF
DROP DUP I + 1+ 0 0 ROT 2 ['] >NUMBER 16 base-execute 2DROP D>S 3
ELSE 1 THEN
>R
input-word DUP C@ + 1+ C!
input-word C@ 1+ input-word C!
R> +LOOP
DROP
;
VARIABLE parse-mode
REQUIRE debugging.fs
: parse-args ( ptr len -- )
2DUP S" debug=" SEARCH IF ( ptr len value n-rest )
6 /STRING 2>R $0. 2R> >NUMBER 2DROP D>S TO debug-mode? ( ptr len )
ELSE 2DROP THEN ( ptr len )
\ 2DUP S" language=" SEARCH IF
\ 9 /STRING 2DUP S" &" SEARCH IF ( ptr len lang-start n-rest lang-end n-rest )
\ DROP SWAP DROP OVER - ( ptr len lang-start lang-len )
\ FPATH ALSO-PATH ( ptr len )
\ ELSE 2DROP 2DROP THEN
\ ELSE 2DROP THEN ( ptr len )
2DUP S" parse=" SEARCH IF
TRUE parse-mode !
6 /STRING fix-percent input-word ." Parsing: " COUNT TYPE CR CR
ELSE
2DROP S" generate=" SEARCH IF
9 /STRING fix-percent input-word ." Paradigm for: " COUNT TYPE CR CR
ELSE ." arguments?" CR BYE THEN
THEN
;