Contents | Index | < Browse | Browse >

5.  ADL Programs

     This chapter describes the	format of ADL programs.	  An
ADL program consists of	a list of one or more of the follow-
ing statements.	 Comments in ADL programs are delimited	by {
and  }.	  Since	case is	significant in ADL, tokens which are
identical except for differing case are	different (for exam-
ple, "noun" is not the same as "NOUN").

     Note: for a full BNF specification	of ADL programs, see
Chapter	8.



INCLUDE	"filename";
	Input to the ADL  compiler  is	read  from  filename
	until  the  end	of file	and compilation	then resumes
	from the current file.	A file included	in  compila-
	tion  by  means	 of an INCLUDE statement may INCLUDE
	other files.

	Example:
		     INCLUDE "standard.adl";



MESSAGE	"message";
	The string message is printed on the console at	com-
	pile time.  This is used to remind the programmer of
	things which should  be	 initialized  or  to  simply
	reassure  the programmer that the compiler is indeed
	reading	the file.

	Example:
		     MESSAGE "Whew!  We're halfway through the file!n";



VAR name, name,	... ;
	This declares each name	to be a	new global variable.
	The  contents of global	variables are initialized to
	zero.  Each  name  must	 not  have  been  previously
	declared.   Each  name	may  be	 followed  by a	size
	specifier, in which case that  number  of  words  is
	allocated.  As ADL routines have no specific facili-
	ties for handling arrays, it is	 the  responsibility
	of  the	 ADL programmer	to add the desired offset to
	the base of the	array in order to access an  element
	of the array For example, ($setg ($plus	Array 10) 5)
	is similar to Array[ 10	] = 5 in C.

	Example:
		     VAR
			     Score,
			     Dark,
			     ObjList[ 10 ],
			     MyLoc;



LOCAL name, name, ... ;
	This statement is only legal inside routine  defini-
	tions.	 It  declares each name	as a new Local Vari-
	able. Each name	may or may  not	 already  have	been
	declared.   If	a  name	 is  the same as the name of
	something declared outside the routine,	 that  thing
	cannot	be  directly referenced	by the routine.	 The
	name of	a local	variable is only visible to the	rou-
	tine in	which it is defined.  Local variables may be
	arrays just as global variables	may.   Note  that  a
	routine	 may  have  a  maximum	of 32 words of local
	variables.  Arrays of local variables  use  up	that
	space  rather  quickly,	 so they should	be used	with
	care.  See the next chapter  for  an  example  using
	local variables.

VERB name, name, ... ;
	This statement declares	each name to be	a new  Verb.
	The PREACT and ACTION routines of Verbs	are initial-
	ized to	zero.  Each name must not have	been  previ-
	ously declared.

	Example:
		     VERB    take, drop, open, close;



ADJEC name, name, ... ;
	This statement declares	each name to be	a new Adjec-
	tive.	Again,	each  name must	not have been previ-
	ously declared.

	Example:
		     ADJEC   red, green, blue;



NOUN ndecl, ndecl, ... ;
	This statement declares	Objects.  Ndecl	may take the
	form  obj  or  obj  (  container  ).  The first	form
	declares a new Object located in  the  object  .ALL.
	The  second  form  declares  a new Object located in
	container.  Each obj may be one	 of:  an  undeclared
	identifier,  a	modifier  followed  by an undeclared
	identifier, or a modifier followed by  a  previously
	declared  noun.	  If obj is just an undeclared iden-
	tifier,	the identifer is declared to be	a noun and a
	new  Object  is	created	with that noun ID and with a
	modifier of 0.	If obj is a modifier followed by  an
	undeclared identifier, the identifier is declared to
	be a noun and a	new Object is created with that	noun
	ID  and	 with the modifier set to the one specified.
	If obj	is  a  modifier	 followed  by  a  previously
	declared  noun,	 a  new	 Object	 is created with the
	specified noun ID and the specified modifier.	Note
	that  the declaration "NOUN foo, blue foo;" is ille-
	gal since it would be too easy to create  situations
	where  the  player  is	unable	to  disambiguate the
	Objects.

	Example:
		     NOUN    room1;
		     NOUN    table( room1 ), chair( room1 ), red ball( room1 );



ROUTINE	name, name, ...	;
	This statement declares	each name to be	a  new	rou-
	tine.	Note  that this	does not associate a routine
	with the Routine ID -- it just declares	the routine.
	This  is  useful  for  daisy-chaining routines (i.e.
	routine	A calls	routine	B, which  calls	 routine  A)
	since everything must be declared before it is used.
	Each name must not have	been previously	declared.

	Example:
		     ROUTINE Looker, Prompter, Quitter;



ARTICLE	name, name, ...	;
	This statement declares	each name to be	a new  Arti-
	cle.   Each  name  must	 not  have  been  previously
	declared.

	Example:
		     ARTICLE the, a, an;



PREP name, name, ... ;
	This statement declares	each name to be	a new Prepo-
	sition.	  Each	name  must  not	have been previously
	declared.

	Example:
		     PREP    in, into, on, above ;



obj (const) = expr ;
	This statement assigns property	const of obj  to  be
	expr.	Const must be a	number or the name of a	con-
	stant (see below).  Expr may be	a string, a  number,
	a routine, another noun, or just about anything	else
	which yields a sixteen bit ID.	Obj must  be  previ-
	ously  declared.   A warning may be produced if	this
	particular property is reassigned later	in the	pro-
	gram.

	Example:
		     room1( LDESC ) =
			     ($say "You	are in a huge room.n")
		     ;
		     chair( WEIGH ) = 450 ;
		     table( MESSAGE ) =	"This space for	rentn"	;



verb (const) = routine ;
	This statement assigns property	const of verb to  be
	routine.  Const	must be	either PREACT or ACTION, and
	verb must have been previously declared.  A  warning
	may be produced	if this	particular property is reas-
	signed later in	the program.

	Example:
		     take( ACTION ) = ($say "You can't take that object.n");
		     drop( PREACT ) = (CheckAvail);



name = expr;
	This statement declares	that name is  equivalent  to
	expr.	Name  must not have been previously declared
	and expr may be	an object, a string,  a	 routine,  a
	number,	 or  just  about anything else that yields a
	sixteen-bit value.

	Example:
		     MagicWord = "AbraCadabra";	     { string ID }
		     VISIT = 3;				     { constant	}
		     Silly = ($say "That's silly!n");	     { routine ID }
		     toolbox = tool box;		     { object ID }



(global) = expr;
	This statement initializes global variable global to
	have  the  value expr.	Global must have been previ-
	ously declared and expr	is the same as expr above.

	Example:
		     ( MyLoc ) = -1;
		     ( Score ) = 10;



(global	+ const) = expr;
	This statement initializes the const'th	slot in	 the
	global array global to have the	value expr.

	Example:
		     VAR foo[ 10 ];
		     ( foo ) = 3;	     { Sets foo[0] to 3	}
		     ( foo + 5 ) = 6;	     { Sets foo[5] to 6	}



prep1 obj prep2	= prep3;
	This  statement	 declares  that	 if  the  three-word
	sequence  prep1	obj prep2 is encountered during	run-
	time parsing in	the proper position for	 a  preposi-
	tion,  it  is to be replaced by	prep3.	Obj may	be a
	modifier-noun pair and prep1, prep2, and prep3	must
	have been previously declared.

	Example:
		     PREP
			     in, of, before;
		     NOUN
			     front;

		     in	front of = before;



verb1 prep = verb2;
	This  statement	 declares  that	 if   the   two-word
	sequence  verb1	 prep is encountered during run-time
	parsing	in the proper position for a verb, it is  to
	be  replaced  by verb2.	 Verb1,	verb2, and prep	must
	have been previously declared.

	Example:
		     VERB
			     put, take,	turn, wear, remove, light, douse;
		     PREP
			     on, off;

		     put on = wear;
		     take off =	remove;
		     turn on = light;
		     turn off =	douse;