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