grammar.h 20 KB

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