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