Browse code

(console.tal) Improved example

neauoire authored on 05/12/2023 19:55:46
Showing 1 changed files
... ...
@@ -10,90 +10,86 @@
10 10
 
11 11
 @on-reset ( -> )
12 12
 	;on-argument .Console/vector DEO2
13
+	.Console/type DEI ?{ ;on-stdin .Console/vector DEO2 }
13 14
 	;dict/hello <print-str>
14
-	.Console/type DEI ?&has-arg
15 15
 	BRK
16
-	&has-arg ( -> )
17
-		;dict/queue <print-str>
18
-		BRK
19 16
 
20 17
 @on-argument ( -> )
21
-	.Console/type DEI ?&>no-argend
22
-		;on-stdin .Console/vector DEO2
23
-		BRK &>no-argend
24
-	.Console/read DEI .buf skey ?&eval
18
+	.Console/read DEI .buf skey ?{ BRK }
19
+	<print-type>
20
+	;dict/yousent <print-str>
21
+	LIT "" #18 DEO
22
+	;buf <print-str>/
23
+	LIT "" #18 DEO
24
+	#0a18 DEO
25
+	;buf sclr/ .Console/type DEI #04 NEQ ?{
26
+		;dict/argend <print-str>
27
+		;on-stdin .Console/vector DEO2 }
25 28
 	BRK
26
-	&eval ( -> )
27
-		<print-type>
28
-		;dict/yousent <print-str>
29
-		LIT "" #18 DEO
30
-		;buf <print-str>
31
-		LIT "" #18 DEO
32
-		#0a18 DEO
33
-		;buf sclr .Console/type DEI #04 NEQ ?&>no-close
34
-			;dict/argend <print-str>
35
-			;on-stdin .Console/vector DEO2 &>no-close
36
-		BRK
37 29
 
38 30
 @on-stdin ( -> )
39
-	.Console/read DEI .buf skey ?&eval
40
-	BRK
41
-	&eval ( -> )
42
-		<print-type>
43
-		;buf ;dict/quit scmp ?&quit
44
-		;dict/yousaid <print-str>
45
-		LIT "" #18 DEO
46
-		;buf <print-str>
47
-		LIT "" #18 DEO
48
-		#0a18 DEO
49
-		;buf sclr BRK
31
+	.Console/read DEI .buf skey ?{ BRK }
32
+	;buf ;dict/quit scmp ?&quit
33
+	<print-type>
34
+	;dict/yousaid <print-str>
35
+	LIT "" #18 DEO
36
+	;buf <print-str>/
37
+	LIT "" #18 DEO
38
+	#0a18 DEO
39
+	;buf sclr/ BRK
50 40
 	&quit ( buf* -> )
51
-		#010f DEO
41
+		#800f DEO
52 42
 		BRK
53 43
 
54 44
 @<print-type> ( -- )
55
-	[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 LDA2 !<print-str>
45
+	[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2
46
+	( ) LDA2 !<print-str>/
56 47
 
57 48
 (
58 49
 @|stdlib )
59 50
 
60 51
 @<print-str> ( str* -- )
61
-	!&
62
-	&while ( -- )
52
+	&w ( -- )
63 53
 		LDAk #18 DEO
64
-		INC2 & LDAk ?&while
54
+		INC2 & LDAk ?&w
65 55
 	POP2 JMP2r
66 56
 
67
-@skey ( key buf -- proc )
68
-	OVR #20 LTH ?&eval
69
-	#00 SWP sput #00 JMP2r
70
-	&eval POP2 #01 JMP2r
71
-
72 57
 @sclr ( str* -- )
73
-	!&
74
-	&while ( -- )
58
+	&w ( -- )
75 59
 		STH2k #00 STH2r STA
76
-		INC2 & LDAk ?&while
60
+		INC2 & LDAk ?&w
77 61
 	POP2 JMP2r
78 62
 
63
+@skey ( key buf -- proc )
64
+	OVR #20 LTH ?{
65
+		#00 SWP sput #00 JMP2r }
66
+	POP2 #01 JMP2r
67
+
79 68
 @scap ( str* -- end* )
80
-	!&
81
-	&while ( -- )
82
-		INC2 & LDAk ?&while
69
+	&w ( -- )
70
+		INC2 & LDAk ?&w
83 71
 	JMP2r
84 72
 
85 73
 @sput ( chr str* -- )
86
-	scap INC2k #00 ROT ROT STA
87
-	STA
74
+	scap/ STA
88 75
 	JMP2r
89 76
 
90 77
 @scmp ( a* b* -- f )
91 78
 	STH2
92
-	&loop ( -- )
93
-		LDAk LDAkr STHr ANDk #00 EQU ?&e
94
-		NEQk ?&e
95
-		POP2 INC2 INC2r !&loop
96
-	&e NIP2 POP2r EQU JMP2r
79
+	&l ( a* b* -- f )
80
+		LDAk LDAkr STHr NEQk ?&d
81
+		DUP EOR EQUk ?&d
82
+		POP2 INC2 INC2r !&l
83
+	&d ( a* c1 c2 b* -- f )
84
+		NIP2 POP2r EQU JMP2r
85
+
86
+@<phex> ( short* -- )
87
+	SWP <phex>/b
88
+	&b ( -- )
89
+		DUP #04 SFT <phex>/c
90
+	&c ( -- )
91
+		#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
92
+		JMP2r
97 93
 
98 94
 (
99 95
 @|assets )
... ...
@@ -109,5 +105,4 @@
109 105
 	&arg "(arg) $1
110 106
 	&quit "quit $1
111 107
 	&argend "(argend) 0a $1
112
-	&queue "(queue) 0a $1
113 108