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