Inform - Support - Source

Back to List

Inventory
Complete

Plain
Coloured
Gaudy

Browsing Grammar.h

This is the complete source code of the example game Grammar.inf.

001  ! ==============================================================================
002  !   GRAMMAR:  Grammar table entries for the standard verbs library.
003  !
004  !   Supplied for use with Inform 6 -- Release 6/11 -- Serial number 040227
005  !
006  !   Copyright Graham Nelson 1993-2004 but freely usable (see manuals)
007  !
008  !   In your game file, Include three library files in this order:
009  !       Include "Parser";
010  !       Include "VerbLib";
011  !       Include "Grammar";
012  ! ==============================================================================
013   
014  System_file;
015   
016  ! ------------------------------------------------------------------------------
017  !  The "meta-verbs", commands to the game rather than in the game, come first:
018  ! ------------------------------------------------------------------------------
019   
020  Verb meta 'brief' 'normal'
021      *                                           -> LMode1;
022  Verb meta 'verbose' 'long'
023      *                                           -> LMode2;
024  Verb meta 'superbrief' 'short'
025      *                                           -> LMode3;
026  Verb meta 'notify'
027      *                                           -> NotifyOn
028      * 'on'                                      -> NotifyOn
029      * 'off'                                     -> NotifyOff;
030  Verb meta 'pronouns' 'nouns'
031      *                                           -> Pronouns;
032  Verb meta 'quit' 'q//' 'die'
033      *                                           -> Quit;
034  Verb meta 'recording'
035      *                                           -> CommandsOn
036      * 'on'                                      -> CommandsOn
037      * 'off'                                     -> CommandsOff;
038  Verb meta 'replay'
039      *                                           -> CommandsRead;
040  Verb meta 'restart'
041      *                                           -> Restart;
042  Verb meta 'restore'
043      *                                           -> Restore;
044  Verb meta 'save'
045      *                                           -> Save;
046  Verb meta 'score'
047      *                                           -> Score;
048  Verb meta 'fullscore' 'full'
049      *                                           -> FullScore
050      * 'score'                                   -> FullScore;
051  Verb meta 'script' 'transcript'
052      *                                           -> ScriptOn
053      * 'on'                                      -> ScriptOn
054      * 'off'                                     -> ScriptOff;
055  Verb meta 'noscript' 'unscript'
056      *                                           -> ScriptOff;
057  Verb meta 'verify'
058      *                                           -> Verify;
059  Verb meta 'version'
060      *                                           -> Version;
061   
062  #Ifndef NO_PLACES;
063  Verb meta 'objects'
064      *                                           -> Objects;
065  Verb meta 'places'
066      *                                           -> Places;
067  #Endif; ! NO_PLACES
068   
069  ! ------------------------------------------------------------------------------
070  !  Debugging grammar
071  ! ------------------------------------------------------------------------------
072   
073  #Ifdef DEBUG;
074  Verb meta 'actions'
075      *                                           -> ActionsOn
076      * 'on'                                      -> ActionsOn
077      * 'off'                                     -> ActionsOff;
078  Verb meta 'changes'
079      *                                           -> ChangesOn
080      * 'on'                                      -> ChangesOn
081      * 'off'                                     -> ChangesOff;
082  Verb meta 'gonear'
083      * noun                                      -> Gonear;
084  Verb meta 'goto'
085      * number                                    -> Goto;
086  Verb meta 'random'
087      *                                           -> Predictable;
088  Verb meta 'routines' 'messages'
089      *                                           -> RoutinesOn
090      * 'on'                                      -> RoutinesOn
091      * 'off'                                     -> RoutinesOff;
092  Verb meta 'scope'
093      *                                           -> Scope
094      * noun                                      -> Scope;
095  Verb meta 'showobj'
096      *                                           -> Showobj
097      * number                                    -> Showobj
098      * multi                                     -> Showobj;
099  Verb meta 'showverb'
100      * special                                   -> Showverb;
101  Verb meta 'timers' 'daemons'
102      *                                           -> TimersOn
103      * 'on'                                      -> TimersOn
104      * 'off'                                     -> TimersOff;
105  Verb meta 'trace'
106      *                                           -> TraceOn
107      * number                                    -> TraceLevel
108      * 'on'                                      -> TraceOn
109      * 'off'                                     -> TraceOff;
110  Verb meta 'abstract'
111      * noun 'to' noun                            -> XAbstract;
112  Verb meta 'purloin'
113      * multi                                     -> XPurloin;
114  Verb meta 'tree'
115      *                                           -> XTree
116      * noun                                      -> XTree;
117   
118  #Ifdef TARGET_GLULX;
119  Verb meta 'glklist'
120      *                                           -> Glklist;
121  #Endif; ! TARGET_
122   
123  #Endif; ! DEBUG
124   
125  ! ------------------------------------------------------------------------------
126  !  And now the game verbs.
127  ! ------------------------------------------------------------------------------
128   
129  [ ADirection; if (noun in compass) rtrue; rfalse; ];
130   
131  Verb 'answer' 'say' 'shout' 'speak'
132      * topic 'to' creature                       -> Answer;
133  Verb 'ask'
134      * creature 'about' topic                    -> Ask
135      * creature 'for' noun                       -> AskFor
136      * creature 'to' topic                       -> AskTo
137      * 'that' creature topic                     -> AskTo;
138  Verb 'attack' 'break' 'crack' 'destroy'
139       'fight' 'hit' 'kill' 'murder' 'punch'
140       'smash' 'thump' 'torture' 'wreck'
141      * noun                                      -> Attack;
142  Verb 'blow'
143      * held                                      -> Blow;
144  Verb 'bother' 'curses' 'darn' 'drat'
145      *                                           -> Mild
146      * topic                                     -> Mild;
147  Verb 'burn' 'light'
148      * noun                                      -> Burn
149      * noun 'with' held                          -> Burn;
150  Verb 'buy' 'purchase'
151      * noun                                      -> Buy;
152  Verb 'climb' 'scale'
153      * noun                                      -> Climb
154      * 'up'/'over' noun                          -> Climb;
155  Verb 'close' 'cover' 'shut'
156      * noun                                      -> Close
157      * 'up' noun                                 -> Close
158      * 'off' noun                                -> SwitchOff;
159  Verb 'consult'
160      * noun 'about' topic                        -> Consult
161      * noun 'on' topic                           -> Consult;
162  Verb 'cut' 'chop' 'prune' 'slice'
163      * noun                                      -> Cut;
164  Verb 'dig'
165      * noun                                      -> Dig
166      * noun 'with' held                          -> Dig;
167  Verb 'drink' 'sip' 'swallow'
168      * noun                                      -> Drink;
169  Verb 'drop' 'discard' 'throw'
170      * multiheld                                 -> Drop
171      * multiexcept 'in'/'into'/'down' noun       -> Insert
172      * multiexcept 'on'/'onto' noun              -> PutOn
173      * held 'at'/'against'/'on'/'onto' noun      -> ThrowAt;
174  Verb 'eat'
175      * held                                      -> Eat;
176  Verb 'empty'
177      * noun                                      -> Empty
178      * 'out' noun                                -> Empty
179      * noun 'out'                                -> Empty
180      * noun 'to'/'into'/'on'/'onto' noun         -> EmptyT;
181  Verb 'enter' 'cross'
182      *                                           -> GoIn
183      * noun                                      -> Enter;
184  Verb 'examine' 'x//' 'check' 'describe' 'watch'
185      * noun                                      -> Examine;
186  Verb 'exit' 'out' 'outside'
187      *                                           -> Exit
188      * noun                                      -> Exit;
189  Verb 'fill'
190      * noun                                      -> Fill;
191  Verb 'get'
192      * 'out'/'off'/'up'                          -> Exit
193      * multi                                     -> Take
194      * 'in'/'into'/'on'/'onto' noun              -> Enter
195      * 'off' noun                                -> GetOff
196      * multiinside 'from' noun                   -> Remove;
197  Verb 'give' 'feed' 'offer' 'pay'
198      * held 'to' creature                        -> Give
199      * creature held                             -> Give reverse
200      * 'over' held 'to' creature                 -> Give;
201  Verb 'go' 'run' 'walk'
202      *                                           -> VagueGo
203      * noun=ADirection                           -> Go
204      * noun                                      -> Enter
205      * 'into'/'in'/'inside'/'through' noun       -> Enter;
206  Verb 'in' 'inside'
207      *                                           -> GoIn;
208  Verb 'insert'
209      * multiexcept 'in'/'into' noun              -> Insert;
210  Verb 'inventory' 'inv' 'i//'
211      *                                           -> Inv
212      * 'tall'                                    -> InvTall
213      * 'wide'                                    -> InvWide;
214  Verb 'jump' 'hop' 'skip'
215      *                                           -> Jump
216      * 'over' noun                               -> JumpOver;
217  Verb 'kiss' 'embrace' 'hug'
218      * creature                                  -> Kiss;
219  Verb 'leave'
220      *                                           -> VagueGo
221      * noun=ADirection                           -> Go
222      * noun                                      -> Exit
223      * 'into'/'in'/'inside'/'through' noun       -> Enter;
224  Verb 'listen' 'hear'
225      *                                           -> Listen
226      * noun                                      -> Listen
227      * 'to' noun                                 -> Listen;
228  Verb 'lock'
229      * noun 'with' held                          -> Lock;
230  Verb 'look' 'l//'
231      *                                           -> Look
232      * 'at' noun                                 -> Examine
233      * 'inside'/'in'/'into'/'through'/'on' noun  -> Search
234      * 'under' noun                              -> LookUnder
235      * 'up' topic 'in' noun                      -> Consult
236      * noun=ADirection                           -> Examine
237      * 'to' noun=ADirection                      -> Examine;
238  Verb 'no'
239      *                                           -> No;
240  Verb 'open' 'uncover' 'undo' 'unwrap'
241      * noun                                      -> Open
242      * noun 'with' held                          -> Unlock;
243  Verb 'peel'
244      * noun                                      -> Take
245      * 'off' noun                                -> Take;
246  Verb 'pick'
247      * 'up' multi                                -> Take
248      * multi 'up'                                -> Take;
249  Verb 'pray'
250      *                                           -> Pray;
251  Verb 'pry' 'prise' 'prize' 'lever' 'jemmy' 'force'
252      * noun 'with' held                          -> Unlock
253      * 'apart'/'open' noun 'with' held           -> Unlock
254      * noun 'apart'/'open' 'with' held           -> Unlock;
255  Verb 'pull' 'drag'
256      * noun                                      -> Pull;
257  Verb 'push' 'clear' 'move' 'press' 'shift'
258      * noun                                      -> Push
259      * noun noun                                 -> PushDir
260      * noun 'to' noun                            -> Transfer;
261  Verb 'put'
262      * multiexcept 'in'/'inside'/'into' noun     -> Insert
263      * multiexcept 'on'/'onto' noun              -> PutOn
264      * 'on' held                                 -> Wear
265      * 'down' multiheld                          -> Drop
266      * multiheld 'down'                          -> Drop;
267  Verb 'read'
268      * noun                                      -> Examine
269      * 'about' topic 'in' noun                   -> Consult
270      * topic 'in' noun                           -> Consult;
271  Verb 'remove'
272      * held                                      -> Disrobe
273      * multi                                     -> Take
274      * multiinside 'from' noun                   -> Remove;
275  Verb 'rub' 'clean' 'dust' 'polish' 'scrub'
276       'shine' 'sweep' 'wipe'
277      * noun                                      -> Rub;
278  Verb 'search'
279      * noun                                      -> Search;
280  Verb 'set' 'adjust'
281      * noun                                      -> Set
282      * noun 'to' special                         -> SetTo;
283  Verb 'shed' 'disrobe' 'doff'
284      * held                                      -> Disrobe;
285  Verb 'show' 'display' 'present'
286      * creature held                             -> Show reverse
287      * held 'to' creature                        -> Show;
288  Verb 'shit' 'damn' 'fuck' 'sod'
289      *                                           -> Strong
290      * topic                                     -> Strong;
291  Verb 'sing'
292      *                                           -> Sing;
293  Verb 'sit' 'lie'
294      * 'on' 'top' 'of' noun                      -> Enter
295      * 'on'/'in'/'inside' noun                   -> Enter;
296  Verb 'sleep' 'nap'
297      *                                           -> Sleep;
298  Verb 'smell' 'sniff'
299      *                                           -> Smell
300      * noun                                      -> Smell;
301  Verb 'sorry'
302      *                                           -> Sorry;
303  Verb 'squeeze' 'squash'
304      * noun                                      -> Squeeze;
305  Verb 'stand'
306      *                                           -> Exit
307      * 'up'                                      -> Exit
308      * 'on' noun                                 -> Enter;
309  Verb 'swim' 'dive'
310      *                                           -> Swim;
311  Verb 'swing'
312      * noun                                      -> Swing
313      * 'on' noun                                 -> Swing;
314  Verb 'switch'
315      * noun                                      -> Switchon
316      * noun 'on'                                 -> Switchon
317      * noun 'off'                                -> Switchoff
318      * 'on' noun                                 -> Switchon
319      * 'off' noun                                -> Switchoff;
320  Verb 'take' 'carry' 'hold'
321      * multi                                     -> Take
322      * 'off' worn                                -> Disrobe
323      * multiinside 'from' noun                   -> Remove
324      * multiinside 'off' noun                    -> Remove
325      * 'inventory'                               -> Inv;
326  Verb 'taste'
327      * noun                                      -> Taste;
328  Verb 'tell'
329      * creature 'about' topic                    -> Tell
330      * creature 'to' topic                       -> AskTo;
331  Verb 'think'
332      *                                           -> Think;
333  Verb 'tie' 'attach' 'fasten' 'fix'
334      * noun                                      -> Tie
335      * noun 'to' noun                            -> Tie;
336  Verb 'touch' 'feel' 'fondle' 'grope'
337      * noun                                      -> Touch;
338  Verb 'transfer'
339      * noun 'to' noun                            -> Transfer;
340  Verb 'turn' 'rotate' 'screw' 'twist' 'unscrew'
341      * noun                                      -> Turn
342      * noun 'on'                                 -> Switchon
343      * noun 'off'                                -> Switchoff
344      * 'on' noun                                 -> Switchon
345      * 'off' noun                                -> Switchoff;
346  Verb 'wave'
347      *                                           -> WaveHands
348      * noun                                      -> Wave;
349  Verb 'wear' 'don'
350      * held                                      -> Wear;
351  Verb 'yes' 'y//'
352      *                                           -> Yes;
353  Verb 'unlock'
354      * noun 'with' held                          -> Unlock;
355  Verb 'wait' 'z//'
356      *                                           -> Wait;
357  Verb 'wake' 'awake' 'awaken'
358      *                                           -> Wake
359      * 'up'                                      -> Wake
360      * creature                                  -> WakeOther
361      * creature 'up'                             -> WakeOther
362      * 'up' creature                             -> WakeOther;
363   
364  ! ------------------------------------------------------------------------------
365  !  This routine is no longer used here, but provided to help existing games
366  !  which use it as a general parsing routine:
367   
368  [ ConTopic w;
369      consult_from = wn;
370      do w = NextWordStopped();
371      until (w == -1 || (w == 'to' && action_to_be == ##Answer));
372      wn--;
373      consult_words = wn - consult_from;
374      if (consult_words == 0) return -1;
375      if (action_to_be == ##Answer or ##Ask or ##Tell) {
376          w = wn; wn = consult_from; parsed_number = NextWord();
377          if (parsed_number == 'the' && consult_words > 1) parsed_number = NextWord();
378          wn = w;
379          return 1;
380      }
381      return 0;
382  ];
383   
384  ! ------------------------------------------------------------------------------
385  !  Final task: provide trivial routines if the user hasn't already:
386  ! ------------------------------------------------------------------------------
387   
388  #Stub AfterLife         0;
389  #Stub AfterPrompt       0;
390  #Stub Amusing           0;
391  #Stub BeforeParsing     0;
392  #Stub ChooseObjects     2;
393  #Stub DarkToDark        0;
394  #Stub DeathMessage      0;
395  #Stub GamePostRoutine   0;
396  #Stub GamePreRoutine    0;
397  #Stub InScope           1;
398  #Stub LookRoutine       0;
399  #Stub NewRoom           0;
400  #Stub ParseNumber       2;
401  #Stub ParserError       1;
402  #Stub PrintTaskName     1;
403  #Stub PrintVerb         1;
404  #Stub TimePasses        0;
405  #Stub UnknownVerb       1;
406   
407  #Ifdef TARGET_GLULX;
408  #Stub HandleGlkEvent    2;
409  #Stub IdentifyGlkObject 4;
410  #Stub InitGlkWindow     1;
411  #Endif; ! TARGET_GLULX
412   
413  #Ifndef PrintRank;
414  ! Constant Make__PR;
415  ! #Endif;
416  ! #Ifdef Make__PR;
417  [ PrintRank; "."; ];
418  #Endif;
419   
420  #Ifndef ParseNoun;
421  ! Constant Make__PN;
422  ! #Endif;
423  ! #Ifdef Make__PN;
424  [ ParseNoun obj; obj = obj; return -1; ];
425  #Endif;
426   
427  #Default Story 0;
428  #Default Headline 0;
429   
430  #Ifdef INFIX;
431  #Include "infix";
432  #Endif;
433   
434  ! ==============================================================================
435   
436  Constant LIBRARY_GRAMMAR;       ! for dependency checking
437   
438  ! ==============================================================================


Last updated 27 February 2004. The librarian in charge of this page is Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight. Please email any comments, suggestions or corrections to cedenqs@inform-fiction.org.