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