Warning: Undefined variable $mode in /var/www/virtual/qbnz.com/htdocs/highlighter/examples/ada/small.php on line 6
GeSHi - Generic Syntax Highlighter :: Examples
 
Navigation
Home News Examples Demo Downloads FAQ Documentation Mailing Lists License
Support GeSHi!
If you're using GeSHi, why not help GeSHi out? You can link to GeSHi with this image:
Powered by GeSHi
Get the HTML

Project Status
The latest stable version of GeSHi is 1.0.8.11, released on the 19th of Aug, 2012.

Supported Languages:
*ABAP
*Actionscript
*ADA
*Apache Log
*AppleScript
*APT sources.list
*ASM (m68k)
*ASM (pic16)
*ASM (x86)
*ASM (z80)
*ASP
*AutoIT
*Backus-Naur form
*Bash
*Basic4GL
*BlitzBasic
*Brainfuck
*C
*C for Macs
*C#
*C++
*C++ (with QT)
*CAD DCL
*CadLisp
*CFDG
*CIL / MSIL
*COBOL
*ColdFusion
*CSS
*D
*Delphi
*Diff File Format
*DIV
*DOS
*DOT language
*Eiffel
*Fortran
*FourJ's Genero
*FreeBasic
*GetText
*glSlang
*GML
*gnuplot
*Groovy
*Haskell
*HQ9+
*HTML
*INI (Config Files)
*Inno
*INTERCAL
*IO
*Java
*Java 5
*Javascript
*KiXtart
*KLone C & C++
*LaTeX
*Lisp
*LOLcode
*LotusScript
*LScript
*Lua
*Make
*mIRC
*MXML
*MySQL
*NSIS
*Objective C
*OCaml
*OpenOffice BASIC
*Oracle 8 & 11 SQL
*Pascal
*Perl
*PHP
*Pixel Bender
*PL/SQL
*POV-Ray
*PowerShell
*Progress (OpenEdge ABL)
*Prolog
*ProvideX
*Python
*Q(uick)BASIC
*robots.txt
*Ruby
*Ruby on Rails
*SAS
*Scala
*Scheme
*Scilab
*SDLBasic
*Smalltalk
*Smarty
*SQL
*T-SQL
*TCL
*thinBasic
*TypoScript
*Uno IDL
*VB.NET
*Verilog
*VHDL
*VIM Script
*Visual BASIC
*Visual Fox Pro
*Visual Prolog
*Whitespace
*Winbatch
*Windows Registry Files
*X++
*XML
*Xorg.conf

GeSHi 1.0.8.11 is the current stable release, with eighteen new languages and bug fixes over the last release.

GeSHi 1.1.2alpha5 is the current latest version from the development branch, with full C support (see the GeSHi development website).
Subscribe
RSS 2
Mailing Lists
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense 
5:27 am GMT

Examples

Examples » Ada
  1. --
  2. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  3. -- Author: David A. Wheeler
  4. --
  5.  
  6. with Occupants;
  7. use Occupants;
  8.  
  9. package Creatures is
  10. type Creature is abstract new Occupant with private;
  11. type Creature_Access is access Creature'Class;
  12. private
  13. type Creature is abstract new Occupant with null record;
  14. end Creatures;
  15.  
  16. --
  17. -- Permission to use, copy, modify, and distribute this software and its
  18. -- documentation for any purpose and without fee is hereby granted,
  19. -- provided that the above copyright and authorship notice appear in all
  20. -- copies and that both that copyright notice and this permission notice
  21. -- appear in supporting documentation.
  22. --
  23. -- The ARA makes no representations about the suitability of this software
  24. -- for any purpose. It is provided "as is" without express
  25. -- or implied warranty.
  26. --
  27. --
  28. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  29. -- Author: David A. Wheeler
  30. --
  31.  
  32. with Ada.Characters.Handling;
  33. use Ada.Characters.Handling;
  34.  
  35. package body Directions is
  36.  
  37. Abbreviations : constant String := "nsewud";
  38.  
  39. procedure To_Direction(Text : in Unbounded_String;
  40. Is_Direction : out Boolean;
  41. Dir : out Direction) is
  42. Lower_Text : String := To_Lower(To_String(Text));
  43. -- Attempt to turn "Text" into a direction.
  44. -- If successful, set "Is_Direction" True and "Dir" to the value.
  45. -- If not successful, set "Is_Direction" False and "Dir" to arbitrary value.
  46. begin
  47. if Length(Text) = 1 then
  48. -- Check if it's a one-letter abbreviation.
  49. for D in Direction'Range loop
  50. if Lower_Text(1) = Abbreviations(Direction'Pos(D) + 1) then
  51. Is_Direction := True;
  52. Dir := D;
  53. return;
  54. end if;
  55. end loop;
  56. Is_Direction := False;
  57. Dir := North;
  58. return;
  59.  
  60. else
  61. -- Not a one-letter abbreviation, try a full name.
  62. for D in Direction'Range loop
  63. if Lower_Text = To_Lower(Direction'Image(D)) then
  64. Is_Direction := True;
  65. Dir := D;
  66. return;
  67. end if;
  68. end loop;
  69. Is_Direction := False;
  70. Dir := North;
  71. return;
  72. end if;
  73. end To_Direction;
  74.  
  75. function To_Direction(Text : in Unbounded_String) return Direction is
  76. Is_Direction : Boolean;
  77. Dir : Direction;
  78. begin
  79. To_Direction(Text, Is_Direction, Dir);
  80. if Is_Direction then
  81. return Dir;
  82. else
  83. raise Constraint_Error;
  84. end if;
  85. end To_Direction;
  86.  
  87. function Is_Direction(Text : in Unbounded_String) return Boolean is
  88. Is_Direction : Boolean;
  89. Dir : Direction;
  90. begin
  91. To_Direction(Text, Is_Direction, Dir);
  92. return Is_Direction;
  93. end Is_Direction;
  94.  
  95. end Directions;
  96.  
  97. --
  98. -- Permission to use, copy, modify, and distribute this software and its
  99. -- documentation for any purpose and without fee is hereby granted,
  100. -- provided that the above copyright and authorship notice appear in all
  101. -- copies and that both that copyright notice and this permission notice
  102. -- appear in supporting documentation.
  103. --
  104. -- The ARA makes no representations about the suitability of this software
  105. -- for any purpose. It is provided "as is" without express
  106. -- or implied warranty.
  107. --
  108. --
  109. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  110. -- Author: David A. Wheeler
  111. --
  112.  
  113. with Ada.Strings.Unbounded;
  114. use Ada.Strings.Unbounded;
  115.  
  116. package Directions is
  117.  
  118. type Direction is (North, South, East, West, Up, Down);
  119.  
  120. Reverse_Direction : constant array(Direction) of Direction :=
  121. (North => South, South => North,
  122. East =>West, West => East,
  123. Up => Down, Down => Up);
  124.  
  125. function To_Direction(Text : Unbounded_String) return Direction;
  126. -- Converts Text to Direction; raises Constraint_Error if it's not
  127. -- a legal direction.
  128.  
  129. function Is_Direction(Text : Unbounded_String) return Boolean;
  130. -- Returns TRUE if Text is a direction, else false.
  131.  
  132. end Directions;
  133.  
  134. --
  135. -- Permission to use, copy, modify, and distribute this software and its
  136. -- documentation for any purpose and without fee is hereby granted,
  137. -- provided that the above copyright and authorship notice appear in all
  138. -- copies and that both that copyright notice and this permission notice
  139. -- appear in supporting documentation.
  140. --
  141. -- The ARA makes no representations about the suitability of this software
  142. -- for any purpose. It is provided "as is" without express
  143. -- or implied warranty.
  144. --
  145. --
  146. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  147. -- Author: David A. Wheeler
  148. --
  149.  
  150. package body Items is
  151.  
  152. function May_I_Get(Direct_Object : access Item;
  153. Agent : access Occupant'Class) return Boolean is
  154. begin
  155. return True;
  156. end May_I_Get;
  157.  
  158. end Items;
  159.  
  160. --
  161. -- Permission to use, copy, modify, and distribute this software and its
  162. -- documentation for any purpose and without fee is hereby granted,
  163. -- provided that the above copyright and authorship notice appear in all
  164. -- copies and that both that copyright notice and this permission notice
  165. -- appear in supporting documentation.
  166. --
  167. -- The ARA makes no representations about the suitability of this software
  168. -- for any purpose. It is provided "as is" without express
  169. -- or implied warranty.
  170. --
  171. --
  172. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  173. -- Author: David A. Wheeler
  174. --
  175.  
  176. with Occupants;
  177. use Occupants;
  178.  
  179. package Items is
  180. type Item is new Occupant with private;
  181. type Item_Access is access Item'Class;
  182. function May_I_Get(Direct_Object : access Item;
  183. Agent : access Occupant'Class) return Boolean;
  184.  
  185. private
  186. type Item is new Occupant with null record;
  187.  
  188. end Items;
  189.  
  190. --
  191. -- Permission to use, copy, modify, and distribute this software and its
  192. -- documentation for any purpose and without fee is hereby granted,
  193. -- provided that the above copyright and authorship notice appear in all
  194. -- copies and that both that copyright notice and this permission notice
  195. -- appear in supporting documentation.
  196. --
  197. -- The ARA makes no representations about the suitability of this software
  198. -- for any purpose. It is provided "as is" without express
  199. -- or implied warranty.
  200. --
  201. --
  202. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  203. -- Author: David A. Wheeler
  204. --
  205.  
  206. with Creatures;
  207. use Creatures;
  208.  
  209. package Monsters is
  210. type Monster is new Creature with private;
  211. type Monster_Access is access Monster'Class;
  212. private
  213. type Monster is new Creature with null record;
  214. end Monsters;
  215.  
  216. --
  217. -- Permission to use, copy, modify, and distribute this software and its
  218. -- documentation for any purpose and without fee is hereby granted,
  219. -- provided that the above copyright and authorship notice appear in all
  220. -- copies and that both that copyright notice and this permission notice
  221. -- appear in supporting documentation.
  222. --
  223. -- The ARA makes no representations about the suitability of this software
  224. -- for any purpose. It is provided "as is" without express
  225. -- or implied warranty.
  226. --
  227. --
  228. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  229. -- Author: David A. Wheeler
  230. --
  231.  
  232. with Text_IO, Ada.Strings.Unbounded, Ustrings, Rooms;
  233. use Text_IO, Ada.Strings.Unbounded, Ustrings, Rooms;
  234.  
  235. package body Occupants is
  236.  
  237.  
  238. procedure Put_View(T : access Occupant; Agent : access Thing'Class) is
  239. begin
  240. Put("You are inside ");
  241. Put_Line(Short_Description(T));
  242. Put_Line(".");
  243. Put_Contents(T, Agent, "You see:");
  244. end Put_View;
  245.  
  246. procedure Look(T : access Occupant) is
  247. -- T is running a "look" command; tell T what he views.
  248. begin
  249. if Container(T) = null then
  250. Put("You are inside nothing at all.");
  251. else
  252. Put_View(Container(T), T);
  253. end if;
  254. end Look;
  255.  
  256.  
  257. procedure Get(Agent : access Occupant; Direct_Object : access Occupant'Class)
  258. is
  259. begin
  260. if May_I_Get(Direct_Object, Agent) then
  261. Place(T => Direct_Object, Into => Thing_Access(Agent));
  262. end if;
  263. end Get;
  264.  
  265. function May_I_Get(Direct_Object : access Occupant;
  266. Agent : access Occupant'Class)
  267. return Boolean is
  268. begin
  269. Sorry("get", Name(Direct_Object)); -- Tell the getter sorry, can't get it
  270. return False;
  271. end May_I_Get;
  272.  
  273. procedure Drop(Agent : access Occupant;
  274. Direct_Object : access Occupant'Class) is
  275. begin
  276. if May_I_Drop(Direct_Object, Agent) then
  277. Place(T => Direct_Object, Into => Container(Agent));
  278. end if;
  279. end Drop;
  280.  
  281. function May_I_Drop(Direct_Object : access Occupant;
  282. Agent : access Occupant'Class)
  283. return Boolean is
  284. begin
  285. return True;
  286. end May_I_Drop;
  287.  
  288.  
  289. procedure Inventory(Agent : access Occupant) is
  290. begin
  291. Put_Contents(Agent, Agent,
  292. "You're carrying:",
  293. "You aren't carrying anything.");
  294. end Inventory;
  295.  
  296. procedure Go(Agent : access Occupant; Dir : in Direction) is
  297. begin
  298. if Container(Agent) = null then
  299. Put_Line("Sorry, you're not in a room!");
  300. else
  301. declare
  302. Destination : Thing_Access := What_Is(Container(Agent), Dir);
  303. begin
  304. if Destination = null then
  305. Put_Line("Sorry, you can't go that way.");
  306. else
  307. Place(Agent, Destination);
  308. end if;
  309. end;
  310. end if;
  311. end Go;
  312.  
  313. end Occupants;
  314.  
  315. --
  316. -- Permission to use, copy, modify, and distribute this software and its
  317. -- documentation for any purpose and without fee is hereby granted,
  318. -- provided that the above copyright and authorship notice appear in all
  319. -- copies and that both that copyright notice and this permission notice
  320. -- appear in supporting documentation.
  321. --
  322. -- The ARA makes no representations about the suitability of this software
  323. -- for any purpose. It is provided "as is" without express
  324. -- or implied warranty.
  325. --
  326. --
  327. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  328. -- Author: David A. Wheeler
  329. --
  330.  
  331. with Things, Directions;
  332. use Things, Directions;
  333.  
  334. package Occupants is
  335.  
  336. -- An "Occupant" is a Thing that can be inside a Room or another Occupant.
  337.  
  338. type Occupant is abstract new Thing with private;
  339. type Occupant_Access is access all Occupant'Class;
  340.  
  341. -- Dispatching subprograms:
  342.  
  343. procedure Look(T : access Occupant); -- Ask Occupant T to "look".
  344.  
  345. procedure Get(Agent : access Occupant; Direct_Object : access Occupant'Class);
  346. -- Ask Agent to get Direct_Object. This assumes that Agent can
  347. -- somehow access Direct_Object (i.e. is in the same room).
  348. -- If the agent decides that it can get the object, it will
  349. -- call May_I_Get to ask the object if that's okay.
  350.  
  351. procedure Drop(Agent : access Occupant; Direct_Object : access Occupant'Class);
  352. -- Ask Agent to drop Direct_Object.
  353.  
  354. procedure Inventory(Agent : access Occupant);
  355. -- Ask Agent to print a list of what Agent is carrying.
  356.  
  357. procedure Go(Agent : access Occupant; Dir : in Direction);
  358. -- Ask Agent to go the given Direction Dir (North, South, etc.)
  359.  
  360. procedure Put_View(T : access Occupant; Agent : access Thing'Class);
  361. -- Override Thing's Put_View.
  362.  
  363. function May_I_Get(Direct_Object : access Occupant;
  364. Agent : access Occupant'Class) return Boolean;
  365. -- Ask Direct_Object if "Agent" can get this object.
  366. -- Returns True if it's okay, else False.
  367. -- If the object does something while being gotten (or an attempt
  368. -- to do so) it does it in this call.
  369.  
  370. function May_I_Drop(Direct_Object : access Occupant;
  371. Agent : access Occupant'Class) return Boolean;
  372. -- Ask Direct_Object if "Agent" can drop this object;
  373. -- returns True if it's okay.
  374.  
  375. private
  376.  
  377. type Occupant is abstract new Thing with
  378. record
  379. null; -- Nothing here for now.
  380. end record;
  381.  
  382. end Occupants;
  383.  
  384. --
  385. -- Permission to use, copy, modify, and distribute this software and its
  386. -- documentation for any purpose and without fee is hereby granted,
  387. -- provided that the above copyright and authorship notice appear in all
  388. -- copies and that both that copyright notice and this permission notice
  389. -- appear in supporting documentation.
  390. --
  391. -- The ARA makes no representations about the suitability of this software
  392. -- for any purpose. It is provided "as is" without express
  393. -- or implied warranty.
  394. --
  395. --
  396. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  397. -- Author: David A. Wheeler
  398. --
  399.  
  400. with Text_IO, Ada.Strings.Maps.Constants, Ustrings, Things, Occupants, World;
  401. use Text_IO, Ada.Strings.Maps.Constants, Ustrings, Things, Occupants, World;
  402. use Ada.Strings, Ada.Strings.Maps;
  403.  
  404. with Directions;
  405. use Directions;
  406.  
  407. package body Parser is
  408.  
  409. Spaces : constant Character_Set := To_Set(' ');
  410.  
  411. procedure Split(Source : in Unbounded_String;
  412. First_Word : out Unbounded_String;
  413. Rest : out Unbounded_String) is
  414. First : Positive; -- Index values of first word.
  415. Last : Natural;
  416. -- Puts first word of Source into First_Word, the rest of the words in Rest
  417. -- (without leading spaces); words are separated by one or more spaces;
  418. -- if there are no spaces, Rest returns empty.
  419. begin
  420. Find_Token(Source, Spaces, Outside, First, Last);
  421. First_Word := U(Slice(Source, First, Last));
  422. Rest := Trim(U(Slice(Source, Last + 1, Length(Source))), Left);
  423. end Split;
  424.  
  425.  
  426.  
  427. procedure Execute(Command : in Unbounded_String; Quit : out Boolean) is
  428. Trimmed_Command : Unbounded_String := Trim(Command, Both);
  429. Verb, Arguments, First_Argument, Rest_Of_Arguments : Unbounded_String;
  430. Direct_Object : Occupant_Access;
  431. begin
  432. Quit := False; -- By default assume we won't quit.
  433. if (Empty(Trimmed_Command)) then
  434. return; -- Ignore blank lines.
  435. end if;
  436.  
  437. -- Extract Verb and First_Argument and force them to lower case.
  438. Split(Trimmed_Command, Verb, Arguments);
  439. Translate(Verb, Lower_Case_Map);
  440. Split(Arguments, First_Argument, Rest_Of_Arguments);
  441. Translate(First_Argument, Lower_Case_Map);
  442.  
  443.  
  444. -- Try to execute "Verb".
  445.  
  446. if Verb = "look" then
  447. Look(Me);
  448. elsif Verb = "get" then
  449. Direct_Object := Occupant_Access(Find(Me, First_Argument));
  450. if Direct_Object /= null then
  451. Get(Me, Direct_Object);
  452. end if;
  453. elsif Verb = "drop" then
  454. Direct_Object := Occupant_Access(Find_Inside(Me, First_Argument));
  455. if Direct_Object /= null then
  456. Drop(Me, Direct_Object);
  457. end if;
  458. elsif Verb = "inventory" or Verb = "inv" then
  459. Inventory(Me);
  460. elsif Verb = "quit" then
  461. Quit := True;
  462. elsif Verb = "go" and then Is_Direction(First_Argument) then
  463. Go(Me, To_Direction(First_Argument));
  464. Look(Me);
  465. elsif Is_Direction(Verb) then -- Is the verb a direction (north, etc)?
  466. Go(Me, To_Direction(Verb));
  467. Look(Me);
  468. elsif Verb = "help" then
  469. Put_Line("Please type in one or two word commands, beginning with a verb");
  470. Put_Line("or direction. Directions are north, south, east, west, etc.");
  471. Put_Line("Here are some sample commands:");
  472. Put_Line("look, get box, drop box, inventory, go west, west, w, quit.");
  473. else
  474. Put_Line("Sorry, I don't recognize that verb. Try 'help'.");
  475. end if;
  476.  
  477. end Execute;
  478. end Parser;
  479.  
  480. --
  481. -- Permission to use, copy, modify, and distribute this software and its
  482. -- documentation for any purpose and without fee is hereby granted,
  483. -- provided that the above copyright and authorship notice appear in all
  484. -- copies and that both that copyright notice and this permission notice
  485. -- appear in supporting documentation.
  486. --
  487. -- The ARA makes no representations about the suitability of this software
  488. -- for any purpose. It is provided "as is" without express
  489. -- or implied warranty.
  490. --
  491. --
  492. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  493. -- Author: David A. Wheeler
  494. --
  495.  
  496. with Ada.Strings.Unbounded;
  497. use Ada.Strings.Unbounded;
  498.  
  499. package Parser is
  500. procedure Execute(Command : in Unbounded_String; Quit : out Boolean);
  501. -- Executes the given command.
  502. -- Sets Quit to False if the user may run additional commands.
  503. end Parser;
  504.  
  505. --
  506. -- Permission to use, copy, modify, and distribute this software and its
  507. -- documentation for any purpose and without fee is hereby granted,
  508. -- provided that the above copyright and authorship notice appear in all
  509. -- copies and that both that copyright notice and this permission notice
  510. -- appear in supporting documentation.
  511. --
  512. -- The ARA makes no representations about the suitability of this software
  513. -- for any purpose. It is provided "as is" without express
  514. -- or implied warranty.
  515. --
  516. --
  517. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  518. -- Author: David A. Wheeler
  519. --
  520.  
  521. with Creatures;
  522. use Creatures;
  523.  
  524. package Players is
  525. type Player is new Creature with private;
  526. type Player_Access is access Player'Class;
  527. private
  528. type Player is new Creature with null record;
  529. end Players;
  530.  
  531. --
  532. -- Permission to use, copy, modify, and distribute this software and its
  533. -- documentation for any purpose and without fee is hereby granted,
  534. -- provided that the above copyright and authorship notice appear in all
  535. -- copies and that both that copyright notice and this permission notice
  536. -- appear in supporting documentation.
  537. --
  538. -- The ARA makes no representations about the suitability of this software
  539. -- for any purpose. It is provided "as is" without express
  540. -- or implied warranty.
  541. --
  542. --
  543. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  544. -- Author: David A. Wheeler
  545. --
  546.  
  547. with Text_IO, Ustrings;
  548. use Text_IO, Ustrings;
  549.  
  550. package body Rooms is
  551.  
  552. procedure Connect(Source : access Room; Dir : in Direction;
  553. Destination : access Thing'Class;
  554. Bidirectional : in Boolean := True) is
  555. begin
  556. Source.Destinations(Dir) := Thing_Access(Destination);
  557. if Bidirectional then -- Connect in reverse direction.
  558. Room_Access(Destination).Destinations(Reverse_Direction(Dir)) :=
  559. Thing_Access(Source);
  560. end if;
  561. end Connect;
  562.  
  563. procedure Disconnect(Source : access Room; Dir : in Direction;
  564. Bidirectional : in Boolean := True) is
  565. begin
  566. if Bidirectional then
  567. -- If it's bidirectional, remove the other direction. The following "if"
  568. -- statement, if uncommented, checks to make sure that
  569. -- disconnecting a bidirectional link only happens to a Room.
  570. -- if (Source.Destinations(Dir).all'Tag in Room'Class) then
  571. Room_Access(Source.Destinations(Dir)).
  572. Destinations(Reverse_Direction(Dir)) := null;
  573. -- end if;
  574. end if;
  575. Source.Destinations(Dir) := null;
  576. end Disconnect;
  577.  
  578. function What_Is(From : access Room; Dir : in Direction) return Thing_Access is
  579. begin
  580. return From.Destinations(Dir);
  581. end What_Is;
  582.  
  583. procedure Put_View(T : access Room; Agent : access Thing'Class) is
  584. begin
  585. Put("You are ");
  586. Put(Long_Description(T));
  587. Put_Line(".");
  588. Put_Contents(T, Agent, "You see:");
  589. end Put_View;
  590.  
  591. end Rooms;
  592.  
  593. --
  594. -- Permission to use, copy, modify, and distribute this software and its
  595. -- documentation for any purpose and without fee is hereby granted,
  596. -- provided that the above copyright and authorship notice appear in all
  597. -- copies and that both that copyright notice and this permission notice
  598. -- appear in supporting documentation.
  599. --
  600. -- The ARA makes no representations about the suitability of this software
  601. -- for any purpose. It is provided "as is" without express
  602. -- or implied warranty.
  603. --
  604. --
  605. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  606. -- Author: David A. Wheeler
  607. --
  608.  
  609. with Things, Directions;
  610. use Things, Directions;
  611.  
  612. package Rooms is
  613. type Room is new Thing with private;
  614. type Room_Access is access all Room'Class;
  615.  
  616. procedure Put_View(T : access Room; Agent : access Thing'Class);
  617.  
  618. procedure Connect(Source : access Room; Dir : in Direction;
  619. Destination : access Thing'Class;
  620. Bidirectional : in Boolean := True);
  621. -- Create a connection from Source to Destination in Direction Dir.
  622. -- If it's bidirectional, create another connection the reverse way.
  623.  
  624. procedure Disconnect(Source : access Room; Dir : in Direction;
  625. Bidirectional : in Boolean := True);
  626. -- Reverse of connect; disconnects an existing connection, if any.
  627.  
  628. function What_Is(From : access Room; Dir : in Direction) return Thing_Access;
  629. -- Returns what is at direction "Dir" from "From".
  630. -- Returns null if nothing connected in that direction.
  631.  
  632. private
  633.  
  634. type Destination_Array is array(Direction) of Thing_Access;
  635.  
  636. type Room is new Thing with
  637. record
  638. Destinations : Destination_Array;
  639. end record;
  640.  
  641. end Rooms;
  642.  
  643. --
  644. -- Permission to use, copy, modify, and distribute this software and its
  645. -- documentation for any purpose and without fee is hereby granted,
  646. -- provided that the above copyright and authorship notice appear in all
  647. -- copies and that both that copyright notice and this permission notice
  648. -- appear in supporting documentation.
  649. --
  650. -- The ARA makes no representations about the suitability of this software
  651. -- for any purpose. It is provided "as is" without express
  652. -- or implied warranty.
  653. --
  654.  
  655. -- Main routine to start up "Small", a small text adventure game to
  656. -- demonstrate Ada 95.
  657.  
  658. --
  659. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  660. -- Author: David A. Wheeler
  661. --
  662.  
  663. -- For documentation see the following URL:
  664. -- http://www.adahome.com//Tutorials/Lovelace/small.htm
  665.  
  666. with Text_IO, Ada.Strings.Unbounded, Ustrings, World;
  667. use Text_IO, Ada.Strings.Unbounded, Ustrings;
  668.  
  669. with Parser;
  670.  
  671. procedure Small is
  672. Command : Unbounded_String; -- Contains user's current command.
  673. Quit : Boolean := False;
  674. begin
  675. Put_Line("Welcome to a Small World!");
  676.  
  677. World.Setup;
  678.  
  679. while not Quit loop
  680. New_Line;
  681. Put_Line("Your Command?");
  682. Get_Line(Command);
  683. Parser.Execute(Command, Quit);
  684. end loop;
  685.  
  686. Put_Line("Bye!");
  687. end Small;
  688.  
  689. --
  690. -- Permission to use, copy, modify, and distribute this software and its
  691. -- documentation for any purpose and without fee is hereby granted,
  692. -- provided that the above copyright and authorship notice appear in all
  693. -- copies and that both that copyright notice and this permission notice
  694. -- appear in supporting documentation.
  695. --
  696. -- The ARA makes no representations about the suitability of this software
  697. -- for any purpose. It is provided "as is" without express
  698. -- or implied warranty.
  699. --
  700. --
  701. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  702. -- Author: David A. Wheeler
  703. --
  704.  
  705. with Text_IO, Ustrings;
  706. use Text_IO, Ustrings;
  707.  
  708.  
  709. package body Things is
  710.  
  711. -- Define basic types for the world and their operations.
  712.  
  713.  
  714. -- Supporting Subprograms:
  715.  
  716. procedure Sorry(Prohibited_Operation : String;
  717. Prohibited_Direct_Object : Unbounded_String) is
  718. begin
  719. Put_Line("Sorry, you may not " & Prohibited_Operation & " the " &
  720. S(Prohibited_Direct_Object));
  721. end Sorry;
  722.  
  723.  
  724. -- Routines to manipulate First_Containee, Next_Sibling, Container:
  725.  
  726. function Previous_Sibling(Containee : access Thing'Class)
  727. return Thing_Access is
  728. -- Find the previous sibling of containee. It's an error to call
  729. -- this if Containee has no previous sibling.
  730. Current : Thing_Access := Containee.Container.First_Containee;
  731. begin
  732. while Current.Next_Sibling /= Thing_Access(Containee) loop
  733. Current := Current.Next_Sibling;
  734. end loop;
  735. return Current;
  736. end Previous_Sibling;
  737.  
  738. function Last_Containee(Container : access Thing'Class)
  739. return Thing_Access is
  740. -- Return an access value of the last contained Thing in container.
  741. -- It's an error to call this routine if there are no containees.
  742. Current : Thing_Access := Container.First_Containee;
  743. begin
  744. while Current.Next_Sibling /= null loop
  745. Current := Current.Next_Sibling;
  746. end loop;
  747. return Current;
  748. end Last_Containee;
  749.  
  750. procedure Remove(Containee : access Thing'Class) is
  751. -- Remove Containee from its current Container.
  752. Previous_Thing : Thing_Access;
  753. begin
  754. if Containee.Container /= null then
  755. if Containee.Container.First_Containee = Thing_Access(Containee) then
  756. -- Containee is the first Thing in its container.
  757. Containee.Container.First_Containee := Containee.Next_Sibling;
  758. else
  759. Previous_Thing := Previous_Sibling(Containee);
  760. Previous_Thing.Next_Sibling := Containee.Next_Sibling;
  761. end if;
  762. Containee.Next_Sibling := null;
  763. Containee.Container := null;
  764. end if;
  765. end Remove;
  766.  
  767.  
  768. procedure Place(T : access Thing'Class; Into : Thing_Access) is
  769. -- Place "T" inside "Into".
  770. Last : Thing_Access;
  771. begin
  772. if (Thing_Access(T) = Into) then
  773. Put_Line("Sorry, that can't be done.");
  774. return;
  775. end if;
  776. Remove(T); -- Remove Thing from where it is now.
  777. if Into /= null then
  778. if Into.First_Containee = null then
  779. Into.First_Containee := Thing_Access(T);
  780. else
  781. Last := Last_Containee(Into);
  782. Last.all.Next_Sibling := Thing_Access(T);
  783. end if;
  784. end if;
  785. T.Container := Into;
  786. end Place;
  787.  
  788. procedure Put_Contents(T : access Thing'Class;
  789. Ignore : access Thing'Class;
  790. Heading_With_Contents : in String;
  791. Heading_Without_Contents : in String := "") is
  792. -- Put a description of the contents of T.
  793. -- If there is something, print Heading_With_Contents;
  794. -- If there isn't something, print Heading_Without_Contents.
  795. -- Ignore The_Player, since presumably the player already knows about
  796. -- him/herself.
  797. Current : Thing_Access := T.First_Containee;
  798. Have_Put_Something : Boolean := False;
  799. begin
  800. while Current /= null loop
  801. if Current /= Thing_Access(Ignore) then
  802. -- This what we're to ignore, print it out.
  803. if Have_Put_Something then
  804. Put(", ");
  805. else
  806. -- We're about to print the first item; print the heading.
  807. Put_Line(Heading_With_Contents);
  808. end if;
  809. Put(Short_Description(Current));
  810. Have_Put_Something := True;
  811. end if;
  812. Current := Current.Next_Sibling;
  813. end loop;
  814. if Have_Put_Something then
  815. Put_Line(".");
  816. elsif Heading_With_Contents'Length > 0 then
  817. Put_Line(Heading_Without_Contents);
  818. end if;
  819. end Put_Contents;
  820.  
  821.  
  822. -- Dispatching Operations:
  823.  
  824. function What_Is(From : access Thing; Dir : in Direction)
  825. return Thing_Access is
  826. begin
  827. return null; -- As a default, you can't go ANY direction from "here".
  828. end What_Is;
  829.  
  830.  
  831. -- Non-dispatching public operations:
  832.  
  833. procedure Set_Name(T : access Thing'Class; Article : in Article_Type;
  834. Name : in Unbounded_String) is
  835. begin
  836. T.Article := Article;
  837. T.Name := Name;
  838. end Set_Name;
  839.  
  840. procedure Set_Name(T : access Thing'Class; Article : in Article_Type;
  841. Name : in String) is
  842. begin
  843. T.Article := Article;
  844. T.Name := To_Unbounded_String(Name);
  845. end Set_Name;
  846.  
  847. function Name(T : access Thing'Class) return Unbounded_String is
  848. begin
  849. return T.Name;
  850. end Name;
  851.  
  852. procedure Set_Description(T : access Thing'Class;
  853. Description : in Unbounded_String) is
  854. begin
  855. T.Description := Description;
  856. end Set_Description;
  857.  
  858. procedure Set_Description(T : access Thing'Class;
  859. Description : in String) is
  860. begin
  861. T.Description := To_Unbounded_String(Description);
  862. end Set_Description;
  863.  
  864. function Long_Description(T : access Thing'Class) return Unbounded_String is
  865. begin
  866. return T.Description;
  867. end Long_Description;
  868.  
  869.  
  870. -- Eventually we'll use an array for the article, but a minor GNAT 2.7.0 bug
  871. -- will cause this to raise a Segmentation Fault when the program quits:
  872. -- Article_Text : constant array(Article_Type) of Unbounded_String :=
  873. -- (A => U("a "), An => U("an "), The => U("the "), Some => U("some "),
  874. -- None => U(""));
  875.  
  876. function Short_Description(T : access Thing'Class) return Unbounded_String is
  877. begin
  878. case T.Article is
  879. when A => return "a " & T.Name;
  880. when An => return "an " & T.Name;
  881. when The => return "the " & T.Name;
  882. when Some => return "some " & T.Name;
  883. when None => return T.Name;
  884. end case;
  885. -- Should become return Article_Text(T.Article) & T.Name;
  886. end Short_Description;
  887.  
  888. function Find(Agent : access Thing'Class;
  889. Object_Name : in Unbounded_String) return Thing_Access is
  890. begin
  891. if Agent.Container = null then
  892. Put_Line("You aren't in anything.");
  893. return null;
  894. else
  895. return Find_Inside(Agent.Container, Object_Name);
  896. end if;
  897. end Find;
  898.  
  899. function Find_Inside(Agent : access Thing'Class;
  900. Object_Name : in Unbounded_String)
  901. return Thing_Access is
  902. Current : Thing_Access := Agent.First_Containee;
  903. begin
  904. if Empty(Object_Name) then
  905. Put_Line("Sorry, you need to name an object.");
  906. return null;
  907. end if;
  908. while Current /= null loop
  909. if Current.Name = Object_Name then
  910. return Current;
  911. end if;
  912. Current := Current.Next_Sibling;
  913. end loop;
  914. Put("Sorry, I don't see a ");
  915. Put_Line(Object_Name);
  916. return null;
  917. end Find_Inside;
  918.  
  919. function Container(T : access Thing'Class) return Thing_Access is
  920. begin
  921. return T.Container;
  922. end Container;
  923.  
  924. function Has_Contents(T : access Thing'Class) return Boolean is
  925. begin
  926. if T.First_Containee = null then
  927. return False;
  928. else
  929. return True;
  930. end if;
  931. end Has_Contents;
  932.  
  933. end Things;
  934.  
  935. --
  936. -- Permission to use, copy, modify, and distribute this software and its
  937. -- documentation for any purpose and without fee is hereby granted,
  938. -- provided that the above copyright and authorship notice appear in all
  939. -- copies and that both that copyright notice and this permission notice
  940. -- appear in supporting documentation.
  941. --
  942. -- The ARA makes no representations about the suitability of this software
  943. -- for any purpose. It is provided "as is" without express
  944. -- or implied warranty.
  945. --
  946. --
  947. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  948. -- Author: David A. Wheeler
  949. --
  950.  
  951. with Ada.Strings.Unbounded, Ada.Finalization, Directions;
  952. use Ada.Strings.Unbounded, Ada.Finalization, Directions;
  953.  
  954. package Things is
  955.  
  956. -- "Thing" is the root class for all things in this small world.
  957. -- Rooms, Players, Items, and Monsters are derived from Thing.
  958.  
  959.  
  960. type Thing is abstract new Limited_Controlled with private;
  961. type Thing_Access is access all Thing'Class;
  962.  
  963. type Article_Type is (A, An, The, Some, None);
  964.  
  965. -- Public Dispatching operations.
  966.  
  967. procedure Put_View(T : access Thing; Agent : access Thing'Class) is abstract;
  968. -- Put what Agents sees inside T.
  969.  
  970. function What_Is(From : access Thing; Dir : in Direction) return Thing_Access;
  971. -- Returns what is at direction "Dir" from "From".
  972. -- Returns null if nothing connected in that direction.
  973.  
  974. -- Public non-Dispatching operations:
  975.  
  976. procedure Set_Name(T : access Thing'Class; Article : in Article_Type;
  977. Name : in Unbounded_String);
  978. procedure Set_Name(T : access Thing'Class; Article : in Article_Type;
  979. Name : in String);
  980. function Name(T : access Thing'Class) return Unbounded_String;
  981. pragma Inline(Name);
  982.  
  983. function Short_Description(T : access Thing'Class) return Unbounded_String;
  984. -- Returns Article + Name, i.e. "the box", "a car", "some horses".
  985.  
  986. procedure Set_Description(T : access Thing'Class;
  987. Description : in Unbounded_String);
  988. procedure Set_Description(T : access Thing'Class;
  989. Description : in String);
  990. function Long_Description(T : access Thing'Class) return Unbounded_String;
  991.  
  992. procedure Place(T : access Thing'Class; Into : Thing_Access);
  993. -- Place T inside "Into" (removing it from wherever it was).
  994. -- Attempting to place T into itself will print an error message
  995. -- and fail.
  996. -- The second parameter is Thing_Access, not Thing'Class, because
  997. -- "null" is a valid value for "Into".
  998. function Container(T : access Thing'Class) return Thing_Access;
  999. -- Return access value to the container of T.
  1000. function Has_Contents(T : access Thing'Class) return Boolean;
  1001. -- Does T have anything in it?
  1002.  
  1003. function Find(Agent : access Thing'Class;
  1004. Object_Name : in Unbounded_String) return Thing_Access;
  1005. -- Find the given Object_Name in the same container as the agent.
  1006. -- Prints and error message and returns null if not found.
  1007.  
  1008. function Find_Inside(Agent : access Thing'Class;
  1009. Object_Name : in Unbounded_String)
  1010. return Thing_Access;
  1011. -- Find the given Object_Name inside the agent.
  1012. -- Prints and error message and returns null if not found.
  1013.  
  1014. procedure Put_Contents(T : access Thing'Class;
  1015. Ignore : access Thing'Class;
  1016. Heading_With_Contents : in String;
  1017. Heading_Without_Contents : in String := "");
  1018. -- Put a description of the contents of T.
  1019. -- Act as though "Ignore" isn't there.
  1020. -- If there is something, print Heading_With_Contents;
  1021. -- If there isn't something, print Heading_Without_Contents.
  1022.  
  1023. procedure Sorry(Prohibited_Operation : String;
  1024. Prohibited_Direct_Object : Unbounded_String);
  1025. -- Put "Sorry, you may not XXX the YYY".
  1026.  
  1027.  
  1028. private
  1029.  
  1030. type Thing is abstract new Limited_Controlled with
  1031. record
  1032. Name, Description : Unbounded_String;
  1033. Article : Article_Type := A;
  1034. Container : Thing_Access; -- what Thing contains me?
  1035. Next_Sibling : Thing_Access; -- next Thing in my container.
  1036. First_Containee : Thing_Access; -- first Thing inside me.
  1037. end record;
  1038.  
  1039. end Things;
  1040.  
  1041. --
  1042. -- Permission to use, copy, modify, and distribute this software and its
  1043. -- documentation for any purpose and without fee is hereby granted,
  1044. -- provided that the above copyright and authorship notice appear in all
  1045. -- copies and that both that copyright notice and this permission notice
  1046. -- appear in supporting documentation.
  1047. --
  1048. -- The ARA makes no representations about the suitability of this software
  1049. -- for any purpose. It is provided "as is" without express
  1050. -- or implied warranty.
  1051. --
  1052. --
  1053. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  1054. -- Author: David A. Wheeler
  1055. --
  1056.  
  1057. package body Ustrings is
  1058.  
  1059. Input_Line_Buffer_Length : constant := 1024;
  1060. -- If an input line is longer, Get_Line will recurse to read in the line.
  1061.  
  1062.  
  1063. procedure Swap(Left, Right : in out Unbounded_String) is
  1064. -- Implement Swap. This is the portable but slow approach.
  1065. Temporary : Unbounded_String;
  1066. begin
  1067. Temporary := Left;
  1068. Left := Right;
  1069. Right := Temporary;
  1070. end Swap;
  1071.  
  1072. function Empty(S : Unbounded_String) return Boolean is
  1073. -- returns True if Length(S)=0.
  1074. begin
  1075. return (Length(S) = 0);
  1076. end Empty;
  1077.  
  1078.  
  1079. -- Implement Unbounded_String I/O by calling Text_IO String routines.
  1080.  
  1081.  
  1082. -- Get_Line gets a line of text, limited only by the maximum number of
  1083. -- characters in an Unbounded_String. It reads characters into a buffer
  1084. -- and if that isn't enough, recurses to read the rest.
  1085.  
  1086. procedure Get_Line (File : in File_Type; Item : out Unbounded_String) is
  1087.  
  1088. function More_Input return Unbounded_String is
  1089. Input : String (1 .. Input_Line_Buffer_Length);
  1090. Last : Natural;
  1091. begin
  1092. Get_Line (File, Input, Last);
  1093. if Last < Input'Last then
  1094. return To_Unbounded_String (Input(1..Last));
  1095. else
  1096. return To_Unbounded_String (Input(1..Last)) & More_Input;
  1097. end if;
  1098. end More_Input;
  1099.  
  1100. begin
  1101. Item := More_Input;
  1102. end Get_Line;
  1103.  
  1104.  
  1105. procedure Get_Line(Item : out Unbounded_String) is
  1106. begin
  1107. Get_Line(Current_Input, Item);
  1108. end Get_Line;
  1109.  
  1110. procedure Put(File : in File_Type; Item : in Unbounded_String) is
  1111. begin
  1112. Put(File, To_String(Item));
  1113. end Put;
  1114.  
  1115. procedure Put(Item : in Unbounded_String) is
  1116. begin
  1117. Put(Current_Output, To_String(Item));
  1118. end Put;
  1119.  
  1120. procedure Put_Line(File : in File_Type; Item : in Unbounded_String) is
  1121. begin
  1122. Put(File, Item);
  1123. New_Line(File);
  1124. end Put_Line;
  1125.  
  1126. procedure Put_Line(Item : in Unbounded_String) is
  1127. begin
  1128. Put(Current_Output, Item);
  1129. New_Line;
  1130. end Put_Line;
  1131.  
  1132. end Ustrings;
  1133.  
  1134. --
  1135. -- Permission to use, copy, modify, and distribute this software and its
  1136. -- documentation for any purpose and without fee is hereby granted,
  1137. -- provided that the above copyright and authorship notice appear in all
  1138. -- copies and that both that copyright notice and this permission notice
  1139. -- appear in supporting documentation.
  1140. --
  1141. -- The ARA makes no representations about the suitability of this software
  1142. -- for any purpose. It is provided "as is" without express
  1143. -- or implied warranty.
  1144. --
  1145. --
  1146. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  1147. -- Author: David A. Wheeler
  1148. --
  1149.  
  1150. with Text_IO, Ada.Strings.Unbounded;
  1151. use Text_IO, Ada.Strings.Unbounded;
  1152.  
  1153. package Ustrings is
  1154.  
  1155. -- This package provides a simpler way to work with type
  1156. -- Unbounded_String, since this type will be used very often.
  1157. -- Most users will want to ALSO with "Ada.Strings.Unbounded".
  1158. -- Ideally this would be a child package of "Ada.Strings.Unbounded".
  1159. --
  1160.  
  1161. -- This package provides the following simplifications:
  1162. -- + Shortens the type name from "Unbounded_String" to "Ustring".
  1163. -- + Creates shorter function names for To_Unbounded_String, i.e.
  1164. -- To_Ustring(U) and U(S). "U" is not a very readable name, but
  1165. -- it's such a common operation that a short name seems appropriate
  1166. -- (this function is needed every time a String constant is used).
  1167. -- It also creates S(U) as the reverse of U(S).
  1168. -- + Adds other subprograms, currently just "Swap".
  1169. -- + Other packages can use this package to provide other simplifications.
  1170.  
  1171. subtype Ustring is Unbounded_String;
  1172.  
  1173. function To_Ustring(Source : String) return Unbounded_String
  1174. renames To_Unbounded_String;
  1175. function U(Source : String) return Unbounded_String
  1176. renames To_Unbounded_String;
  1177. function S(Source : Unbounded_String) return String
  1178. renames To_String;
  1179.  
  1180. -- "Swap" is important for reuse in some other packages, so we'll define it.
  1181.  
  1182. procedure Swap(Left, Right : in out Unbounded_String);
  1183.  
  1184.  
  1185. function Empty(S : Unbounded_String) return Boolean;
  1186. -- returns True if Length(S)=0.
  1187. pragma Inline(Empty);
  1188.  
  1189.  
  1190. -- I/O Routines.
  1191. procedure Get_Line(File : in File_Type; Item : out Unbounded_String);
  1192. procedure Get_Line(Item : out Unbounded_String);
  1193.  
  1194. procedure Put(File : in File_Type; Item : in Unbounded_String);
  1195. procedure Put(Item : in Unbounded_String);
  1196.  
  1197. procedure Put_Line(File : in File_Type; Item : in Unbounded_String);
  1198. procedure Put_Line(Item : in Unbounded_String);
  1199.  
  1200. end Ustrings;
  1201.  
  1202. --
  1203. -- Permission to use, copy, modify, and distribute this software and its
  1204. -- documentation for any purpose and without fee is hereby granted,
  1205. -- provided that the above copyright and authorship notice appear in all
  1206. -- copies and that both that copyright notice and this permission notice
  1207. -- appear in supporting documentation.
  1208. --
  1209. -- The ARA makes no representations about the suitability of this software
  1210. -- for any purpose. It is provided "as is" without express
  1211. -- or implied warranty.
  1212. --
  1213. --
  1214. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  1215. -- Author: David A. Wheeler
  1216. --
  1217.  
  1218. with Text_IO, Ada.Strings.Unbounded, Ustrings;
  1219. use Text_IO, Ada.Strings.Unbounded, Ustrings;
  1220.  
  1221. with Things, Players, Items, Rooms, Directions;
  1222. use Things, Players, Items, Rooms, Directions;
  1223.  
  1224. package body World is
  1225.  
  1226. The_Player : Player_Access; -- This is the object representing the
  1227. -- current player.
  1228.  
  1229.  
  1230. procedure Setup is
  1231. Starting_Room : Room_Access := new Room;
  1232. Box : Item_Access := new Item;
  1233. Knife : Item_Access := new Item;
  1234. Living_Room : Room_Access := new Room;
  1235. begin
  1236. Set_Name(Starting_Room, The, "Hallway");
  1237. Set_Description(Starting_Room, "in the hallway. There is a living room " &
  1238. "to the west");
  1239.  
  1240. Set_Name(Box, A, "box");
  1241. Set_Description(Box, "a red box");
  1242. Place(T => Box, Into => Thing_Access(Starting_Room));
  1243.  
  1244. Set_Name(Knife, A, "knife");
  1245. Set_Description(Box, "a black knife");
  1246. Place(T => Knife, Into => Thing_Access(Starting_Room));
  1247.  
  1248. Set_Name(Living_Room, The, "Living Room");
  1249. Set_Description(Living_Room, "in the living room. " &
  1250. "A hallway is to your east");
  1251. Connect(Starting_Room, West, Living_Room);
  1252.  
  1253. -- Setup player.
  1254. The_Player := new Player;
  1255. Set_Name(The_Player, None, "Fred");
  1256. Set_Description(The_Player, Name(The_Player));
  1257. Place(T => Me, Into => Thing_Access(Starting_Room));
  1258. Look(Me);
  1259.  
  1260. end Setup;
  1261.  
  1262.  
  1263. function Me return Occupant_Access is
  1264. -- Return access value to current player.
  1265. begin
  1266. return Occupant_Access(The_Player);
  1267. end Me;
  1268.  
  1269. end World;
  1270.  
  1271. --
  1272. -- Permission to use, copy, modify, and distribute this software and its
  1273. -- documentation for any purpose and without fee is hereby granted,
  1274. -- provided that the above copyright and authorship notice appear in all
  1275. -- copies and that both that copyright notice and this permission notice
  1276. -- appear in supporting documentation.
  1277. --
  1278. -- The ARA makes no representations about the suitability of this software
  1279. -- for any purpose. It is provided "as is" without express
  1280. -- or implied warranty.
  1281. --
  1282. --
  1283. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  1284. -- Author: David A. Wheeler
  1285. --
  1286.  
  1287. with Occupants;
  1288. use Occupants;
  1289.  
  1290. package World is
  1291.  
  1292. procedure Setup;
  1293. -- Setup the World; initialize the contents of the world.
  1294.  
  1295.  
  1296. function Me return Occupant_Access;
  1297. -- Return an access variable pointing to the current player.
  1298.  
  1299. end World;
  1300.  
  1301. --
  1302. -- Permission to use, copy, modify, and distribute this software and its
  1303. -- documentation for any purpose and without fee is hereby granted,
  1304. -- provided that the above copyright and authorship notice appear in all
  1305. -- copies and that both that copyright notice and this permission notice
  1306. -- appear in supporting documentation.
  1307. --
  1308. -- The ARA makes no representations about the suitability of this software
  1309. -- for any purpose. It is provided "as is" without express
  1310. -- or implied warranty.
  1311. --

This category contains 3 examples, and has been viewed 41898 times.