Import v6.12.6 of the Inform 6 standard library
[informlib.git] / grammar.h
1 ! ==============================================================================
2 !   GRAMMAR:  Grammar table entries for the standard verbs library.
3 !
4 !   Supplied for use with Inform 6 -- Release 6.12.5 -- Serial number 220219
5 !
6 !   Copyright Graham Nelson 1993-2004 and David Griffith 2012-2022
7 !
8 !   This file is free software: you can redistribute it and/or modify
9 !   it under the terms of the GNU Affero General Public License as
10 !   published by the Free Software Foundation, either version 3 of the
11 !   License, or (at your option) any later version.
12 !
13 !   This file is distributed in the hope that it will be useful, but
14 !   WITHOUT ANY WARRANTY; without even the implied warranty of
15 !   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 !   Affero General Public License for more details.
17 !
18 !   You should have received a copy of the GNU Affero General Public
19 !   License along with this program. If not, see
20 !   https://gnu.org/licenses/
21 !
22 !   In your game file, Include three library files in this order:
23 !       Include "parser";
24 !       Include "verblib";
25 !       Include "grammar";
26 ! ==============================================================================
27
28 System_file;
29
30 #Ifdef          LIBRARY_STAGE;
31 #Iffalse        LIBRARY_STAGE >= AFTER_GRAMMAR; ! if not already included
32 #Iftrue         LIBRARY_STAGE == AFTER_VERBLIB; ! if okay to include it
33
34 ! ------------------------------------------------------------------------------
35 !  The "meta-verbs", commands to the game rather than in the game, come first:
36 ! ------------------------------------------------------------------------------
37
38 Verb meta 'brief'
39     *                                           -> LMode1;
40
41 Verb meta 'verbose' 'long'
42     *                                           -> LMode2;
43
44 Verb meta 'superbrief' 'short'
45     *                                           -> LMode3;
46
47 Verb meta 'normal'
48     *                                           -> LModeNormal;
49
50 Verb meta 'notify'
51     *                                           -> NotifyOn
52     * 'on'                                      -> NotifyOn
53     * 'off'                                     -> NotifyOff;
54
55 Verb meta 'pronouns' 'nouns'
56     *                                           -> Pronouns;
57
58 Verb meta 'quit' 'q//' 'die'
59     *                                           -> Quit;
60
61 Verb meta 'recording'
62     *                                           -> CommandsOn
63     * 'on'                                      -> CommandsOn
64     * 'off'                                     -> CommandsOff;
65
66 Verb meta 'replay'
67     *                                           -> CommandsRead;
68
69 Verb meta 'restart'
70     *                                           -> Restart;
71
72 Verb meta 'restore'
73     *                                           -> Restore;
74
75 Verb meta 'save'
76     *                                           -> Save;
77
78 Verb meta 'score'
79     *                                           -> Score;
80
81 Verb meta 'fullscore' 'full'
82     *                                           -> FullScore
83     * 'score'                                   -> FullScore;
84
85 Verb meta 'script' 'transcript'
86     *                                           -> ScriptOn
87     * 'on'                                      -> ScriptOn
88     * 'off'                                     -> ScriptOff;
89
90 Verb meta 'noscript' 'unscript'
91     *                                           -> ScriptOff;
92
93 Verb meta 'verify'
94     *                                           -> Verify;
95
96 Verb meta 'version'
97     *                                           -> Version;
98
99 #Ifndef NO_PLACES;
100 Verb meta 'objects'
101     *                                           -> Objects
102     * 'tall'                                    -> ObjectsTall
103     * 'wide'                                    -> ObjectsWide;
104 Verb meta 'places'
105     *                                           -> Places
106     * 'tall'                                    -> PlacesTall
107     * 'wide'                                    -> PlacesWide;
108 #Endif; ! NO_PLACES
109
110 ! ------------------------------------------------------------------------------
111 !  Debugging grammar
112 ! ------------------------------------------------------------------------------
113
114 #Ifdef DEBUG;
115 Verb meta 'actions'
116     *                                           -> ActionsOn
117     * 'on'                                      -> ActionsOn
118     * 'off'                                     -> ActionsOff;
119
120 Verb meta 'changes'
121     *                                           -> ChangesOn
122     * 'on'                                      -> ChangesOn
123     * 'off'                                     -> ChangesOff;
124
125 Verb meta 'gonear'
126     * anynumber                                 -> GoNear
127     * noun                                      -> GoNear;
128
129
130 Verb meta 'goto'
131     * anynumber                                 -> Goto;
132
133 Verb meta 'random'
134     *                                           -> Predictable;
135
136 Verb meta 'routines' 'messages'
137     *                                           -> RoutinesOn
138     * 'on'                                      -> RoutinesOn
139     * 'verbose'                                 -> RoutinesVerbose
140     * 'off'                                     -> RoutinesOff;
141
142 Verb meta 'scope'
143     *                                           -> Scope
144     * anynumber                                 -> Scope
145     * noun                                      -> Scope;
146
147 Verb meta 'showdict' 'dict'
148     *                                           -> ShowDict
149     * topic                                     -> ShowDict;
150
151 Verb meta 'showobj'
152     *                                           -> ShowObj
153     * anynumber                                 -> ShowObj
154     * multi                                     -> ShowObj;
155
156 Verb meta 'showverb'
157     * special                                   -> ShowVerb;
158
159 Verb meta 'timers' 'daemons'
160     *                                           -> TimersOn
161     * 'on'                                      -> TimersOn
162     * 'off'                                     -> TimersOff;
163
164 Verb meta 'trace'
165     *                                           -> TraceOn
166     * number                                    -> TraceLevel
167     * 'on'                                      -> TraceOn
168     * 'off'                                     -> TraceOff;
169
170 Verb meta 'abstract'
171     * anynumber 'to' anynumber                  -> XAbstract
172     * noun 'to' noun                            -> XAbstract;
173
174 Verb meta 'purloin'
175     * anynumber                                 -> XPurloin
176     * multi                                     -> XPurloin;
177
178 Verb meta 'tree'
179     *                                           -> XTree
180     * anynumber                                 -> XTree
181     * noun                                      -> XTree;
182
183 #Ifdef TARGET_GLULX;
184 Verb meta 'glklist'
185     *                                           -> Glklist;
186 #Endif; ! TARGET_
187
188 #Endif; ! DEBUG
189
190 ! ------------------------------------------------------------------------------
191 !  And now the game verbs.
192 ! ------------------------------------------------------------------------------
193
194 [ ADirection; if (noun in Compass) rtrue; rfalse; ];
195
196 Verb 'answer' 'say' 'shout' 'speak'
197     * topic 'to' creature                       -> Answer;
198
199 Verb 'ask'
200     * creature 'about' topic                    -> Ask
201     * creature 'for' noun                       -> AskFor
202     * creature 'to' topic                       -> AskTo
203     * 'that' creature topic                     -> AskTo;
204
205 Verb 'attack' 'break' 'crack' 'destroy'
206      'fight' 'hit' 'kill' 'murder' 'punch'
207      'smash' 'thump' 'torture' 'wreck'
208     * noun                                      -> Attack;
209
210 Verb 'blow'
211     * held                                      -> Blow;
212
213 Verb 'bother' 'curses' 'darn' 'drat'
214     *                                           -> Mild
215     * topic                                     -> Mild;
216
217 Verb 'burn' 'light'
218     * noun                                      -> Burn
219     * noun 'with' held                          -> Burn;
220
221 Verb 'buy' 'purchase'
222     * noun                                      -> Buy;
223
224 Verb 'climb' 'scale'
225     * noun                                      -> Climb
226     * 'up'/'over' noun                          -> Climb;
227
228 Verb 'carry'
229     * multi                                     -> Take
230     * multiinside 'from'/'off' noun             -> Remove
231     * 'inventory'                               -> Inv;
232
233 Verb 'close' 'cover' 'shut'
234     * noun                                      -> Close
235     * 'up' noun                                 -> Close
236     * 'off' noun                                -> SwitchOff;
237
238 Verb 'consult'
239     * noun 'about' topic                        -> Consult
240     * noun 'on' topic                           -> Consult;
241
242 Verb 'cut' 'chop' 'prune' 'slice'
243     * noun                                      -> Cut;
244
245 Verb 'dig'
246     * noun                                      -> Dig
247     * noun 'with' held                          -> Dig
248     * 'in' noun                                 -> Dig
249     * 'in' noun 'with' held                     -> Dig;
250
251
252 Verb 'disrobe' 'doff' 'shed'
253     * multi                                     -> Disrobe;
254
255 Verb 'drink' 'sip' 'swallow'
256     * noun                                      -> Drink;
257
258 Verb 'drop' 'discard'
259     * multiheld                                 -> Drop
260     * multiexcept 'in'/'into'/'down' noun       -> Insert
261     * multiexcept 'on'/'onto' noun              -> PutOn;
262
263 Verb 'throw'
264     * noun                                      -> ThrowAt
265     * held 'at'/'against'/'on'/'onto' noun      -> ThrowAt;
266
267 Verb 'eat'
268     * held                                      -> Eat;
269
270 Verb 'empty'
271     * noun                                      -> Empty
272     * 'out' noun                                -> Empty
273     * noun 'out'                                -> Empty
274     * noun 'to'/'into'/'on'/'onto' noun         -> EmptyT;
275
276 Verb 'enter' 'cross'
277     *                                           -> GoIn
278     * noun                                      -> Enter;
279
280 Verb 'examine' 'x//' 'check' 'describe' 'watch'
281     * noun                                      -> Examine;
282
283 Verb 'exit' 'out' 'outside'
284     *                                           -> Exit
285     * noun                                      -> Exit;
286
287 Verb 'fill'
288     * noun                                      -> Fill
289     * noun 'from' noun                          -> Fill;
290
291 Verb 'get'
292     * 'out'/'off'/'up' 'of'/'from' noun         -> Exit
293     * multi                                     -> Take
294     * 'in'/'into'/'on'/'onto' noun              -> Enter
295     * 'off' noun                                -> GetOff
296     * multiinside 'from'/'off' noun             -> Remove;
297
298 Verb 'give' 'feed' 'offer' 'pay'
299     * creature held                             -> Give reverse
300     * held 'to' creature                        -> Give
301     * 'over' held 'to' creature                 -> Give;
302
303 Verb 'go' 'run' 'walk'
304     *                                           -> VagueGo
305     * noun=ADirection                           -> Go
306     * noun                                      -> Enter
307     * 'out'/'outside'                           -> Exit
308     * 'in'/'inside'                             -> GoIn
309     * 'into'/'in'/'inside'/'through' noun       -> Enter;
310
311 Verb 'hold'
312     * multi                                     -> Take
313     * multiinside 'from'/'off' noun             -> Remove
314     * 'inventory'                               -> Inv;
315
316 Verb 'in' 'inside'
317     *                                           -> GoIn;
318
319 Verb 'insert'
320     * multiexcept 'in'/'into' noun              -> Insert;
321
322 Verb 'inventory' 'inv' 'i//'
323     *                                           -> Inv
324     * 'tall'                                    -> InvTall
325     * 'wide'                                    -> InvWide;
326
327 Verb 'jump' 'hop' 'skip'
328     *                                           -> Jump
329     * 'in' noun                                 -> JumpIn
330     * 'into' noun                               -> JumpIn
331     * 'on' noun                                 -> JumpOn
332     * 'upon' noun                               -> JumpOn
333     * 'over' noun                               -> JumpOver;
334
335 Verb 'kiss' 'embrace' 'hug'
336     * creature                                  -> Kiss;
337
338 Verb 'leave'
339     *                                           -> VagueGo
340     * noun=ADirection                           -> Go
341     * noun                                      -> Exit
342     * 'into'/'in'/'inside'/'through' noun       -> Enter;
343
344 Verb 'listen' 'hear'
345     *                                           -> Listen
346     * noun                                      -> Listen
347     * 'to' noun                                 -> Listen;
348
349 Verb 'lock'
350     * noun 'with' held                          -> Lock;
351
352 Verb 'look' 'l//'
353     *                                           -> Look
354     * 'at' noun                                 -> Examine
355     * 'inside'/'in'/'into'/'through'/'on' noun  -> Search
356     * 'under' noun                              -> LookUnder
357     * 'up' topic 'in' noun                      -> Consult
358     * noun=ADirection                           -> Examine
359     * 'to' noun=ADirection                      -> Examine;
360
361 Verb 'no'
362     *                                           -> No;
363
364 Verb 'open' 'uncover' 'undo' 'unwrap'
365     * noun                                      -> Open
366     * noun 'with' held                          -> Unlock;
367
368 Verb 'peel'
369     * noun                                      -> Take
370     * 'off' noun                                -> Take;
371
372 Verb 'pick'
373     * 'up' multi                                -> Take
374     * multi 'up'                                -> Take;
375
376 Verb 'pray'
377     *                                           -> Pray;
378
379 Verb 'pry' 'prise' 'prize' 'lever' 'jemmy' 'force'
380     * noun 'with' held                          -> Unlock
381     * 'apart'/'open' noun 'with' held           -> Unlock
382     * noun 'apart'/'open' 'with' held           -> Unlock;
383
384 Verb 'pull' 'drag'
385     * noun                                      -> Pull;
386
387 Verb 'push' 'clear' 'move' 'press' 'shift'
388     * noun                                      -> Push
389     * noun noun                                 -> PushDir
390     * noun 'to' noun                            -> Transfer;
391
392 Verb 'put'
393     * multiexcept 'in'/'inside'/'into' noun     -> Insert
394     * multiexcept 'on'/'onto' noun              -> PutOn
395     * 'on' multiheld                            -> Wear
396     * 'down' multiheld                          -> Drop
397     * multiheld 'down'                          -> Drop;
398
399 Verb 'read'
400     * noun                                      -> Examine
401     * 'about' topic 'in' noun                   -> Consult
402     * topic 'in' noun                           -> Consult;
403
404 Verb 'remove'
405     * worn                                      -> Disrobe
406     * multi                                     -> Remove
407     * multiinside 'from' noun                   -> Remove;
408
409 Verb 'rub' 'clean' 'dust' 'polish' 'scrub'
410      'shine' 'sweep' 'wipe'
411     * noun                                      -> Rub;
412
413 Verb 'search'
414     * noun                                      -> Search;
415
416 Verb 'set' 'adjust'
417     * noun                                      -> Set
418     * noun 'to' special                         -> SetTo;
419
420 Verb 'show' 'display' 'present'
421     * creature held                             -> Show reverse
422     * held 'to' creature                        -> Show;
423
424 Verb 'shit' 'damn' 'fuck' 'sod'
425     *                                           -> Strong
426     * topic                                     -> Strong;
427
428 Verb 'sing'
429     *                                           -> Sing;
430
431 Verb 'sit' 'lie'
432     * 'on' 'top' 'of' noun                      -> Enter
433     * 'on'/'in'/'inside' noun                   -> Enter;
434
435 Verb 'sleep' 'nap'
436     *                                           -> Sleep;
437
438 Verb 'smell' 'sniff'
439     *                                           -> Smell
440     * noun                                      -> Smell;
441
442 Verb 'sorry'
443     *                                           -> Sorry;
444
445 Verb 'squeeze' 'squash'
446     * noun                                      -> Squeeze;
447
448 Verb 'stand'
449     *                                           -> Exit
450     * 'up'                                      -> Exit
451     * 'on' noun                                 -> Enter;
452
453 Verb 'swim' 'dive'
454     *                                           -> Swim;
455
456 Verb 'swing'
457     * noun                                      -> Swing
458     * 'on' noun                                 -> Swing;
459
460 Verb 'switch'
461     * noun                                      -> SwitchOn
462     * noun 'on'                                 -> SwitchOn
463     * noun 'off'                                -> SwitchOff
464     * 'on' noun                                 -> SwitchOn
465     * 'off' noun                                -> SwitchOff;
466
467 Verb 'take'
468     * multi                                     -> Take
469     * 'off' multiheld                           -> Disrobe
470     * multiinside 'from'/'off' noun             -> Remove
471     * 'inventory'                               -> Inv;
472
473 Verb 'taste'
474     * noun                                      -> Taste;
475
476 Verb 'tell'
477     * creature 'about' topic                    -> Tell
478     * creature 'to' topic                       -> AskTo;
479
480 Verb 'think'
481     *                                           -> Think;
482
483 Verb 'tie' 'attach' 'connect' 'fasten' 'fix'
484     * noun                                      -> Tie
485     * noun 'to' noun                            -> Tie;
486
487 Verb 'touch' 'feel' 'fondle' 'grope'
488     * noun                                      -> Touch;
489
490 Verb 'transfer'
491     * noun 'to' noun                            -> Transfer;
492
493 Verb 'turn' 'rotate' 'screw' 'twist' 'unscrew'
494     * noun                                      -> Turn
495     * noun 'on'                                 -> SwitchOn
496     * noun 'off'                                -> SwitchOff
497     * 'on' noun                                 -> SwitchOn
498     * 'off' noun                                -> SwitchOff;
499
500 Verb 'unlock'
501     * noun 'with' held                          -> Unlock;
502
503 Verb 'wait' 'z//'
504     *                                           -> Wait;
505
506 Verb 'wake' 'awake' 'awaken'
507     *                                           -> Wake
508     * 'up'                                      -> Wake
509     * creature                                  -> WakeOther
510     * creature 'up'                             -> WakeOther
511     * 'up' creature                             -> WakeOther;
512
513 Verb 'wave'
514     *                                           -> WaveHands
515     * noun                                      -> Wave
516     * noun 'at' noun                            -> Wave
517     * 'at' noun                                 -> WaveHands;
518
519 Verb 'wear' 'don'
520     * multiheld                                 -> Wear;
521
522 Verb 'yes' 'y//'
523     *                                           -> Yes;
524
525 ! ------------------------------------------------------------------------------
526 !  This routine is no longer used here, but provided to help existing games
527 !  which use it as a general parsing routine:
528
529 [ ConTopic w;
530     consult_from = wn;
531     do w = NextWordStopped();
532     until (w == -1 || (w == 'to' && action_to_be == ##Answer));
533     wn--;
534     consult_words = wn - consult_from;
535     if (consult_words == 0) return -1;
536     if (action_to_be == ##Answer or ##Ask or ##Tell) {
537         w = wn; wn = consult_from; parsed_number = NextWord();
538         if (parsed_number == 'the' && consult_words > 1) parsed_number = NextWord();
539         wn = w;
540         return 1;
541     }
542     return 0;
543 ];
544
545 ! ------------------------------------------------------------------------------
546 !  Final task: provide trivial routines if the user hasn't already:
547 ! ------------------------------------------------------------------------------
548
549 Default Story           0;
550 Default Headline        0;
551 Default d_obj           NULL;
552 Default u_obj           NULL;
553
554 Stub AfterLife         0;
555 Stub AfterPrompt       0;
556 Stub Amusing           0;
557 Stub BeforeParsing     0;
558 Stub ChooseObjects     2;
559 Stub DarkToDark        0;
560 Stub DeathMessage      0;
561 Stub Epilogue          0;
562 Stub GamePostRoutine   0;
563 Stub GamePreRoutine    0;
564 Stub InScope           1;
565 Stub LookRoutine       0;
566 Stub NewRoom           0;
567 Stub ObjectDoesNotFit  2;
568 Stub ParseNumber       2;
569 Stub ParserError       1;
570 Stub PrintTaskName     1;
571 Stub PrintVerb         1;
572 Stub TimePasses        0;
573 Stub UnknownVerb       1;
574 Stub AfterSave         1;
575 Stub AfterRestore      1;
576
577 #Ifdef TARGET_GLULX;
578 Stub HandleGlkEvent    2;
579 Stub IdentifyGlkObject 4;
580 Stub InitGlkWindow     1;
581 #Endif; ! TARGET_GLULX
582
583 #Ifndef PrintRank;
584 [ PrintRank; "."; ];
585 #Endif;
586
587 #Ifndef ParseNoun;
588 [ ParseNoun obj; obj = obj; return -1; ];
589 #Endif;
590
591 #Ifdef INFIX;
592 Include "infix";
593 #Endif;
594
595 ! ==============================================================================
596
597 Undef LIBRARY_STAGE; Constant LIBRARY_STAGE = AFTER_GRAMMAR;
598
599 #Ifnot;         ! LIBRARY_STAGE < AFTER_GRAMMAR but ~= AFTER_VERBLIB
600 Message "Error: 'verblib' needs to be correctly included before including 'grammar'. This will cause a big number of errors!";
601 #Endif;
602
603 #Ifnot;         ! LIBRARY_STAGE >= AFTER_GRAMMAR : already included
604 Message "Warning: 'grammar' included twice; ignoring second inclusion. (Ignore this if this is on purpose.)";
605 #Endif;
606
607 #Ifnot;         ! LIBRARY_STAGE is not defined
608 Message "Error: 'parser', then 'verblib' need to be correctly included before including 'grammar'. This will cause a big number of errors!";
609 #Endif;
610
611 ! ==============================================================================