| 1 : |
anton
|
1.1
|
include glocals.fs |
| 2 : |
|
|
|
| 3 : |
|
|
: localsinfo \ !! only debugging |
| 4 : |
|
|
." stack: " .s ." locals-size: " locals-size ? ." locals-list" |
| 5 : |
|
|
also locals words previous cr ; |
| 6 : |
|
|
|
| 7 : |
|
|
." before foo" cr |
| 8 : |
|
|
: foo |
| 9 : |
|
|
{ c: a b c: c d: d } |
| 10 : |
|
|
a . |
| 11 : |
|
|
b . |
| 12 : |
|
|
d type |
| 13 : |
|
|
c . cr |
| 14 : |
|
|
; |
| 15 : |
|
|
|
| 16 : |
|
|
." before" .s cr |
| 17 : |
|
|
lp@ . cr |
| 18 : |
|
|
1 2 3 s" xxx" foo |
| 19 : |
|
|
lp@ . cr |
| 20 : |
|
|
." after" .s cr |
| 21 : |
|
|
|
| 22 : |
|
|
|
| 23 : |
|
|
." xxx" cr |
| 24 : |
|
|
.s cr |
| 25 : |
|
|
depth . cr |
| 26 : |
|
|
|
| 27 : |
|
|
|
| 28 : |
|
|
." testing part 2" cr |
| 29 : |
|
|
|
| 30 : |
|
|
: xxxx |
| 31 : |
anton
|
1.2
|
[ ." starting xxxx" .s cr ] |
| 32 : |
anton
|
1.1
|
{ f } f |
| 33 : |
anton
|
1.2
|
if |
| 34 : |
anton
|
1.1
|
{ a b } |
| 35 : |
|
|
b a |
| 36 : |
|
|
[ ." before else" .s cr ] |
| 37 : |
anton
|
1.2
|
else |
| 38 : |
anton
|
1.1
|
[ ." after else" .s cr ] |
| 39 : |
|
|
{ c d } |
| 40 : |
|
|
c d |
| 41 : |
anton
|
1.2
|
then |
| 42 : |
anton
|
1.1
|
[ ." locals-size after then:" locals-size @ . cr ] |
| 43 : |
|
|
f drop |
| 44 : |
anton
|
1.2
|
[ ." ending xxxx" .s cr ] |
| 45 : |
anton
|
1.1
|
; |
| 46 : |
|
|
|
| 47 : |
|
|
2 3 1 xxxx . . cr |
| 48 : |
|
|
2 3 0 xxxx . . cr |
| 49 : |
|
|
cr cr cr |
| 50 : |
|
|
|
| 51 : |
|
|
: xxx3 |
| 52 : |
anton
|
1.2
|
begin |
| 53 : |
anton
|
1.1
|
{ a } |
| 54 : |
anton
|
1.2
|
until |
| 55 : |
anton
|
1.1
|
a |
| 56 : |
|
|
; |
| 57 : |
|
|
." after xxx3" .s cr cr cr |
| 58 : |
|
|
|
| 59 : |
|
|
: xxx2 |
| 60 : |
|
|
[ ." start of xxx2" .s cr ] |
| 61 : |
anton
|
1.2
|
begin |
| 62 : |
anton
|
1.1
|
[ ." after begin" .s cr ] |
| 63 : |
|
|
{ a } |
| 64 : |
|
|
[ ." after { a }" .s cr ] |
| 65 : |
anton
|
1.2
|
1 while |
| 66 : |
anton
|
1.1
|
[ ." after while" .s cr ] |
| 67 : |
|
|
{ b } |
| 68 : |
|
|
a b |
| 69 : |
|
|
[ ." after a" .s cr ] |
| 70 : |
anton
|
1.2
|
repeat |
| 71 : |
anton
|
1.1
|
[ ." after repeat" .s cr |
| 72 : |
|
|
also locals words previous cr |
| 73 : |
|
|
] |
| 74 : |
|
|
a |
| 75 : |
|
|
[ ." end of xxx2" .s cr ] |
| 76 : |
|
|
; |
| 77 : |
|
|
|
| 78 : |
|
|
: xxx4 |
| 79 : |
|
|
[ ." before if" localsinfo ] |
| 80 : |
anton
|
1.2
|
if |
| 81 : |
anton
|
1.1
|
[ ." after if" localsinfo ] |
| 82 : |
|
|
{ a } |
| 83 : |
|
|
[ ." before begin" localsinfo ] |
| 84 : |
anton
|
1.2
|
begin |
| 85 : |
anton
|
1.1
|
[ ." after begin" localsinfo ] |
| 86 : |
|
|
[ 1 cs-roll ] |
| 87 : |
|
|
[ ." before then" localsinfo ] |
| 88 : |
anton
|
1.2
|
then |
| 89 : |
anton
|
1.1
|
{ b } |
| 90 : |
anton
|
1.2
|
until |
| 91 : |
anton
|
1.1
|
[ ." after until" localsinfo ] |
| 92 : |
|
|
; |
| 93 : |
|
|
|
| 94 : |
|
|
: xxx5 |
| 95 : |
|
|
{ a } |
| 96 : |
anton
|
1.2
|
ahead |
| 97 : |
|
|
begin |
| 98 : |
anton
|
1.1
|
[ ." after begin" localsinfo ] |
| 99 : |
|
|
[ 1 cs-roll ] |
| 100 : |
anton
|
1.2
|
then |
| 101 : |
anton
|
1.1
|
[ ." after then" localsinfo ] |
| 102 : |
anton
|
1.2
|
until |
| 103 : |
anton
|
1.1
|
[ ." after until" localsinfo ] |
| 104 : |
|
|
; |
| 105 : |
|
|
|
| 106 : |
anton
|
1.2
|
." xxx6 coming up" cr |
| 107 : |
anton
|
1.1
|
: xxx6 |
| 108 : |
anton
|
1.2
|
[ ." starting xxx6" localsinfo ] |
| 109 : |
|
|
if |
| 110 : |
anton
|
1.1
|
{ x } |
| 111 : |
anton
|
1.2
|
else |
| 112 : |
anton
|
1.1
|
[ ." after else" localsinfo ] |
| 113 : |
anton
|
1.2
|
ahead |
| 114 : |
|
|
begin |
| 115 : |
anton
|
1.1
|
[ ." after begin" localsinfo ] |
| 116 : |
anton
|
1.2
|
[ 2 CS-ROLL ] then |
| 117 : |
anton
|
1.1
|
[ ." after then" localsinfo ] |
| 118 : |
anton
|
1.2
|
until |
| 119 : |
|
|
then |
| 120 : |
|
|
[ ." ending xxx6" localsinfo ] |
| 121 : |
anton
|
1.1
|
; |
| 122 : |
|
|
|
| 123 : |
|
|
." xxx7 coming up" cr |
| 124 : |
|
|
: xxx7 |
| 125 : |
|
|
{ b } |
| 126 : |
anton
|
1.2
|
do |
| 127 : |
anton
|
1.1
|
{ a } |
| 128 : |
|
|
[ ." before loop" localsinfo ] |
| 129 : |
anton
|
1.2
|
loop |
| 130 : |
anton
|
1.1
|
[ ." after loop" localsinfo ] |
| 131 : |
|
|
; |
| 132 : |
|
|
|
| 133 : |
|
|
." xxx8 coming up" cr |
| 134 : |
|
|
|
| 135 : |
|
|
: xxx8 |
| 136 : |
|
|
{ b } |
| 137 : |
anton
|
1.2
|
?do |
| 138 : |
anton
|
1.1
|
{ a } |
| 139 : |
|
|
[ ." before loop" localsinfo ] |
| 140 : |
anton
|
1.2
|
loop |
| 141 : |
anton
|
1.1
|
[ ." after loop" localsinfo ] |
| 142 : |
|
|
; |
| 143 : |
|
|
|
| 144 : |
|
|
." xxx9 coming up" cr |
| 145 : |
|
|
: xxx9 |
| 146 : |
|
|
{ b } |
| 147 : |
anton
|
1.2
|
do |
| 148 : |
anton
|
1.1
|
{ c } |
| 149 : |
|
|
[ ." before ?leave" leave-sp ? leave-stack . cr ] |
| 150 : |
anton
|
1.2
|
?leave |
| 151 : |
anton
|
1.1
|
[ ." after ?leave" leave-sp ? cr ] |
| 152 : |
|
|
{ a } |
| 153 : |
|
|
[ ." before loop" localsinfo ] |
| 154 : |
anton
|
1.2
|
loop |
| 155 : |
anton
|
1.1
|
[ ." after loop" localsinfo ] |
| 156 : |
|
|
; |
| 157 : |
|
|
|
| 158 : |
|
|
." strcmp coming up" cr |
| 159 : |
|
|
: strcmp { addr1 u1 addr2 u2 -- n } |
| 160 : |
anton
|
1.2
|
addr1 addr2 u1 u2 min 0 ?do |
| 161 : |
anton
|
1.1
|
{ s1 s2 } |
| 162 : |
anton
|
1.2
|
s1 c@ s2 c@ - ?dup if |
| 163 : |
|
|
unloop exit |
| 164 : |
|
|
then |
| 165 : |
anton
|
1.1
|
s1 char+ s2 char+ |
| 166 : |
anton
|
1.2
|
loop |
| 167 : |
anton
|
1.1
|
2drop |
| 168 : |
|
|
u1 u2 - ; |
| 169 : |
|
|
|
| 170 : |
|
|
: teststrcmp |
| 171 : |
|
|
." lp@:" lp@ . cr |
| 172 : |
|
|
s" xxx" s" yyy" strcmp . cr |
| 173 : |
|
|
." lp@:" lp@ . cr |
| 174 : |
|
|
s" xxx" s" xxx" strcmp . cr |
| 175 : |
|
|
." lp@:" lp@ . cr |
| 176 : |
|
|
s" xxx" s" xxxx" strcmp . cr |
| 177 : |
|
|
." lp@:" lp@ . cr |
| 178 : |
|
|
s" xxx3" s" xxx2" strcmp . cr |
| 179 : |
|
|
." lp@:" lp@ . cr |
| 180 : |
|
|
s" " s" " strcmp . cr |
| 181 : |
|
|
." lp@:" lp@ . cr |
| 182 : |
|
|
." lp@:" lp@ . cr |
| 183 : |
|
|
." stack:" .s cr |
| 184 : |
|
|
; |
| 185 : |
|
|
|
| 186 : |
|
|
: findchar { c addr u -- i } |
| 187 : |
anton
|
1.2
|
addr u 0 ?do |
| 188 : |
anton
|
1.1
|
{ p } |
| 189 : |
anton
|
1.2
|
p c@ c = if |
| 190 : |
|
|
p leave |
| 191 : |
|
|
then |
| 192 : |
anton
|
1.1
|
p char+ |
| 193 : |
anton
|
1.2
|
loop |
| 194 : |
anton
|
1.1
|
addr - ; |
| 195 : |
|
|
|
| 196 : |
|
|
|
| 197 : |
|
|
: testfindchar |
| 198 : |
|
|
." findcahr " cr |
| 199 : |
|
|
." lp@:" lp@ . cr |
| 200 : |
|
|
[char] a s" xxx" findchar . cr |
| 201 : |
|
|
." lp@:" lp@ . cr |
| 202 : |
|
|
[char] a s" " findchar . cr |
| 203 : |
|
|
." lp@:" lp@ . cr |
| 204 : |
|
|
[char] a s" wam" findchar . cr |
| 205 : |
|
|
." lp@:" lp@ . cr |
| 206 : |
|
|
[char] a s" wma" findchar . cr |
| 207 : |
|
|
." lp@:" lp@ . cr |
| 208 : |
|
|
[char] a s" awam" findchar . cr |
| 209 : |
|
|
." lp@:" lp@ . cr |
| 210 : |
|
|
." stack:" .s cr |
| 211 : |
|
|
; |
| 212 : |
|
|
|
| 213 : |
|
|
|
| 214 : |
|
|
|
| 215 : |
|
|
." stack:" .s cr |
| 216 : |
|
|
teststrcmp |
| 217 : |
|
|
testfindchar |
| 218 : |
|
|
." hey you" cr |
| 219 : |
|
|
|
| 220 : |
|
|
: xxx10 |
| 221 : |
|
|
[ ." before if" localsinfo ] |
| 222 : |
anton
|
1.2
|
if |
| 223 : |
anton
|
1.1
|
[ ." after if" localsinfo ] |
| 224 : |
|
|
scope |
| 225 : |
|
|
[ ." after scope" localsinfo ] |
| 226 : |
|
|
{ a } |
| 227 : |
|
|
[ ." before endscope" localsinfo ] |
| 228 : |
|
|
endscope |
| 229 : |
|
|
[ ." before begin" localsinfo ] |
| 230 : |
anton
|
1.2
|
begin |
| 231 : |
anton
|
1.1
|
[ ." after begin" localsinfo ] |
| 232 : |
|
|
[ 1 cs-roll ] |
| 233 : |
|
|
[ ." before then" localsinfo ] |
| 234 : |
anton
|
1.2
|
then |
| 235 : |
anton
|
1.1
|
{ b } |
| 236 : |
anton
|
1.2
|
until |
| 237 : |
anton
|
1.1
|
[ ." after until" localsinfo ] |
| 238 : |
|
|
; |
| 239 : |
|
|
|
| 240 : |
anton
|
1.2
|
: xxx11 |
| 241 : |
|
|
if |
| 242 : |
|
|
{ a } |
| 243 : |
|
|
exit |
| 244 : |
|
|
[ ." after xexit" localsinfo ] |
| 245 : |
|
|
else |
| 246 : |
|
|
{ b } |
| 247 : |
|
|
[ ." before xthen" localsinfo |
| 248 : |
|
|
then |
| 249 : |
|
|
[ ." after xthen" localsinfo ] |
| 250 : |
|
|
; |
| 251 : |
|
|
|
| 252 : |
|
|
|
| 253 : |
|
|
bye |