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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
|
!% $SMALL ! This is ICL, not a comment.
!% -w
!% A comprehensive test of Inform6Lexer.
Switches d2SDq;
Constant Story "Informal Testing";
Constant Headline "^Not a game.^";!% This is a comment, not ICL.
Release 2;
Serial "140308";
Version 5;
Ifndef TARGET_ZCODE;
Ifndef TARGET_GLULX;
Ifndef WORDSIZE;
Default WORDSIZE 2;
Constant TARGET_ZCODE;
Endif;
Endif;
Endif;
Ifv3; Message "Compiling to version 3"; Endif;
Ifv5; Message "Not compiling to version 3"; endif;
ifdef TARGET_ZCODE;
#IFTRUE (#version_number == 5);
Message "Compiling to version 5";
#ENDIF;
endif ;
Replace CreatureTest;
Include "Parser";
Include "VerbLib";
# ! A hash is optional at the top level.
Object kitchen "Kitchen"
with description "You are in a kitchen.",
arr 1 2 3 4,
has light;
#[ Initialise;
location = kitchen;
print "v"; inversion; "^";
];
Ifdef VN_1633;
Replace IsSeeThrough IsSeeThroughOrig;
[ IsSeeThrough * o;
return o hasnt opaque || IsSeeThroughOrig(o);
];
Endif;
Abbreviate "test";
Array table buffer 260;
Attribute reversed;
Attribute opaque alias locked;
Constant to reversed;
Property long additive additive long alias;
Property long long long wingspan alias alias;
Class Flier with wingspan 5;
Class Bird(10) has animate class Flier with wingspan 2;
Constant Constant1;
Constant Constant2 Constant1;
Constant Constant3 = Constant2;
Ifdef VN_1633; Undef Constant; Endif;
Ifdef VN_1633;
Dictionary 'word' 1 2;
Ifnot;
Dictionary dict_word "word";
Endif;
Fake_action NotReal;
Global global1;
Global global2 = 69105;
Lowstring low_string "low string";
Iftrue false;
Message error "Uh-oh!^~false~ shouldn't be ~true~.";
Endif;
Iffalse true;
Message fatalerror "Uh-oh!^~true~ shouldn't be ~false~.";
Endif;
Nearby person "person"
with name 'person',
description "This person is barely implemented.",
life [ * x y z;
Ask: print_ret (The) self, " says nothing.";
Answer: print (The) self, " didn't say anything.^"; rfalse;
]
has has animate transparent;
Object -> -> test_tube "test tube"
with name 'test' "tube" 'testtube',
has ~openable ~opaque container;
Bird -> pigeon
with name 'pigeon',
description [;
"The pigeon has a wingspan of ", self.&wingspan-->0, " wing units.";
];
Object -> "thimble" with name 'thimble';
Object -> pebble "pebble" with name 'pebble';
Ifdef TARGET_ZCODE; Trace objects; Endif;
Statusline score;
Stub StubR 3;
Ifdef TARGET_ZCODE;
Zcharacter "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"123456789.,!?_#'0/@{005C}-:()";
Zcharacter table '@!!' '@<<' '@'A';
Zcharacter table + '@AE' '@{dc}' '@et' '@:y';
Ifnot;
Ifdef TARGET_GLULX;
Message "Glulx doesn't use ~Zcharacter~.^Oh well."; ! '~' and '^' work here.
Ifnot;
Message warning "Uh-oh! ^~^"; ! They don't work in other Messages.
Endif;
Endif;
Include "Grammar";
Verb"acquire"'collect'='take';
[ NounFilter; return noun ofclass Bird; ];
[ ScopeFilter obj;
switch (scope_stage) {
1: rtrue;
2: objectloop (obj in compass) PlaceInScope(obj);
3: "Nothing is in scope.";
}
];
Verb meta "t" 'test'
* 'held' held -> TestHeld
* number -> TestNumber
* reversed -> TestAttribute
* 'creature' creature -> TestCreature
* 'multiheld' multiheld -> TestMultiheld
* 'm' multiexcept 'into'/"in" noun -> TestMultiexcept
* 'm' multiinside 'from' noun -> TestMultiinside
* multi -> TestMulti
* 'filter'/'f' noun=NounFilter -> TestNounFilter
* 'filter'/'f' scope=ScopeFilter -> TestScopeFilter
* 'special' special -> TestSpecial
* topic -> TestTopic;
Verb 'reverse' 'swap' 'exchange'
* held 'for' noun -> reverse
* noun 'with' noun -> reverse reverse;
Extend "t" last * noun -> TestNoun;
Extend 't' first * -> Test;
Extend 'wave' replace * -> NewWave;
Extend only 'feel' 'touch' replace * noun -> Feel;
[ TestSub a b o;
string 25 low_string;
print "Test what?> ";
table->0 = 260;
parse->0 = 61;
#Ifdef TARGET_ZCODE;
read buffer parse;
#Ifnot; ! TARGET_GLULX
KeyboardPrimitive(buffer, parse);
#Endif; ! TARGET_
switch (parse-->1) {
'save':
#Ifdef TARGET_ZCODE;
#Ifv3;
@save ?saved;
#Ifnot;
save saved;
#Endif;
#Endif;
print "Saving failed.^";
'restore':
#Ifdef TARGET_ZCODE;
restore saved;
#Endif;
print "Restoring failed.^";
'restart':
@restart;
'quit', 'q//':
quit;
return 2; rtrue; rfalse; return;
'print', 'p//':
print "Print:^",
" (string): ", (string) "xyzzy^",
" (number): ", (number) 123, "^",
" (char): ", (char) 'x', "^",
" (address): ", (address) 'plugh//p', "^",
" (The): ", (The) person, "^",
" (the): ", (the) person, "^",
" (A): ", (A) person, "^",
" (a): ", (a) person, "^",
" (an): ", (an) person, "^",
" (name): ", (name) person, "^",
" (object): ", (object) person, "^",
" (property): ", (property) alias, "^",
" (<routine>): ", (LanguageNumber) 123, "^",
" <expression>: ", a * 2 - 1, "^",
" (<expression>): ", (a + person), "^";
print "Escapes:^",
" by mnemonic: @!! @<< @'A @AE @et @:y^",
" by decimal value: @@64 @@126^",
" by Unicode value: @{DC}@{002b}^",
" by string variable: @25^";
'font', 'style':
font off; print "font off^";
font on; print "font on^";
style reverse; print "style reverse^"; style roman;
style bold; print "style bold^";
style underline; print "style underline^";
style fixed; print "style fixed^";
style roman; print "style roman^";
'statements':
spaces 8;
objectloop (o) {
print "objectloop (o): ", (the) o, "^";
}
objectloop (o in compass) { ! 'in' is a keyword
print "objectloop (o in compass): ", (the) o, "^";
}
objectloop (o in compass && true) { ! 'in' is an operator
print "objectloop (o in compass && true): ", (the) o, "^";
}
objectloop (o from se_obj) {
print "objectloop (o from se_obj): ", (the) o, "^";
}
objectloop (o near person) {
print "objectloop (o near person): ", (the) o, "^";
}
#Ifdef TARGET_ZCODE;
#Trace assembly on;
@ ! This is assembly.
add -4 ($$1+$3)*2 -> b;
@get_sibling test_tube -> b ?saved;
@inc [b];
@je sp (1+3*0) ? equal;
@je 1 ((sp)) ?~ different;
.! This is a label:
equal;
print "sp == 1^";
jump label;
.different;
print "sp @@126= 1^";
.label;
#Trace off; #Endif; ! TARGET_ZCODE
a = random(10);
switch (a) {
1, 9:
box "Testing oneself is best when done alone."
" -- Jimmy Carter";
2, 6, to, 3 to 5, to to to:
<Take pigeon>;
#Ifdef VN_1633;
<Jump, person>;
#Endif;
a = ##Drop;
< ! The angle brackets may be separated by whitespace.
< (a) pigeon > >;
default:
do {
give person general ~general;
} until (person provides life && ~~false);
if (a == 7) a = 4;
else a = 5;
}
'expressions':
a = 1+1-1*1/1%1&1|1&&1||1==(1~=(1>(1<(1>=(1<=1)))));
a++; ++a; a--; --a;
a = person.life;
a = kitchen.&arr;
a = kitchen.#arr;
a = Bird::wingspan;
a = kitchen has general;
a = kitchen hasnt general;
a = kitchen provides arr;
a = person in kitchen;
a = person notin kitchen;
a = person ofclass Bird;
a = a == 0 or 1;
a = StubR();
a = StubR(a);
a = StubR(, a);
a = "string";
a = 'word';
a = '''; ! character
a = $09afAF;
a = $$01;
a = ##Eat; a = #a$Eat;
a = #g$self;
a = #n$!word;
a = #r$StubR;
a = #dict_par1;
default:
for (a = 2, b = a; (a < buffer->1 + 2) && (Bird::wingspan): ++a, b--) {
print (char) buffer->a;
}
new_line;
for (::) break;
}
.saved;;
];
[ TestNumberSub;
print_ret parsed_number, " is ", (number) parsed_number, ".";
];
[ TestAttributeSub; print_ret (The) noun, " has been reversed."; ];
[ CreatureTest obj; return obj has animate; ];
[ TestCreatureSub; print_ret (The) noun, " is a creature."; ];
[ TestMultiheldSub; print_ret "You are holding ", (the) noun, "."; ];
[ TestMultiexceptSub; "You test ", (the) noun, " with ", (the) second, "."; ];
[ TestMultiinsideSub; "You test ", (the) noun, " from ", (the) second, "."; ];
[ TestMultiSub; print_ret (The) noun, " is a thing."; ];
[ TestNounFilterSub; print_ret (The) noun, " is a bird."; ];
[ TestScopeFilterSub; print_ret (The) noun, " is a direction."; ];
[ TestSpecialSub; "Your lucky number is ", parsed_number, "."; ];
[ TestTopicSub; "You discuss a topic."; ];
[ TestNounSub; "That is ", (a) noun, "."; ];
[ TestHeldSub; "You are holding ", (a) noun, "."; ];
[ NewWaveSub; "That would be foolish."; ];
[ FeelSub; print_ret (The) noun, " feels normal."; ];
[ ReverseSub from;
from = parent(noun);
move noun to parent(second);
if (from == to)
move second to to;
else
move second to from;
give noun to;
from = to;
give second from;
"You swap ", (the) noun, " and ", (the) second, ".";
];
End: The End directive ends the source code.
|