1
! ==============================================================================
2
! INFIX: Support for the optional library debugger extension "Infix".
4
! Supplied for use with Inform 6 -- Release 6/11 -- Serial number 040227
6
! Copyright Graham Nelson 1993-2004 but freely usable (see manuals)
8
! This file is automatically Included in your game file by "Grammar" if you
9
! supply the -X compiler switch.
10
! ==============================================================================
14
! ------------------------------------------------------------------------------
18
Constant INFIXTT_NUMBER 0;
19
Constant INFIXTT_ARRAY 1;
20
Constant INFIXTT_ROUTINE 2;
21
Constant INFIXTT_CONSTANT 3;
22
Constant INFIXTT_DWORD 4;
23
Constant INFIXTT_ACTION 5;
24
Constant INFIXTT_ATTRIBUTE 6;
25
Constant INFIXTT_PROPERTY 7;
26
Constant INFIXTT_GLOBAL 8;
27
Constant INFIXTT_NAMEDOBJECT 9;
28
Constant INFIXTT_SYSFUN 10;
29
Constant INFIXTT_STATICSTRING 11;
30
Constant INFIXTT_LOGICAL 12;
32
Global infix_term_type;
36
Global infix_parsed_lvalue;
37
Array infix_tolowercase -> 256;
39
Array infix_text buffer 126;
41
Array infix_text -> 128;
45
[ InfixPrintAttribute x; print (string) #attribute_names_array-->x; ];
47
[ InfixPrintProperty x; print (property) x; ];
49
[ InfixPrintGlobal x; print (string) #global_names_array-->x; ];
51
[ InfixPrintAction x; print (string) #action_names_array-->(x-#lowest_action_number); ];
53
[ InfixPrintRoutine x; print (string) #routine_names_array-->(x-#lowest_routine_number); ];
55
[ InfixPrintConstant x; print (string) #constant_names_array-->(x-#lowest_constant_number); ];
57
[ InfixPrintArray x; print (string) #array_names_array-->(x-#lowest_array_number); ];
59
[ InfixPrintFakeAction x;
60
print (string) #fake_action_names_array-->(x-#lowest_fake_action_number); ];
63
for (n=#lowest_routine_number : n<=#highest_routine_number : n++) {
64
if (x == Symb__Tab(INFIXTT_ROUTINE, n)) {
65
print (InfixPrintRoutine) n; return;
68
print "Routine(", x, ")";
71
[ InfixMatchPrule PrintingRule range1 range2 wa wl t i i2 it2 itlc j k plus;
72
itlc = infix_tolowercase;
74
for (j=0 : j<256 : j++) itlc->j = j;
75
itlc->'A' = 'a'; itlc->'B' = 'b';
76
itlc->'C' = 'c'; itlc->'D' = 'd';
77
itlc->'E' = 'e'; itlc->'F' = 'f';
78
itlc->'G' = 'g'; itlc->'H' = 'h';
79
itlc->'I' = 'i'; itlc->'J' = 'j';
80
itlc->'K' = 'k'; itlc->'L' = 'l';
81
itlc->'M' = 'm'; itlc->'N' = 'n';
82
itlc->'O' = 'o'; itlc->'P' = 'p';
83
itlc->'Q' = 'q'; itlc->'R' = 'r';
84
itlc->'S' = 's'; itlc->'T' = 't';
85
itlc->'U' = 'u'; itlc->'V' = 'v';
86
itlc->'W' = 'w'; itlc->'X' = 'x';
87
itlc->'Y' = 'y'; itlc->'Z' = 'z';
89
switch(PrintingRule) {
91
if (wa->0 == '~') { wl--; wa++; plus = 100; } ! A tilde
92
t = #attribute_names_array;
93
InfixPrintProperty: t = #property_names_array;
94
InfixPrintAction: t = #action_names_array;
95
InfixPrintFakeAction: t = #fake_action_names_array;
96
InfixPrintGlobal: t = #global_names_array;
97
InfixPrintRoutine: t = #routine_names_array;
98
InfixPrintAction: t = #constant_names_array;
99
InfixPrintArray: t = #array_names_array;
102
i2 = range2-range1; it2 = infix_text+2;
103
for (i=0 : i<=i2 : i++) {
104
infix_text-->0 = 62; @output_stream 3 infix_text;
105
if (t) print (string) t-->i; else PrintingRule(i+range1);
108
if (k ~= wl) jump XL;
109
if (itlc->(it2->0) ~= wa->0) jump XL;
110
for (j=1 : j<k : j++)
111
if (itlc->(it2->j) ~= wa->j) jump XL;
112
parsed_number = i + range1 + plus;
120
if (InfixMatchPrule(InfixPrintAction, #lowest_action_number,
121
#highest_action_number, WordAddress(wn), WordLength(wn))) {
122
wn++; infix_lvalue = parsed_number; return 0;
124
if (InfixMatchPrule(InfixPrintFakeAction, #lowest_fake_action_number,
125
#highest_fake_action_number, WordAddress(wn), WordLength(wn))) {
126
wn++; infix_lvalue = parsed_number; return 0;
131
[ InfixRvalueTerm n w i initial_wn wa wl sign base digit dcount;
135
infix_parsed_lvalue = -1;
136
infix_term_type = INFIXTT_NUMBER;
138
w = NextWordStopped();
139
if (w == -1) return -1;
141
wa = WordAddress(wn-1);
142
wl = WordLength(wn-1);
143
if (wa->0 == '-' or '$' or '0' or '1' or '2' or '3'
144
or '4' or '5' or '6' or '7' or '8' or '9') {
145
! Parse decimal, hex or binary number
147
sign = 1; base = 10; dcount = 0;
148
if (wa->0 == '-') { sign = -1; wl--; wa++; }
150
if (wa->0 == '$') { base = 16; wl--; wa++; }
151
if (wa->0 == '$') { base = 2; wl--; wa++; }
153
if (wl == 0) return -1;
156
if (wa->0 >= 'a') digit = wa->0 - 'a' + 10;
157
else digit = wa->0 - '0';
161
if (dcount == 17) return -1;
163
if (dcount == 6) return -1;
165
if (n > 3276) return -1;
167
if (sign == 1 && digit > 7) return -1;
168
if (sign == -1 && digit > 8) return -1;
172
if (dcount == 5) return -1;
174
if (digit >= 0 && digit < base) n = base*n + digit;
178
parsed_number = n*sign; return 1;
181
! Parse character constant 'a'
183
if (wl == 3 && wa->0 == ''' && wa->2 == ''') {
184
parsed_number = wa->1; return 1;
191
infix_term_type = INFIXTT_ACTION;
192
w = NextWordStopped(); if (w == -1) return -1;
194
if (InfixActionToken() == 0) return 1;
197
infix_term_type = INFIXTT_DWORD;
198
w = NextWordStopped(); if (w == -1) return -1;
199
parsed_number = w; return 1;
202
! Test for attribute, property, class name, variable name, array name, routine
203
! name, constant name
206
if ((wa->0 >= 'a' && wa->0 <= 'z') ||
207
(wa->0 >= 'A' && wa->0 <= 'Z') ||
211
infix_term_type = INFIXTT_ATTRIBUTE;
212
if (InfixMatchPrule(InfixPrintAttribute, #lowest_attribute_number,
213
#highest_attribute_number, wa, wl)) {
216
infix_term_type = INFIXTT_PROPERTY;
217
if (InfixMatchPrule(InfixPrintProperty, #lowest_property_number,
218
#highest_property_number, wa, wl)) {
221
infix_term_type = INFIXTT_GLOBAL;
222
if (InfixMatchPrule(InfixPrintGlobal, #lowest_global_number,
223
#highest_global_number, wa, wl)) {
224
infix_parsed_lvalue = parsed_number-16;
225
parsed_number = #globals_array-->infix_parsed_lvalue;
229
infix_term_type = INFIXTT_ARRAY;
230
if (InfixMatchPrule(InfixPrintArray, #lowest_array_number,
231
#highest_array_number, wa, wl)) {
232
infix_parsed_lvalue = parsed_number;
233
parsed_number = Symb__Tab(INFIXTT_ARRAY,parsed_number);
234
infix_data1 = temp__global3;
235
infix_data2 = temp__global2;
239
infix_term_type = INFIXTT_ROUTINE;
240
if (InfixMatchPrule(InfixPrintRoutine, #lowest_routine_number,
241
#highest_routine_number, wa, wl)) {
242
infix_parsed_lvalue = parsed_number;
243
parsed_number = Symb__Tab(INFIXTT_ROUTINE,parsed_number);
244
infix_data1 = temp__global3;
245
infix_data2 = temp__global2;
249
infix_term_type = INFIXTT_CONSTANT;
250
if (InfixMatchPrule(InfixPrintConstant, #lowest_constant_number,
251
#highest_constant_number, wa, wl)) {
252
infix_parsed_lvalue = parsed_number;
253
parsed_number = Symb__Tab(INFIXTT_CONSTANT,parsed_number);
254
infix_data1 = temp__global3;
255
infix_data2 = temp__global2;
260
'parent', 'child', 'children',
261
'random', 'metaclass', 'sibling':
263
infix_parsed_lvalue = INFIXTT_SYSFUN;
268
infix_term_type = INFIXTT_NAMEDOBJECT;
270
wn = initial_wn; i = ParseToken(SCOPE_TT, InfixBigScope);
272
if (i == GPR_REPARSE) return i;
273
if (i > GPR_MULTIPLE) {
274
print "(", (name) i, " (", i, "))^";
275
parsed_number = i; return 1;
278
]; ! end of InfixRvalueTerm
281
if (scope_stage == 1) return false; ! No multiples here
282
if (scope_stage == 2) {
283
objectloop (x ofclass Object) PlaceInScope(x);
284
return true; ! That's the whole scope
286
print "; I'm unable to make any sense of that term.^";
289
[ InfixCheckLineSpaced wa wl i force altered;
290
for (i=1 : i<=parse->1 : i++) {
293
if (wl > 3 && wa->0 == ''' && wa->(wl-1) == ''') {
295
if (wa->(wl-2) == '/' && wa->(wl-3) == '/') {
299
LTI_Insert(wa-buffer, ''');
300
LTI_Insert(wa-buffer + 2, ' ');
301
altered = true; break;
304
for (i=2 : i<buffer->1 + 2 : i++) {
306
if (buffer->i == '-' && buffer->(i+1) == '-' && buffer->(i+2) == '>')
309
if (i>2 && buffer->(i-1) ~= ' ') {
310
LTI_Insert(i++, ' '); altered = true;
312
if (buffer->(i+3) ~= ' ') {
313
LTI_Insert(i+3, ' '); i++; altered = true;
318
if (buffer->i == ':' && buffer->(i+1) == ':') force = true;
319
if (buffer->i == '-' && buffer->(i+1) == '>') force = true;
320
if (buffer->i == '.' && buffer->(i+1) == '&') {
321
buffer->i = ']'; force = true;
323
if (buffer->i == '.' && buffer->(i+1) == '#') {
324
buffer->i = ']'; force = true;
326
if (buffer->i == ']' && buffer->(i+1) == '&') force = true;
327
if (buffer->i == ']' && buffer->(i+1) == '#') force = true;
328
if (buffer->i == '+' && buffer->(i+1) == '+') force = true;
329
if (buffer->i == '-' && buffer->(i+1) == '-') force = true;
330
if (buffer->i == '&' && buffer->(i+1) == '&') force = true;
331
if (buffer->i == '|' && buffer->(i+1) == '|') force = true;
332
if (buffer->i == '~' && buffer->(i+1) == '~') force = true;
334
if (buffer->i == '=' && buffer->(i+1) == '=') force = true;
335
if (buffer->i == '~' && buffer->(i+1) == '=') force = true;
336
if (buffer->i == '>' && buffer->(i+1) == '=') force = true;
337
if (buffer->i == '<' && buffer->(i+1) == '=') force = true;
338
if (buffer->i == '#' && buffer->(i+1) == '#') force = true;
341
if (i > 2 && buffer->(i-1) ~= ' ') {
342
LTI_Insert(i++, ' '); altered = true;
344
if (buffer->(i+2) ~= ' ') {
345
LTI_Insert(i+2, ' '); i++; altered = true;
350
if (buffer->i == '+') force = true;
351
if (buffer->i == '-') force = true;
352
if (buffer->i == '*') force = true;
353
if (buffer->i == '/') force = true;
354
if (buffer->i == '%') force = true;
355
if (buffer->i == '(') force = true;
356
if (buffer->i == ')') force = true;
357
if (buffer->i == '<' && buffer->(i-1) ~= ';') force = true;
358
if (buffer->i == '>') force = true;
359
if (buffer->i == ',') force = true;
360
if (buffer->i == '.') force = true;
361
if (buffer->i == '&') force = true;
362
if (buffer->i == '|') force = true;
363
if (buffer->i == '~') force = true;
364
if (buffer->i == '=') force = true;
366
if (i > 2 && buffer->(i-1) ~= ' ') {
367
LTI_Insert(i++, ' '); altered = true;
369
if (buffer->(i+1) ~= ' ') {
370
LTI_Insert(i+1, ' '); i++; altered = true;
374
for (i=2 : i<buffer->1 + 2 : i++)
375
if (buffer->i == '~') { buffer->i = '['; altered = true; }
377
]; ! end of InfixCheckLineSpaced
379
Array InfixRV_rvals --> 32;
380
Array InfixRV_lvals --> 32;
381
Array InfixRV_op --> 32;
382
Array InfixRV_lop --> 32;
383
Array InfixRV_rop --> 32;
384
Array InfixRV_types --> 32;
385
Array InfixRV_commas --> 32;
387
[ InfixInBounds addr index n;
388
if (addr < #array__start || addr > #array__end)
390
for (n=#lowest_array_number : n<=#highest_array_number : n++) {
391
if (addr == Symb__Tab(INFIXTT_ARRAY, n)) {
392
if (temp__global3 == 1 or 3)
393
temp__global2=temp__global2*WORDSIZE+WORDSIZE-1;
394
if (index > temp__global2) {
395
print "Array index out of range";
403
[ InfixRvalue acc w i n flag base expecting_term max maxi lop rop lvalside
406
if (InfixCheckLineSpaced()) return GPR_REPARSE;
408
! w = wn; for (i=0 : i<10 : i++) { wn = w; InfixRvalueTerm(); print i, "^"; }
411
expecting_term = true; base = 0;
413
w = NextWordStopped();
414
if (expecting_term) {
417
InfixRV_rvals-->n = 'unary-'; InfixRV_types-->n = base + 8;
419
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
421
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
423
InfixRV_rvals-->n = 'pre++'; InfixRV_types-->n = base + 9;
425
InfixRV_rvals-->n = 'pre--'; InfixRV_types-->n = base + 9;
427
InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base+100;
429
InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base-100;
430
if (base < 0) { wn--; flag = true; }
435
if (InfixRValueTerm() == 1) {
436
InfixRV_rvals-->n = parsed_number;
437
InfixRV_lvals-->n = infix_parsed_lvalue;
438
InfixRV_types-->n = -1;
439
expecting_term = false;
445
expecting_term = true;
448
InfixRV_rvals-->n = w; InfixRV_types-->n = base;
450
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 1;
452
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
453
'==', '[=', '>//', '>=', '<//', '<=', 'has', 'hasnt',
454
'in', 'notin', 'ofclass', 'provides':
455
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 3;
457
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 4;
459
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 5;
460
'*//', '@{2f}//', '%//', '&//', '|//':
461
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
463
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 7;
465
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 10;
467
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 12;
469
InfixRV_rvals-->n = w; InfixRV_types-->n = base + 13;
471
InfixRV_rvals-->n = '(rcall';
472
InfixRV_types-->n = base + 11; base = base + 100;
474
InfixRV_rvals-->n = w; InfixRV_types-->n = -3;
476
if (base < 0) { wn--; flag = true; }
477
expecting_term = false;
479
InfixRV_rvals-->n = 'post++'; InfixRV_types-->n = base + 9;
480
expecting_term = false;
482
InfixRV_rvals-->n = 'post--'; InfixRV_types-->n = base + 9;
483
expecting_term = false;
489
} until (flag || n == 32);
490
if (base > 0) return -1;
491
n--; if (n == 0) return -1;
494
for (i=0 : i<n : i++) {
495
acc = 0; if (InfixRV_types-->i ~= -3) acc = InfixRV_rvals-->i;
496
InfixRV_op-->i = acc;
501
! for (i=0 : i<n : i++) {
502
! if (InfixRV_types-->i == -1) print InfixRV_rvals-->i, " ";
503
! else if (InfixRV_types-->i == -3) print " # ";
504
! else if (InfixRV_types-->i == -2) print " ## ";
505
! else print (address) InfixRV_rvals-->i, "_", InfixRV_types-->i, " ";
510
for (i=0 : i<n : i++) if (InfixRV_types-->i > max) {
511
max = InfixRV_types-->i; maxi = i; }
512
if (max == -1) { parsed_number = InfixRV_rvals-->maxi; return 1; }
514
lop = maxi-1; rop = maxi+1;
515
while (lop >= 0 && InfixRV_types-->lop < -1) lop--;
516
while (rop < n && InfixRV_types-->rop < -1) rop++;
517
if (lop >= 0) InfixRV_lop-->maxi = InfixRV_rvals-->lop;
518
if (rop < n) InfixRV_rop-->maxi = InfixRV_rvals-->rop;
520
infix_term_type = INFIXTT_NUMBER;
521
switch (InfixRV_rvals-->maxi) {
523
acc = (InfixRV_rvals-->rop);
524
'=//', 'pre++', 'post++', 'pre--', 'post--':
526
switch (InfixRV_rvals-->maxi) {
527
'=//': acc = (InfixRV_rvals-->rop);
528
'pre++': acc = (InfixRV_rvals-->rop) + 1; lvalside = rop;
529
'pre--': acc = (InfixRV_rvals-->rop) - 1; lvalside = rop;
530
'post++': acc = (InfixRV_rvals-->lop) + 1;
531
'post--': acc = (InfixRV_rvals-->lop) - 1;
533
switch (InfixRV_op-->lvalside) {
535
(InfixRV_lop-->lvalside).(InfixRV_rop-->lvalside) = acc;
537
if (InfixInBounds(InfixRV_lop-->lvalside, InfixRV_rop-->lvalside))
538
(InfixRV_lop-->lvalside)->(InfixRV_rop-->lvalside) = acc;
540
if (InfixInBounds(InfixRV_lop-->lvalside, WORDSIZE * InfixRV_rop-->lvalside))
541
(InfixRV_lop-->lvalside)-->(InfixRV_rop-->lvalside) = acc;
543
w = InfixRV_lvals-->lvalside; if (w == -1) return -1;
544
@storew #globals_array w acc;
546
switch(InfixRV_rvals-->maxi) {
552
switch (InfixRV_op-->lop) {
554
a = InfixRV_lop-->lop; b = InfixRV_rop-->lop;
556
a = InfixRV_rvals-->lop; b = call;
557
if (InfixRV_lvals-->lop == INFIXTT_SYSFUN)
561
i = maxi + 1; base = 100;
562
if (InfixRV_types-->i == -1 && InfixRV_rvals-->i == ')//') {
563
if (sysfun_f) return -1;
568
if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == ')//') base = base - 100;
569
if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == '(//') base = base + 100;
570
if (InfixRV_op-->i == '(rcall') base = base + 100;
571
if (base == 100 && InfixRV_op-->i == comma_word) {
572
InfixRV_commas-->(w++) = i;
573
! print "Comma found at ", i, "^";
577
! print "Num args = ", w + 1, "^";
578
! for (i=0 : i<w : i++)
579
! print "arg: ", InfixRV_lop-->(InfixRV_commas-->i), "^";
580
! print "arg: ", InfixRV_rvals-->rop, "^";
584
b = InfixRV_rvals-->rop;
585
infix_term_type = INFIXTT_NAMEDOBJECT;
595
infix_term_type = INFIXTT_NUMBER;
598
infix_term_type = INFIXTT_NUMBER;
604
acc = a.b(InfixRV_rvals-->rop);
606
if (sysfun_f) return -1;
607
acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
608
InfixRV_rvals-->rop);
610
if (sysfun_f) return -1;
611
acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
612
InfixRV_lop-->(InfixRV_commas-->1),
613
InfixRV_rvals-->rop);
615
if (sysfun_f) return -1;
616
acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
617
InfixRV_lop-->(InfixRV_commas-->1),
618
InfixRV_lop-->(InfixRV_commas-->2),
619
InfixRV_rvals-->rop);
621
if (sysfun_f) return -1;
622
acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
623
InfixRV_lop-->(InfixRV_commas-->1),
624
InfixRV_lop-->(InfixRV_commas-->2),
625
InfixRV_lop-->(InfixRV_commas-->3),
626
InfixRV_rvals-->rop);
631
'+//': acc = (InfixRV_rvals-->lop) + (InfixRV_rvals-->rop);
632
'-//': acc = (InfixRV_rvals-->lop) - (InfixRV_rvals-->rop);
633
'*//': acc = (InfixRV_rvals-->lop) * (InfixRV_rvals-->rop);
634
'@{2f}//': acc = (InfixRV_rvals-->lop) / (InfixRV_rvals-->rop);
635
'%//': acc = (InfixRV_rvals-->lop) % (InfixRV_rvals-->rop);
636
THEN1__WD: acc = (InfixRV_rvals-->lop) . (InfixRV_rvals-->rop);
637
'->': acc = (InfixRV_rvals-->lop) -> (InfixRV_rvals-->rop);
638
'-->': acc = (InfixRV_rvals-->lop) --> (InfixRV_rvals-->rop);
639
']&': acc = (InfixRV_rvals-->lop) .& (InfixRV_rvals-->rop);
640
']#': acc = (InfixRV_rvals-->lop) .# (InfixRV_rvals-->rop);
641
'::': acc = (InfixRV_rvals-->lop) :: (InfixRV_rvals-->rop);
642
'&//': acc = (InfixRV_rvals-->lop) & (InfixRV_rvals-->rop);
643
'|//': acc = (InfixRV_rvals-->lop) | (InfixRV_rvals-->rop);
644
'&&': acc = (InfixRV_rvals-->lop) && (InfixRV_rvals-->rop);
645
infix_term_type = INFIXTT_LOGICAL;
646
'||': acc = (InfixRV_rvals-->lop) || (InfixRV_rvals-->rop);
647
infix_term_type = INFIXTT_LOGICAL;
648
'<//': acc = (InfixRV_rvals-->lop) < (InfixRV_rvals-->rop);
649
infix_term_type = INFIXTT_LOGICAL;
650
'<=': acc = (InfixRV_rvals-->lop) <= (InfixRV_rvals-->rop);
651
infix_term_type = INFIXTT_LOGICAL;
652
'>//': acc = (InfixRV_rvals-->lop) > (InfixRV_rvals-->rop);
653
infix_term_type = INFIXTT_LOGICAL;
654
'>=': acc = (InfixRV_rvals-->lop) >= (InfixRV_rvals-->rop);
655
infix_term_type = INFIXTT_LOGICAL;
656
'==': acc = (InfixRV_rvals-->lop) == (InfixRV_rvals-->rop);
657
infix_term_type = INFIXTT_LOGICAL;
658
'[=': acc = (InfixRV_rvals-->lop) ~= (InfixRV_rvals-->rop);
659
infix_term_type = INFIXTT_LOGICAL;
660
'has': acc = (InfixRV_rvals-->lop) has (InfixRV_rvals-->rop);
661
infix_term_type = INFIXTT_LOGICAL;
662
'hasnt': acc = (InfixRV_rvals-->lop) hasnt (InfixRV_rvals-->rop);
663
infix_term_type = INFIXTT_LOGICAL;
664
'in': acc = (InfixRV_rvals-->lop) in (InfixRV_rvals-->rop);
665
infix_term_type = INFIXTT_LOGICAL;
666
'notin': acc = (InfixRV_rvals-->lop) notin (InfixRV_rvals-->rop);
667
infix_term_type = INFIXTT_LOGICAL;
668
'provides': acc = (InfixRV_rvals-->lop) provides (InfixRV_rvals-->rop);
669
infix_term_type = INFIXTT_LOGICAL;
670
'ofclass': acc = (InfixRV_rvals-->lop) ofclass (InfixRV_rvals-->rop);
671
infix_term_type = INFIXTT_LOGICAL;
672
'[[': acc = ~~ (InfixRV_rvals-->rop); flag = true;
673
'[//': acc = ~ (InfixRV_rvals-->rop); flag = true;
674
'unary-': acc = - (InfixRV_rvals-->rop); flag = true;
675
} ! end of switch(InfixRV_rvals-->maxi)
676
InfixRV_rvals-->maxi = acc;
677
InfixRV_types-->maxi = -1;
678
if (rop < n) InfixRV_types-->rop = -2;
679
if (flag == false && lop >= 0) InfixRV_types-->lop = -2;
681
]; ! end of InfixRvalue
683
! ------------------------------------------------------------------------
686
print "; Welcome to the ~Infix~ debugger (1/990428), which makes the
687
following verbs available:^^
688
~; <expression>~: evaluates this Inform expression: e.g.
689
~; location~ will print the value of the variable ~location~,
690
~; 3*5+1~ will print 16, ~; children(old cloth bag)~ will tell you
691
how many items are in it. (You can name objects either by their
692
names inside the source code, such as ~n_obj~, or by typing the
693
names by which the game's parser would normally know them, such
694
as ~north wall~: the effect is the same.)^
695
Any expression is allowed except that you can't use double-quoted
696
strings of text: but you can send messages, call routines or
697
assign values to variables, properties and array entries.
698
^ ~; score++~ is one way to get on in the world.
699
^ ~; deadflag = true~ is one way to get out of it.
700
^ ~; StopDaemon(nasty little dwarf)~ will keep you from being pestered.^
701
Conditions like ~; score>20~ are also allowed and print
702
either 1 (if true) or 0 (if false).^^";
703
print "~;examine <something>~ or ~;x <something>~ gives full details
704
of whatever it is. For instance, ~;x ##Take~ describes the Take
705
action; ~;x Class~ the class Class; ~;x 'drop'~ the dictionary
706
word ~drop~ and so on for numbers, routines, arrays and of course
707
objects. ~;xo~ examines something as an object, so for instance
708
~;x location~ tells you about the variable ~location~, but ~;xo
709
location~ tells you what object it refers to.^^";
710
print "~;give~, ~;remove~ and ~;move~ work like the corresponding
711
Inform statements.^^";
712
print "~;<~ causes an action: for instance, ~;< Eat cheese~.^^";
713
print "~;watch~ or ~;w~ can set a watch on various activities:
714
type just ~;w~ for details.^^";
715
print "~;inventory~ or ~;i~ describes the contents of this story file.^";
718
[ InfixEvalSub; InfixExamineP(true); ];
721
print "; <", (InfixPrintAction) infix_lvalue;
722
if (noun) print " (", (the) noun, ")";
723
if (second) print " (", (the) second, ")";
725
if (second) <<(infix_lvalue) noun second>>;
726
if (noun) <<(infix_lvalue) noun>>;
731
print "; give (", (the) noun, ") ";
732
if (second < 0) { second = ~second; f=true; }
733
if (second < 0 || second >= 48) "<No such attribute>";
734
if (f) print "@@126";
735
print (DebugAttribute) second;
736
if (f) @clear_attr noun second;
737
else @set_attr noun second;
741
print "; move (", (the) noun, ") to (", (the) second, ")";
746
print "; remove (", (the) noun, ")";
751
y = (x & $7f00) / $100;
752
if (x < 0) y = y + $80;
754
print (Infixhexdigit) y/$10, (Infixhexdigit) y, (Infixhexdigit) x/$10, (Infixhexdigit) x;
757
[ Infixhexdigit x; x = x % $10; if (x < 10) print x; else print (char) 'a'+x-10; ];
760
infix_data1 = metaclass(noun);
761
infix_term_type = INFIXTT_CONSTANT;
762
InfixExamineP(false);
766
infix_term_type = INFIXTT_STATICSTRING;
767
InfixExamineP(false);
770
[ InfixExamineSub; InfixExamineP(false); ];
772
[ InfixExamineP brief x a b w flag lines;
773
switch (infix_term_type) {
775
if (brief) "; == ", noun;
776
print "; The number ", noun, " == $", (InfixHex) noun;
777
if (noun >= 32 && noun < 127) print " == '", (char) noun, "'";
780
print "~", (name) noun, "~ (", noun, ")^"; if (brief) return;
783
if (brief) "; == ", noun;
784
switch (infix_data1 & 15) {
786
print "; Constant ", (InfixPrintConstant) infix_parsed_lvalue,
788
Object: <<Showobj noun>>;
790
print "Class ", (name) noun, "^";
791
objectloop (a ofclass noun) {
792
if (flag) print ", "; else print "Contains: ";
793
print (name) a, " (", a, ")"; flag=true;
795
if (flag == false) "No object is of this class";
799
if (brief) "; == ", noun;
800
if (noun >= 48 || noun < 0) "; No such attribute";
801
print "; Attribute ", (InfixPrintAttribute) noun,
802
" (numbered ", noun, ")^";
803
objectloop (x has noun) {
804
if (flag) print ", ";
805
else print "Each of these ~has ", (InfixPrintAttribute) noun, "~: ";
806
print (name) x, " (", x, ")"; flag = true;
808
if (flag == false) "No object ~has ", (InfixPrintAttribute) noun, "~";
811
if (brief) "; == ", noun;
812
print "; Property ", (property) noun, " (numbered ", noun, ")^";
813
objectloop (x provides noun) {
814
if (flag) print ", "; else print "Provided by: ";
815
print (name) x, " (", x, ")"; flag = true;
817
if (flag == false) "Which is not provided by any object";
820
if (brief) "; == ", noun;
821
if (noun == 0) "; This word is not in the dictionary";
822
a = noun->#dict_par1;
823
print "; Dictionary word '", (address) noun;
824
if (a & 4) print "//p";
825
print "' (address ", noun, ")";
828
if (a & 2) print "meta ";
829
if (a & 1) print "verb ";
830
if (a & 8) print "preposition ";
831
if (a & 4) print "pluralising ";
832
if (a & 128) print "noun ";
835
if (a & 1) <<Showverb noun>>;
837
if (brief) "; == ", noun;
838
print "; Routine ", (InfixPrintRoutine) infix_parsed_lvalue, " (number ",
839
infix_parsed_lvalue, ", packed address ", noun, ")^";
841
if (brief) "; == ", noun;
842
print "; Global ", (InfixPrintGlobal) infix_parsed_lvalue, " == ", noun, "^";
844
if (brief) "; == ", noun;
845
print "; Array ", (InfixPrintArray) infix_parsed_lvalue, " ";
846
infix_data1 = infix_data1 % 16;
847
switch (infix_data1) {
850
2: print "string"; a=1;
851
3: print "table"; a=1;
852
4: print "buffer"; a=WORDSIZE;
854
print " ", infix_data2 + 1 - a, "^; == "; b = infix_data2;
855
for (w=b : w>=a : w--)
856
if (infix_data1 == 0 or 2 or 4) { if (noun->w) break; }
857
else { if (noun-->w) break; }
860
if (infix_data1 == 0 or 2 or 4) print noun->x, " ";
861
else print noun-->x, " ";
862
if (x+1 == a) print ": ";
864
if (w < b) print "(then ", b-w, " zero entries)";
867
if (brief) "; == ", noun;
868
if (noun >= #lowest_fake_action_number && noun <= #highest_fake_action_number)
869
"; Fake action ", (InfixPrintFakeAction) noun,
870
" (numbered ", noun, ")^Is not generated by any grammar";
871
print "; Action ", (InfixPrintAction) noun,
872
" (numbered ", noun, ")^";
873
w = HDR_DICTIONARY-->0;
874
for (b=0 : b<(HDR_DICTIONARY-->0 + 5)-->0 : b++) {
875
w = HDR_DICTIONARY-->0 + 7 + b*9;
876
if ((w->#dict_par1) & 1) {
877
a = (HDR_STATICMEMORY-->0)-->($ff-(w->#dict_par2));
879
for (: lines>0 : lines--) {
880
a = UnpackGrammarLine(a);
881
if (action_to_be == noun) {
882
print "'", (address) w, "' "; DebugGrammarLine();
889
if (flag == 0) "Is not generated by any grammar";
891
if (brief) "; == ", noun;
892
"; System function ~", (address) infix_parsed_lvalue, "~ has
893
not been overridden by any routine and so has its standard definition.";
894
INFIXTT_STATICSTRING:
895
if (brief) "; == ", noun;
896
if (metaclass(noun) ~= String) "; ", noun, " is not a string.";
897
print "~", (string) noun, "~^";
899
if (noun == true) "; true"; if (noun == false) "; false";
902
]; ! end of InfixExamineP
904
[ InfixDescribeWatchSub x y z s flag aflag;
905
print "; The Infix ~;watch~ verb allows you to set a watch on any named
906
routine(s) or objects: for instance ~;watch ScoreSub~ or
907
~;watch silver bars~. You can also:
908
^ ~;watch objects~: changes to attribute or property settings";
909
if (debug_flag & 8) print " (on)"; else print " (off)";
911
print ";^ ~;watch timers~: the running of timers and daemons each turn";
912
if (debug_flag & 4) print " (on)"; else print " (off)";
914
print ";^ ~;watch messages~: all messages sent";
915
if (debug_flag & 1) print " (on)"; else print " (off)";
917
print ";^ ~;watch actions~: all actions generated";
918
if (debug_flag & 2) print " (on)"; else print " (off)";
920
print ".^~~;watch~ can be abbreviated to ~;w~ and use ~off~ to stop
921
watching: for instance ~;w location off~.^";
923
objectloop (x has infix__watching) flag = true; aflag = aflag || flag;
924
if (flag) print "The following objects are currently being watched: ";
926
objectloop (x has infix__watching) {
927
if (flag) print ", "; flag = true;
928
print (name) x, " (", x, ")";
931
s = (#highest_routine_number - #lowest_routine_number);
932
if (s%8 == 0) s=s/8; else s=s/8+1;
933
for (flag=false,x=0 : x<s : x++) if (#routine_flags_array->x) flag = true;
934
aflag = aflag || flag;
935
if (flag) print "The following routines are currently being watched: ";
936
for (x=0,flag=false : x<s : x++) {
937
for (y=1,z=0 : y<256 : z++,y=y*2) {
938
if ((#routine_flags_array->x) & y) {
939
if (flag) print ", "; flag = true;
940
print (InfixPrintRoutine)
941
#lowest_routine_number + x*8 + z;
946
if (aflag == false) "At present, nothing is being watched.";
949
[ InfixWatchOnSub i j k l;
950
if (noun == 0) return InfixDescribeWatchSub();
951
if (infix_term_type == INFIXTT_ROUTINE) {
952
i = infix_parsed_lvalue/8;
953
for (j=0,k=1 : j<infix_parsed_lvalue%8 : j++) k=k*2;
954
l = #routine_flags_array->i;
956
@storeb #routine_flags_array i l;
957
"; Watching routine ", (InfixPrintRoutine) infix_parsed_lvalue, ".";
959
if (metaclass(noun) == Object) {
960
give noun infix__watching;
961
"; Watching object ~", (name) noun, "~ (", noun, ").";
963
InfixDescribeWatchSub();
966
[ InfixWatchOffSub i j k l;
967
if (noun == 0) return InfixDescribeWatchSub();
968
if (infix_term_type == INFIXTT_ROUTINE) {
969
i = infix_parsed_lvalue/8;
970
for (j=0,k=1 : j<infix_parsed_lvalue%8 : j++) k=k*2;
971
l = #routine_flags_array->i;
973
@storeb #routine_flags_array i l;
974
"; Not watching ", (InfixPrintRoutine) infix_parsed_lvalue, ".";
976
if (metaclass(noun) == Object) {
977
@clear_attr noun infix__watching;
978
"; Not watching object ~", (name) noun, "~ (", noun, ").";
980
InfixDescribeWatchSub();
983
[ InfixList from to tab filter i flag;
985
for (i=from : i<=to : i++)
986
if (tab-->(i-from)) {
988
if (tab == #array_names_array) {
989
Symb__Tab(INFIXTT_ARRAY, i);
990
flag = ~~(temp__global3 & 16);
992
if (tab == #routine_names_array) {
993
Symb__Tab(INFIXTT_ROUTINE,i);
994
flag = ~~(temp__global3 & 16);
996
if (tab == #constant_names_array) {
997
Symb__Tab(INFIXTT_CONSTANT,i);
998
flag = (~~(temp__global3 & 16)) && (temp__global3 % 16 == filter);
1000
if (flag) print (string) tab-->(i-from), " ";
1007
print (string) Story, (string) Headline;
1008
print " ", (number) #highest_object_number - #lowest_object_number + 1,
1011
print " non-library object-name constants:";
1012
InfixList(#lowest_constant_number, #highest_constant_number, #constant_names_array, 2);
1014
print " ", (number) #highest_class_number - #lowest_class_number + 1, " classes:^ ";
1015
for (i=#lowest_class_number : i<=#highest_class_number : i++)
1016
print (name) #class_objects_array-->i, " ";
1019
print " non-library arrays:";
1020
InfixList(#lowest_array_number, #highest_array_number, #array_names_array);
1022
print " non-library routines:";
1023
InfixList(#lowest_routine_number, #highest_routine_number, #routine_names_array);
1025
print " non-library constants:";
1026
InfixList(#lowest_constant_number, #highest_constant_number, #constant_names_array, 0);
1028
print " (common) properties:";
1029
InfixList(#lowest_property_number, 63, #property_names_array);
1031
print " (individual) properties:";
1032
InfixList(64, #highest_property_number, #property_names_array + 126);
1034
print " attributes:";
1035
InfixList(#lowest_attribute_number, #highest_attribute_number, #attribute_names_array);
1039
print " variables:";
1040
InfixList(#lowest_global_number, #highest_global_number, #global_names_array);
1043
InfixList(#lowest_action_number, #highest_action_number, #action_names_array);
1045
print " fake actions:";
1046
InfixList(#lowest_fake_action_number, #highest_fake_action_number, #fake_action_names_array);
1049
Verb meta ';i' ';inv' ';inventory'
1051
Verb meta ';x' ';examine'
1052
* InfixRvalue -> InfixExamine;
1053
Verb meta ';xo' ';examineo'
1054
* InfixRvalue -> InfixExamineO;
1055
Verb meta ';xs' ';examines'
1056
* InfixRvalue -> InfixExamineS;
1058
* InfixActionToken -> InfixAction
1059
* InfixActionToken InfixRvalue -> InfixAction
1060
* InfixActionToken InfixRvalue InfixRvalue -> InfixAction;
1063
* InfixRvalue -> InfixEval;
1065
* InfixRvalue InfixRvalue -> InfixGive;
1067
* InfixRvalue "to" InfixRvalue -> InfixMove;
1069
* InfixRvalue -> InfixRemove;
1070
Verb meta ';watch' ';w'
1072
* "timers"/"daemons" -> TimersOn
1073
* "timers"/"daemons" "off" -> TimersOff
1074
* "actions" -> ActionsOn
1075
* "actions" "off" -> ActionsOff
1076
* "messages" -> RoutinesOn
1077
* "messages" "off" -> RoutinesOff
1078
* "objects" -> ChangesOn
1079
* "objects" "off" -> ChangesOff
1080
* InfixRvalueTerm -> InfixWatchOn
1081
* InfixRvalueTerm "off" -> InfixWatchOff;
1085
! ==============================================================================