Hash :
ed679850
Author :
Date :
2006-10-30T17:01:46
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
\ An even more severe test of Erroneous Control Constructs.
\ Updated Fri, 28 Jul 2006 at 14:28 PDT by David L. Paktor
fcode-version2
headers
\ Seven dwarves:
\ Happy Grumpy Sleepy Sneezy Dopey Bashful and Doc
\ Their disfavored cousins:
\ Crappy Dumpy Sneaky Sleazy Gropey Trashful and Schlock
: crapsky
." 0 case" 0 case
." 1 of"
1 of ." 1 endof" 1 endof
." 2 of"
2 of ." 2 endof" 2 endof
." 3 of"
3 of ." 3 endof" 3 endof
." default 0" 0
." resolve case w/ then" then
." resolve 3 endof w/ then" then
." resolve 2 endof w/ then" then
." resolve 1 endof w/ then" then
." Donesky vith crapsky."
;
: dumpsky
." 0 if" 0 if
." free-floating endcase"
endcase ." And no then"
;
: sneaksky
." Free-floating else" else
." And notsnik aftervards."
;
." While by itself, outside of def'n"
while
: gropsky
." A typo. 0 of not 0 if"
0 of
." Misbalanced by a then?"
then
." Goobar... Guwno?"
;
: trashsky
." Another typo..."
." 0 case " 0 case
." 10 if not 10 of"
10 if
." Misbalanced by endof."
endof
." Not my default."
endcase
." That was an endcase just in case"
;
: schlocksky
." Like trashsky but without final balancer..."
." Another typo..."
." 0 case " 0 case
." 10 if not 10 of"
10 if
." Misbalanced by endof."
endof
." No endcase here"
;
." We need to be able to detect Leave out of context."
." Let's see if this can fool it..."
." 1 0 DO" 1 0 do
: stinsky
." if leave then "
if
leave
then
;
." 1 begin" 1 begin
." 1 - ?dup while" 1 - ?dup while
." What the hey? Loop ?" loop
." 1 begin" 1 begin
." 1 - ?dup while" 1 - ?dup while
." again then ought to match..."
again
then
." How about IF BEGIN without WHILE then REPEAT..."
." 0 if" 0 if
begin
." There's an IF ; where's the WHILE?" #message" There's an IF ; where's the WHILE?"
repeat
." That compiles..." #message" Won't be easy to catch."
." How about BEGIN without WHILE then REPEAT..."
." begin" begin #message" BEGIN without WHILE then REPEAT..."
." Where's the while?" #message" Where's the while?"
repeat
." repeat without precedent..." repeat
." loop without precedent" loop
." 1 0 DO" 1 0 do
." What???"
." repeat..." repeat
#message" Definitions within a loop" ." ...within a loop"
: test_something ( indx -- targ true | false )
." Stub" 2 = dup if h# 1923 swap then
;
4 0 do
i test_something if
( targ ) value targ ( klingon-pet )
: funny_stuff
1 0 do targ u.
#message" Error here..." j
#message" But not here" 1 0 do j . loop
loop test_something
;
then
loop
#message"
Same line as a loop" ." ...Same line as a loop"
4 0 do i test_something if to targ : runny_stuff begin
1 0 do targ u. #message" Error here, too..." j
#message" But not here either" 1 0 do j . loop
loop true #message" Missing an until"
;
then loop
fcode-end