#Relay-Version: version Notes 2.7.5 (840 Contrib) 87/2/5; site hpesoc1.HP.COM
#From: games-request@tekred.TEK.COM
#Date: Tue, 4 Aug 87 23:40:51 GMT
#Date-Received: Wed, 5 Aug 87 20:42:30 GMT
#Subject: v02i019:  adl - Adventure Definition Language, Part02/11
#Message-ID: <1473@tekred.TEK.COM>
#Path: hpesoc1!hpda!hplabs!ucbvax!ucbcad!zen!ucla-cs!rutgers!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
#Newsgroups: comp.sources.games
#Sender: billr@tekred.TEK.COM
#Approved: billr@tekred.TEK.COM
#Lines: 2504
#
#Submitted by: cunniff%hpda@hplabs.HP.COM (Ross Cunniff)
#Comp.sources.games: Volume 2, Issue 19
#Archive-name: adl/Part02
#
#
#
#
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 11)."
# Contents:  adlcomp/adlmisc.c adlrun/adltrans.c man/doc.ac
# Wrapped by billr@tekred on Tue Aug  4 16:27:35 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f adlcomp/adlmisc.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlcomp/adlmisc.c\"
else
echo shar: Extracting \"adlcomp/adlmisc.c\" \(13006 characters\)
sed "s/^X//" >adlcomp/adlmisc.c <<'END_OF_adlcomp/adlmisc.c'
X	/***************************************************************\
X	*								*
X	*	adlmisc.c - miscellaneous compiling routines.		*
X	*	Copyright 1987 by Ross Cunniff.				*
X	*								*
X	\***************************************************************/
X
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "adlprog.h"
X#include "adldef.h"
X#include "adlcomp.h"
X
Xstatic	int16
X    NUMADJ = 1,			/* Number of ADJECs found.		*/
X    num_local;			/* Number of LOCALs found.		*/
Xextern	int16
X    numprep;			/* Number of prep synonyms found.	*/
X
X
X	/***************************************************************\
X	*								*
X	*	get_local() - read and process a possible LOCAL		*
X	*	declaration.						*
X	*								*
X	\***************************************************************/
X
Xget_local()
X{
X    int16
X	i;
X
X    num_local = 0;
X    if( t_type == LOCAL_D ) {
X	/* We found the LOCAL token - get a LOCAL list */
X	do {
X	    /* Get the name of a local */
X	    lexer();
X	    if( t_type < 256 )
X		_ERR_FIX( ILLEGAL_SYMBOL, '(' );
X	    insert_local( token, LOCAL, num_local );
X
X	    lexer();
X	    if( t_type == '[' ) {
X		/* The user wants an array.  Get the size. */
X		lexer();
X		if( t_type != CONST )
X		    _ERR_FIX( CONST_EXPECTED, ';' );
X		if( t_val < 1 )
X		    _ERR_FIX( BAD_ARRAY, ';' );
X
X		/* Create space on the stack for the locals */
X		for( i = 0; i < t_val; i++ )
X		    newcode( PUSH, 0L );
X		num_local += t_val;
X
X		/* Pick up the closing bracket */
X		lexer();
X		if( t_type != ']' )
X		    _ERR_FIX( BRACKET_EXPECTED, ';' );
X
X		/* Pick up the next token */
X		lexer();
X	    }
X	    else {
X		newcode( PUSH, 0L );	/* Allocate space for this local */
X		num_local += 1;
X	    }
X	} while( t_type == ',' );
X
X	/* The list should be terminated by a semicolon */
X	if( t_type != ';' )
X	    _ERR_FIX( SEMI_EXPECTED, '(' );
X
X	/* Skip to the beginning of the routine */
X	lexer();
X    }
X    if( num_local > 31 )
X	error( "Number of locals must be less than 32.\n" );
X}
X
X
X	/***************************************************************\
X	*								*
X	*	unget_local() - forget all LOCALS declared in this	*
X	*	routine.						*
X	*								*
X	\***************************************************************/
X
Xunget_local()
X{
X    del_locals();
X}
X
X
X	/***************************************************************\
X	*								*
X	*	getvars() - get a VAR declaration list.			*
X	*								*
X	\***************************************************************/
Xgetvars()
X{
X    do {
X	lexer();
X	if( t_type != UNDECLARED )
X	    _ERR_FIX( ILLEGAL_SYMBOL, ';' );
X	insert_sys( token, VAR, NUMVAR );
X	lexer();
X	if( t_type == '[' ) {
X	    /* The user wants an array.  Pick up the size. */
X	    lexer();
X	    if( t_type != CONST )
X		_ERR_FIX( CONST_EXPECTED, ';' );
X	    if( t_val < 1 )
X		_ERR_FIX( BAD_ARRAY, ';' );
X	    NUMVAR += t_val;
X
X	    /* Pick up the closing bracket */
X	    lexer();
X	    if( t_type != ']' )
X		_ERR_FIX( BRACKET_EXPECTED, ';' );
X
X	    /* Pick up the comma */
X	    lexer();
X	}
X	else
X	    NUMVAR += 1;
X    } while( t_type == ',' );
X    if( t_type != ';' )
X	_ERR_FIX( SEMI_EXPECTED, ';' );
X}
X
X
X	/***************************************************************\
X	*								*
X	*	getlist( t ) - Get a declaration list, such as		*
X	*		ADJEC red, green, blue;				*
X	*	and insert the tokens where they belong.		*
X	*								*
X	\***************************************************************/
X  
Xgetlist( t )
Xint16
X    t;			/* The type of the declaration */
X{
X    int16
X	*addr;		/* The address of the counter to be incremented */
X
X    /* Get the address and the type of the tokens being declared. */
X    switch( t ) {
X	case VERB_D	: addr = &NUMVERB;	t = VERB;	break;
X	case ROUT_D	: addr = &NUMROUT;	t = ROUTINE;	break;
X	case ADJEC_D	: addr = &NUMADJ;	t = ADJEC;	break;
X	case ART_D	: addr = 0;		t = ARTICLE;	break;
X	case PREP_D	: addr = &numprep;	t = PREP;	break;
X    }
X
X    /* Actually declare the token list */
X    do {
X	lexer();
X	if( t_type != UNDECLARED )
X	    /* Only tokens not previously declared are allowed */
X	    _ERR_FIX( ILLEGAL_SYMBOL, ';' );
X
X	if( addr ) {
X	    /* Declare the token and increment the counter */
X	    if( t == ROUTINE )
X		insert_sys( token, t, *addr );
X	    else
X		insertkey( token, t, *addr, 1 );
X	    (*addr) += 1;
X	}
X	else {
X	    /* Articles are just noise, no values are needed. */
X	    insertkey( token, t, 0, 1 );
X	}
X	lexer();
X    } while( t_type == ',' );
X    if( t_type != ';' )
X	_ERR_FIX( SEMI_EXPECTED, ';' );
X}
X
X
X	/***************************************************************\
X	*								*
X	*	getassign() - get an assignment statement like		*
X	*		toolbox = tool box;				*
X	*	or							*
X	*		SEEN = 3;					*
X	*								*
X	\***************************************************************/
X
Xint16
Xgetassign( do_insert )
Xint
X    do_insert;
X{
X    char
X	s[ 512 ];		/* Save area for the current token string */
X    int16
X	t_save,			/* Save area for the current token value */
X	retval;
X
X    if( do_insert ) {
X	/* Save the current token (used to print an error message later) */
X	retval = 0;
X	strcpy( s, token );
X    }
X
X    /* Read the next token - it should be '=' */
X    lexer();
X    if( t_type != '=' )
X	_ERR_FIX( EQUAL_EXPECTED, ';' );
X
X    /* Read the value of the assignment statement */
X    lexer();
X    if( (t_type == ADJEC) || (t_type == VERB) ) {
X	/* We may be reading a noun phrase */
X	if( t_type == ADJEC )
X	    t_save = t_val;
X	else
X	    t_save = -t_val;
X	lexer();
X	if( t_type == NOUN ) {
X	    if( (t_save = noun_exists( t_save, t_val )) < 0 )
X		_ERR_FIX( "Undeclared object.", ';' );
X	    if( do_insert )
X		insertkey( s, NOUN_SYN, t_save, 1 );
X	    else
X		retval = t_save;
X	    lexer();
X	}
X	else if( t_type == ';' ) {
X	    /* This was just foo = ADJEC or foo = VERB */
X	    if( do_insert ) {
X		if( t_save < 0 )
X		    insertkey( s, VERB, -t_save, 0 );
X		else
X		    insertkey( s, ADJEC, t_save, 0 );
X	    }
X	    else {
X		if( t_save < 0 )
X		    retval = -t_save;
X		else
X		    retval = t_save;
X	    }
X	}
X	else
X	    _ERR_FIX( SEMI_EXPECTED, ';' );
X    }
X    else if( t_type == NOUN ) {
X	/* Unmodified object */
X	if( (t_save = noun_exists( 0, t_val )) < 0 )
X	    _ERR_FIX( ATTEMPT, ';' );
X	if( do_insert )
X	    insertkey( s, NOUN_SYN, t_save, 1 );
X	else
X	    retval = t_save;
X	lexer();
X    }
X    else if( (t_type >= MIN_LEGAL) && (t_type <= MAX_LEGAL) ) {
X        /* We're reading a simple synonym */
X	if( do_insert ) {
X	    if( (t_type >= MIN_RT) && (t_type <= MAX_RT) && (t_type != STRING) )
X		insertkey( s, t_type, t_val, 0 );
X	    else
X		insert_sys( s, t_type, t_val );
X	}
X	else
X	    retval = t_val;
X	lexer();
X    }
X    else if( (t_type == '(') || (t_type == LOCAL_D) ) {
X	/* We're creating a routine */
X	if( do_insert )
X	    insert_sys( s, ROUTINE, NUMROUT );
X	else
X	    retval = NUMROUT;
X	routspace[ NUMROUT++ ] = currcode();
X	get_local();
X	getroutine( 1 );
X	newcode( RET, 0L );
X	unget_local();
X    }
X    if( t_type != ';' )
X	_ERR_FIX( SEMI_EXPECTED, ';' );
X    return retval;
X}
X
X	/***************************************************************\
X	*								*
X	*	adlrout( t_read ) - read in an ADL routine and return	*
X	*	its starting address.  If t_read is false, the initial	*
X	*	'=' [ locals ] '(' sequence is read from the input	*
X	*	 stream.						*
X	*								*
X	\***************************************************************/
X
Xaddress
Xadlrout( t_read )
Xint16
X    t_read;
X{
X    address
X	t;
X
X    if( !t_read ) {
X	lexer();
X	if( t_type != '=' )
X	    _ERR_FX0( EQUAL_EXPECTED, ';' );
X	lexer();
X	if( (t_type != '(') && (t_type != LOCAL_D) )
X	    _ERR_FX0( LEFT_EXPECTED, ';' );
X    }
X    t = currcode();
X    get_local();
X    getroutine( 1 );
X    newcode( RET, 0L );
X    unget_local();
X    if( t_type != ';' )
X	_ERR_FX0( SEMI_EXPECTED, ';' );
X    return t;
X}
X
X
X	/***************************************************************\
X	*								*
X	*	getverb() - handle things like				*
X	*		north(PREACT) = ($setg GOVERB TRUE);		*
X	*	or							*
X	*		north ball(WEIGH) = 300;			*
X	*								*
X	\***************************************************************/
X
Xgetverb()
X{
X    int16
X	 verb,		/* The verb which is under consideration */
X	 val,		/* The property which is being assigned */
X	 rval;		/* The 16-bit value of the RHS of the expression */
X
X    verb = t_val;
X    lexer();
X    if( t_type == NOUN ) {
X	/* This is actually a noun assignment */
X	nounassign( 2, -verb );
X	return;
X    }
X    else if( t_type == PREP ) {
X	/* This is actually a VERB PREP = VERB statement */
X	getverbsyn( verb );
X	return;
X    }
X
X    /* This is a verb assignment.  Get the property number. */
X    if( t_type != '(' )
X	_ERR_FIX( LEFT_EXPECTED, ';' );
X    lexer();
X    if( t_type != CONST )
X	_ERR_FIX( CONST_EXPECTED, ';' );
X    if( (t_val != _PREACT) && (t_val != _ACT) )
X	_ERR_FIX( "PREACT or ACTION expected.\n", ';' );
X    val = t_val;
X    lexer();
X    if( t_type != ')' )
X	_ERR_FIX( RIGHT_EXPECTED, ';' );
X
X    /* Get the RHS of the expression - it must be a routine ID or a routine */
X    lexer();
X    if( t_type != '=' )
X	_ERR_FIX( EQUAL_EXPECTED, ';' );
X    lexer();
X    if( t_type == ROUTINE ) {
X	rval = t_val;
X	lexer();
X	if( t_type != ';' )
X	    _ERR_FIX( SEMI_EXPECTED, ';' );
X    }
X    else if( (t_type == '(') || (t_type == LOCAL_D) ) {
X	rval = NUMROUT;
X	routspace[ NUMROUT++ ] = adlrout( 1 );
X    }
X    else
X	_ERR_FIX( "Routine expected", ';' );
X
X    /* Put the RHS into the proper property. */
X    switch( val ) {
X	case _PREACT :
X	    if( verbspace[ verb ].preact )
X		warning( "verb( PREACT ) already assigned.\n" );
X	    verbspace[ verb ].preact = rval;
X	    break;
X	case _ACT :
X	    if( verbspace[ verb ].postact )
X		warning( "verb( ACTION ) already assigned.\n" );
X	    verbspace[ verb ].postact = rval;
X	    break;
X    }
X}
X
X
X	/***************************************************************\
X	*								*
X	*	globassign() - Read and process a statement such as	*
X	*		(MaxScore) = 400;				*
X	*								*
X	\***************************************************************/
X
Xglobassign()
X{
X    int16
X	v;	/* The actual variable id */
X
X    /* Read the variable */
X    lexer();
X    if( t_type != VAR )
X	_ERR_FIX( VAR_EXPECTED, ';' );
X    v = t_val;
X
X    lexer();
X    if( t_type == '+' ) {
X	/* The user wants to assign into an array.  Get the offset. */
X	lexer();
X	if( t_type != CONST )
X	    _ERR_FIX( CONST_EXPECTED, ';' );
X	v += t_val;
X
X	/* Pick up the closing parenthesis */
X	lexer();
X    }
X
X    if( t_type != ')' )
X	_ERR_FIX( RIGHT_EXPECTED, ')' );
X
X    if( varspace[ v ] )
X	warning( "Re-assignment of VAR value.\n" );
X
X    /* Get the RHS and stuff it into the correct place. */
X    varspace[ v ] = getassign( 0 );
X}
X
X
X	/***************************************************************\
X	*								*
X	*	routassign() - handle the assignment of an actual	*
X	*	routine to a previously declared routine ID.		*
X	*								*
X	\***************************************************************/
X
Xroutassign()
X{
X    int16
X	v;	/* The routine ID */
X
X    v = t_val;
X    if( routspace[ v ] )
X	warning( "Re-assignment of ROUTINE value.\n" );
X    routspace[ v ] = adlrout( 0 );
X}
X
X
X	/***************************************************************\
X	*								*
X	*	prepassign() - handle constructs like			*
X	*		in front of = before;				*
X	*								*
X	\***************************************************************/
X
Xprepassign()
X{
X    int16
X	adj;
X
X    /* Save the value of the first preposition */
X    prepspace[ NUMPP ].first = t_val;
X
X    /* Get the middle part of the phrase */
X    lexer();
X    if( t_type == NOUN_SYN ) {
X	prepspace[ NUMPP ].obj = t_val;
X	lexer();
X    }
X    else if( t_type != PREP ) {
X	if( t_type == VERB ) {
X	    adj = -t_val;
X	    lexer();
X	}
X	else if( t_type == ADJEC ) {
X	    adj = t_val;
X	    lexer();
X	}
X	else
X	    adj = 0;
X	if( t_type != NOUN )
X	    _ERR_FIX( NOUN_WANTED, ';' );
X	if( (prepspace[ NUMPP ].obj = noun_exists( adj, t_val )) < 0 )
X	    _ERR_FIX( "Illegal object.\n", ';' );
X	lexer();
X    }
X
X    /* Get the second preposition and save it */
X    if( t_type != PREP )
X	_ERR_FIX( PREP_EXPECTED, ';' );
X    prepspace[ NUMPP ].last = t_val;
X
X    /* Get the '=' PREP ';' */
X    lexer();
X    if( t_type != '=' )
X	_ERR_FIX( EQUAL_EXPECTED, '=' );
X    lexer();
X    if( t_type != PREP )
X	_ERR_FIX( PREP_EXPECTED, ';' );
X    prepspace[ NUMPP ].val = t_val;
X    lexer();
X    if( t_type != ';' )
X	_ERR_FIX( SEMI_EXPECTED, ';' );
X    NUMPP++;
X}
X
X
X	/***************************************************************\
X	*								*
X	*	getverbsyn( verb ) - get a statement like		*
X	*		put on = wear;					*
X	*								*
X	\***************************************************************/
X
Xgetverbsyn( verb )
Xint16
X    verb;
X{
X    /* At this point, we have VERB PREP */
X    verbsyn[ NUMVS ].vrb = verb;
X    verbsyn[ NUMVS ].prp = t_val;
X
X    /* Get the equals sign */
X    lexer();
X    if( t_type != '=' )
X	_ERR_FIX( EQUAL_EXPECTED, ';' );
X
X    /* Get the following verb */
X    lexer();
X    if( t_type != VERB )
X	_ERR_FIX( "VERB expected.\n", ';' );
X    verbsyn[ NUMVS++ ].val = t_val;
X
X    /* Get the closing semicolon */
X    lexer();
X    if( t_type != ';' )
X	_ERR_FIX( SEMI_EXPECTED, ';' );
X}
X
X/*** EOF adlmisc.c ***/
END_OF_adlcomp/adlmisc.c
if test 13006 -ne `wc -c <adlcomp/adlmisc.c`; then
    echo shar: \"adlcomp/adlmisc.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f adlrun/adltrans.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"adlrun/adltrans.c\"
else
echo shar: Extracting \"adlrun/adltrans.c\" \(1156 characters\)
sed "s/^X//" >adlrun/adltrans.c <<'END_OF_adlrun/adltrans.c'
X#include <stdio.h>
X
X#include "adltypes.h"
X#include "adlprog.h"
X#include "builtins.h"
X#include "adlrun.h"
X
X
Xsetverb()
X{
X    int16
X	i;
X
X    assertargs( "$setv", 10 );
X    for( i = 0; i <= 9; i++ )
X	vecverb[ i ] = ARG( i + 1 );
X    RETVAL = 0;
X}
X
X
Xhitverb()
X{
X    int16
X	i;
X
X    assertargs( "$hit", 11 );
X    for( i = 0; i <= 9; i++ )
X	if( vecverb[ i ] == Verb ) {
X	    ARG( 2 ) = ARG( i + 2 );
X	    if( ARG( 2 ) )
X		move_obj();
X	    RETVAL = 0;
X	    return;
X	}
X    RETVAL = 0;
X}
X
X
Xmissverb()
X{
X    int16
X	i,
X	oldbp,
X	which;
X
X    assertargs( "$miss", 10 );
X    for( i = 0; i <= 9; i++ ) {
X	if( vecverb[ i ] == Verb ) {
X	    popip();
X	    oldbp = pop();
X	    which = ARG( i + 1 );
X#if DEBUG
X	    if( (which < 0) || (which > NUMROUT) )
X		error( 26 );	/* Illegal rout for $miss */
X#endif
X	    sp = bp;		/* Cut args off stack */
X	    if( which && routspace[ which ] ) {
X		push( 1 );	/* stackdepth */
X		push( oldbp );	/* bp */
X		puship();	/* ip */
X		ip = routspace[ which ];
X	    }
X	    else {
X		push( 0 );
X		bp = oldbp;
X	    }
X	    return;
X	}
X    }
X    popip();
X    oldbp = pop();
X    sp = bp + 1;
X    stack[ bp ] = 0;
X    bp = oldbp;
X}
X
X/*** EOF adltrans.c ***/
END_OF_adlrun/adltrans.c
if test 1156 -ne `wc -c <adlrun/adltrans.c`; then
    echo shar: \"adlrun/adltrans.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f man/doc.ac -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"man/doc.ac\"
else
echo shar: Extracting \"man/doc.ac\" \(38154 characters\)
sed "s/^X//" >man/doc.ac <<'END_OF_man/doc.ac'
X
X		  TRUE	= 1;
X		  FALSE	= 0;
X		  NULL	= 0;
X
X
X     In	addition, the following	constants  are	defined	 for
X     use as arguments to the $spec routine:
X
X		  DEBUG	= 1;
X		  RESTART = 2;
X		  QUIT = 3;
X		  SAVE = 4;
X		  RESTORE = 5;
X		  EXEC = 6;
X		  PRESERVE = 7;
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 54	-
X
X
X		  SCRIPT = 8;
X		  HEADER = 9;
X		  MARGIN = 10;
X
X
X     The following constants are defined for  use  as  argu-
X     ments  to	the  Expect  routine  (described  in section
X     10.6):
X
X		  NO_OBJ = 1;
X		  ONE_OBJ = 2;
X		  MULT_OBJ = 4;
X		  PLAIN_OBJ = 8;
X		  STR_OBJ = 16;
X
X
X     The  following  global  variables	 are   declared	  by
X     standard.adl for use by the ADL programmer:
X
X		  Skip,
X		  Indent,
X		  Dark,
X		  MyLoc,
X		  Verbose,
X		  Scripting,
X		  LastVerb,
X		  LastNumd,
X		  LastDobj,
X		  LastPrep,
X		  LastIobj;
X
X     The above globals are used	as follows:
X
X     Skip	   Skip	is used	in preference to  ($exit  1)
X		   or  ($exit 2) inside	Object ACTIONs if it
X		   is desired that the rest  of	 the  Object
X		   list	 be  processed by the Verb ACTION of
X		   "take" or "drop" (see the  discussion  on
X		   TakeAct and DropAct below).
X
X     Indent	   Indent should be set	to  TRUE  if  object
X		   descriptions	 are  to  be indented by two
X		   spaces before being printed.
X
X     Dark	   Dark	is TRUE	if  it	is  currently  dark.
X		   This	 variable  is set by the Looker	rou-
X		   tine	if there is no light in	the  current
X		   location  of	 .ME, and may also be set as
X		   the result of some other action.
X
X     MyLoc	   MyLoc is the	location of  the  player  at
X		   the	outset	of  the	 previous turn.	 The
X		   routine  Looker  checks  to	see  whether
X		   MyLoc  is the same as the location of the
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 55	-
X
X
X		   player.  If so, the room  description  is
X		   printed.   If not, no action	is performed
X		   by Looker.  MyLoc is	initialized to -1 to
X		   force  the printing of a room description
X		   at the beginning of the game.
X
X     Verbose	   Verbose should be  set  to  TRUE  if	 the
X		   player  wishes that all room	descriptions
X		   be verbose ones (i.e.  long	descriptions
X		   of  the  room and its contents).  If	Ver-
X		   bose	is  false  and	the  room  has	been
X		   visited  previously,	 a short description
X		   will	be printed.
X
X     Scripting	   Scripting is	set to TRUE by the ACTION of
X		   the	Verb  "script"	when output is being
X		   scripted to a file.	It is  FALSE  other-
X		   wise.
X
X     LastVerb	   LastVerb, LastNumd,	LastDobj,  LastPrep,
X		   and	LastIobj  contain the values present
X		   in the sentence prior to the	current	sen-
X		   tence.  These values	are set	in the stan-
X		   dard	  looking   daemon.    The   routine
X		   SaveSentence	 is  provided  for this	pur-
X		   pose.
X
X
X10.3.  Words
X
X     The following words are defined to	be a  standard	part
X     of	the ADL	vocabulary:
X
X     PREP	   with, to, into, at, under, from, off, on;
X
X     in	= into;
X
X     ARTICLE	   the,	a, an;
X
X     NOUN	   all,	it;
X
X
X10.4.  Verbs and their actions
X
X     Standard.adl declares the following verbs,	and initial-
X     izes  their  PREACT  and  ACTION  routines	to (usually)
X     fairly simply-minded defaults.
X
X		  n,  s,  e,  w,
X		  ne, se, nw, sw,
X		  up, down,
X		  enter, exit,
X		  get, put, take, drop,
X		  wear,	remove,
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 56	-
X
X
X		  verbose, terse,
X		  open,	close,
X		  lock,	unlock,
X		  move,	break, rub, touch,
X		  throw, read, burn,
X		  examine, look, inventory,
X		  quit,	restart,
X		  save,	restore, script,
X		  turn,	douse, light,
X		  wait,	again, go;
X
X
X     The following verbs have special semantics	and redefin-
X     ition  of	their  PREACT  or  ACTION routines should be
X     avoided:
X
X     NOVERB	   NOVERB (which is predeclared	by  ADL)  is
X		   the	verb  returned	by the parser if the
X		   player's  sentence  contained  no   verb.
X		   Standard.adl	 initializes  the  PREACT of
X		   NOVERB so that appropriate  requests	 for
X		   more	information are	generated.
X
X     put	   "Put" transforms itself into	"drop"	then
X		   calls the PREACT of "drop".
X
X     get	   "Get" transforms itself into	"take"	then
X		   calls the PREACT of "take".
X
X     take	   "Take" determines whether the sentence is
X		   one	like "Take all but the sword and the
X		   shield".  If	it is then a list of objects
X		   is  built  up  which	 are then taken.  If
X		   not,	the normal semantics apply.  If	 the
X		   programmer  wants  an  action  to be	per-
X		   formed by the "take"	ACTION,	the  routine
X		   TakeAct should be defined.
X
X     drop	   "drop" may  be  used	 in  sentences	like
X		   "Drop  all  but  the	 book."	 If it is so
X		   used, a list	of objects is created  which
X		   are	then  dropped.	 If  the  programmer
X		   wants an action to be  performed  by	 the
X		   "drop" ACTION, the routine DropAct should
X		   be defined.
X
X     go		   If "go" is used in a	 sentence  like	 "Go
X		   north",  the	 Verb  is changed to "north"
X		   and the Dobj	and Iobj are  set  to  NULL.
X		   This	 only applies to the direction verbs
X		   "north",   "south",	  "east",    "west",
X		   "northeast",	  "southeast",	"northwest",
X		   "southwest",	"up", and "down".
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 57	-
X
X
X     again	   If  the  standard  actor  action  is	  in
X		   effect,  the	 Verb  "again" will never be
X		   called or seen by  Objects  since  it  is
X		   replaced by the previous sentence.
X
X     In	 addition  to	declaring   the	  preceding   verbs,
X     standard.adl declares the following equivalences:
X
X		  g		  = again;
X		  z		  = wait;
X		  l		  = look;
X		  u		  = up;
X		  d		  = down;
X		  north		  = n;
X		  south		  = s;
X		  east		  = e;
X		  west		  = w;
X		  northeast	  = ne;
X		  northwest	  = nw;
X		  southeast	  = se;
X		  southwest	  = sw;
X
X		  put on	  = wear;
X		  take off	  = remove;
X		  turn on	  = light;
X		  turn off	  = douse;
X
X
X10.5.  Routines
X
X     Standard.adl declares and defines	the  following	Rou-
X     tines for use by the ADL programmer:
X
X		  StdInit,
X		  Reach,
X		  See,
X		  Lit,
X		  Avail,
X		  CheckAvail,
X		  Expect,
X		  Preact,
X		  Looker,
X		  Prompter,
X		  TakeAct,
X		  DropAct,
X		  ActAction,
X		  SaveSentence,
X		  Dwimmer;
X
X     Their use is defined as follows:
X
X     StdInit	   (StdInit actor)  should  be	executed  in
X		   START  if the programmer desires that ALL
X		   of the default routines be  used.   Actor
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 58	-
X
X
X		   should   be	 the  name  of	the  primary
X		   interactive Actor in	the scenario.
X
X     Reach	   (Reach  object  container)  is  TRUE	  if
X		   object  is  contained in container and if
X		   the player can reach	the object.   It  is
X		   FALSE  otherwise.   Note  that  this	also
X		   checks whether  object  is  contained  in
X		   something which is contained	in container
X		   and so on.
X
X     See	   (See	object container) is TRUE if  object
X		   is  contained in container and the player
X		   can see the object.	It is  FALSE  other-
X		   wise.  This also checks containers inside
X		   containers.
X
X     Lit	   (Lit) is TRUE if  something	is  lighting
X		   the	player's  location  and	FALSE other-
X		   wise.
X
X     Avail	   (Avail object) is TRUE if the player	 can
X		   see	object (either in the room or in the
X		   player's inventory)	and  can  reach	 the
X		   object.  It is FALSE	otherwise.
X
X     CheckAvail	   (CheckAvail)	checks to  see	whether	 the
X		   Dobj	 and  Iobj  typed  by the player are
X		   available.  If not, an  appropriate	mes-
X		   sage	 is  printed  and  ($exit 1) is	per-
X		   formed.
X
X     Expect	   Expect is typically called by the  PREACT
X		   of  a Verb.	It looks at the	current	sen-
X		   tence to see	whether	it is of  acceptable
X		   form.    The	 two  parameters  to  Expect
X		   define criteria for	acceptability.	 The
X		   first  parameter  indicates what types of
X		   direct objects  are	acceptable  and	 the
X		   second  indicates  what types of indirect
X		   objects are acceptable.   Each  parameter
X		   consists  of	 one  or  more of the Expect
X		   flags $or'd together.   The	flag  NO_OBJ
X		   indicates  that  it is acceptable that no
X		   object  be  present;	  ONE_OBJ  indicates
X		   that	 it is acceptable that one object be
X		   present;  MULT_OBJ indicates	that  it  is
X		   acceptable	that   multiple	 objects  be
X		   present;  STR_OBJ indicates that it's  OK
X		   for	the  object(s)	to  be	strings; and
X		   PLAIN_OBJ indicates that it's OK for	 the
X		   object(s) to	be normal ADL objects.
X
X		   Example:
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 59	-
X
X
X				{ "take" needs 1 to N Dobjs and	0 or 1 Iobjs }
X				take(PREACT) =
X					(Expect	($or MULT_OBJ PLAIN_OBJ)
X						($or NO_OBJ ONE_OBJ PLAIN_OBJ))
X				;
X				{ "quit" can accept no objects }
X				quit(PREACT) =
X					(Expect	 NO_OBJ	 NO_OBJ)
X				;
X				{ "unlock" needs exactly one Dobj and Iobj }
X				unlock(PREACT) =
X					(Expect	($or  ONE_OBJ  PLAIN_OBJ)
X						($or  ONE_OBJ  PLAIN_OBJ) )
X				;
X				{ "say"	needs a	string to say and possibly
X				  someone to whom to say it }
X				say(PREACT) =
X					(Expect	($or ONE_OBJ STR_OBJ)
X						($or NO_OBJ ONE_OBJ PLAIN_OBJ))
X				;
X
X
X
X     Preact	   Preact is the standard PREACT for  Verbs.
X		   It  checks  to make sure that exactly one
X		   plain Direct	Object was  typed  and	that
X		   the	Indirect Object	is not a string.  It
X		   also	checks to see  whether	all  of	 the
X		   named objects are available.
X
X     Looker	   Looker is the  standard  looking  daemon.
X		   It is intended to be	executed every turn.
X		   To enable this, either of the  statements
X		   ($sdem Looker) or (StdInit actor) must be
X		   executed (where  actor)  is	the  primary
X		   actor).
X
X     Prompter	   Prompter is the standard  prompting	rou-
X		   tine.   To  use  it,	either of the state-
X		   ments  ($prompt  Prompter)  or   (StdInit
X		   actor) must be executed.
X
X     ActAction	   ActAction is	the standard  Actor  action.
X		   It checks to	see whether the	Verb "again"
X		   or the Object "it" was used and  modifies
X		   the	sentences appropriately.  To use it,
X		   either  of  the  statements	($setp	 .ME
X		   ACTION ActAction) or	(StdInit actor)	must
X		   be executed.
X
X     TakeAct	   TakeAct is called by	the  default  action
X		   routine  of	the  Verb  "take"  after the
X		   ACTION routines  of	all  of	 the  Direct
X		   Objects have	been executed.
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 60	-
X
X
X     DropAct	   DropAct is  similar	to  TakeAct,  except
X		   that	 it  is	called by the ACTION routine
X		   of "drop".
X
X     SaveSentence  SaveSentence	should be called by the	 ADL
X		   programmer if it is desired that the	Verb
X		   "again" and the Object "it"	work  as  in
X		   ActAction  above.   Looker calls SaveSen-
X		   tence every turn.
X
X     Dwimmer	   Dwimmer is the standard DWIMming routine.
X		   It  checks  to  see	whether	an ambiguous
X		   object could	 possibly  be  the  one	 the
X		   player  meant.   To	use Dwimmer, include
X		   the	statement  (IF	(Dwimmer  %1)	THEN
X		   ($return 1))	in DWIMI and/or	DWIMD.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 61	-
X
X
XAppendix 1 - A Tiny Dungeon
X
X     The following dungeon is a	tiny but complete  scenario.
XIt  demonstrates  the  use of $hit and $miss, as well as the
Xuse of some of the features of standard.adl.
X
X
X     INCLUDE "standard.adl";
X
X     NOUN startrm, brightroom;		     { Locations in the	dungeon	}
X     startrm(LIGHT) = TRUE;	     brightroom(LIGHT) = TRUE;
X     cg	= ($say	"You can't go that way.\n");
X
X     startrm(LDESC) =
X	     ($say "You	are in a small but comfortable room.  You hardly "
X		   "want to leave, but there is	a door leading east, if	"
X		   "you	insist.\n")
X     ;
X     startrm (SDESC) = ($say "Comfortable room.\n");
X     startrm(ACTION) =
X	     ($miss cg cg 0 cg 0 0 0 0 0 0)
X	     ($hit .ME 0 0 brightroom 0	0 0 0 0	0 0)
X     ;
X     brightroom(LDESC) =
X	     ($say "You	are in a brightly lit room.  The walls sparkle "
X		   "with scintillating lights.	There is a darker room "
X		   "to the west.\n")
X     ;
X     brightroom(SDESC) = ($say "Bright room.\n");
X     brightroom(ACTION)	=
X	     ($miss cg cg cg 0 0 0 0 0 0 0)
X	     ($hit .ME 0 0 0 startrm 0 0 0 0 0 0)
X     ;
X     ADJEC red,	blue;
X     NOUN red pillow(startrm), blue pillow(startrm);
X
X     red pillow(LDESC) = ($say "There is a red pillow here.\n");
X     red pillow(SDESC) = ($say "A red pillow");
X
X     blue pillow(LDESC)	= ($say	"There is a blue pillow	here.\n");
X     blue pillow(SDESC)	= ($say	"A blue	pillow");
X
X     NOUN platinum(brightroom);		     bar = platinum;
X     platinum(LDESC) = ($say "There is a bar of	platinum here!\n");
X     platinum(SDESC) = ($say "A	platinum bar");
X     platinum(ACTION) =
X	     (IF	     ($and ($eq	($verb)	drop)
X			     ($eq ($loc	.ME) ($loc [red	pillow])))
X	     THEN
X		     ($say "The	bar falls onto the red pillow, breaking	it! "
X			   "The	symbolism impresses itself upon	you, and "
X			   "you	go back	to work	instead	of playing these "
X			   "silly games!\n")
X		     ($spec 3)
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 62	-
X
X
X	     )
X     ;
X     NOUN SELF(startrm);	     SELF(NOTAKE) = TRUE;
X
X     START = ($prompt Prompter)
X	     ($sdem Looker)
X	     ($actor SELF 0 1 0)
X	     ($setv n s	e w 0 0	0 0 0 0)
X     ;
X     DWIMD = ($return (DWIM %1));
X     DWIMI = (DWIM %1);	     { This result will	be returned by default }
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 63	-
X
X
XAppendix 2 - A scenario	with multiple Actors
X
X     The following ADL program demonstrates both the use  of
Xthe  standard  package and the use of multiple actors.	This
Xis the scenario	which generated	the script at the  beginning
Xof this	document.
X
X
XINCLUDE	"standard.adl";		{ Include the standard package }
X
X
X{ The following	are Object properties }
X
XBROKEN	=  1;		{ Is the robot damaged?	}
XTOLD	=  2;		{ Have I told the robot	something? }
XBSTATE	= 17;		{ State	of the button }
X	B_OFF	=  0;	{ Button is off	}
X	B_FLASH	=  1;	{ Button is flashing }
X	B_LIT	=  2;	{ Button is lit	}
X
X
X{ Global variables }
X
XVAR
X	RobSave[ 6 ],	{ Saved	sentence for the robot }
X	Score;		{ Current score	}
X
X
X{ Utility routines }
X
XROUTINE
X	NoGo,	Sayer,	Myself,	Lifter,
X	DoorCk,	TrapCk,	RobMov,	BlueCk,
X	Header,	Die,	Skore,	RobEntr,
X	HatchSD;
X
X
X{ Locations in the dungeon }
X
XNOUN
X	Redrm,		Bluerm,
X	Greenrm,	Cellar,
X	Endrm;
X
X
X{ Immovable objects }
X
XNOUN
X	button(	Bluerm ),
X	door( Cellar ),
X	hatch( Bluerm );
X
X
X{ Objects which	may become actors }
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 64	-
X
X
XNOUN
X	me( Redrm ),
X	robot( Greenrm );
X
Xme( NOTAKE ) = TRUE;
X
X
X{ Room descriptions }
X
XRedrm( LDESC ) =
X	($say
X"You are in a large room which is illuminated by a bright
Xred glow.  Exits lie to	the east and south.\n"
X	)
X;
XRedrm( SDESC ) = ($return (Header "Red room" %0));
XRedrm( LIGHT ) = TRUE;
X
X
XGreenrm( LDESC ) =
X	($say
X"You are in a smallish room which is illuminated by a pleasant
Xgreen glow.  The only exit is to the west.\n"
X	)
X;
XGreenrm( SDESC ) = ($return (Header "Green room" %0));
XGreenrm( LIGHT ) = TRUE;
X
X
XBluerm(	LDESC )	=
X	($say
X"You are in a tiny room	which is barely	illuminated by a
Xdim blue glow.	There is an exit to the	north,"
X	)
X	(IF ($eq ($prop	button BSTATE) B_LIT) THEN
X		($say
X" and most of the floor	has tilted up to reveal	a hatch	leading
Xdown into blackness.  A	button on the wall is glowing brightly."
X		)
X	 ELSE
X		($say "	and you	seem to	make out something on the floor.")
X		(IF ($prop button BSTATE) THEN
X			($say "	 A button on the wall is flashing urgently.")
X		 ELSE
X			($say "	 There is a button on the wall.")
X		)
X	)
X	($say
X"  Above the button is a sign that reads:\n\n"
X"		DANGER!\n\n"
X"	     HIGH VOLTAGE!\n\n"
X	)
X;
XBluerm(	SDESC )	=
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 65	-
X
X
X	(IF %0 THEN ($return "Blue room"))
X	($say "Blue room.\n")
X;
XBluerm(	LIGHT )	= TRUE;
X
X
XCellar(	LDESC )	=
X	($say
X"You are in the	cellar.	 Far above you can be seen a dim
Xblue light."
X	)
X	(IF ($prop door	OPENED)	THEN
X		($say
X"  An open door	leads to the north.\n"
X		)
X	 ELSE
X		($say
X"  You can barely see the outline of a door to the north.\n"
X		)
X	)
X;
XCellar(	SDESC )	=
X    ($return (Header "Cellar" %0))
X;
XCellar(	LIGHT )	= TRUE;
X
X
XEndrm( LDESC ) =
X	($say
X"You exit from the dark	cellar into a land filled with singing birds,
Xblooming flowers, flowing streams, and bright blue skies.  In other words,
Xyou have finished this game!\n"
X	)
X	($setg Score ($plus @Score 25))
X	(Skore)
X	($spec 3)
X;
XEndrm( LIGHT ) = TRUE;
X
X
X{ Verbs	}
X
XVERB
X	score,
X	push,
X	shout;
X
Xtell = TELLER;
Xsay = tell;
Xpress =	push;
Xfeel = touch;
Xyell = shout;
X
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 66	-
X
X
X{ Verb routines	}
X
Xtell( PREACT ) =
X	(IF ($ne @Iobj robot) THEN
X		{ The only logical thing to talk to is the robot }
X		(Sayer
X"Talking to yourself is	said to	be a sign of impending insanity"
X		)
X	 ELSEIF	($ge @Dobj 0) THEN
X		{ You must say strings }
X		(Sayer
X"You must put what you want to say in quotes"
X		)
X	 ELSEIF	($ne ($loc robot) ($loc	me)) THEN
X		{ The robot must be in the same	place as the player }
X		(IF (Myself) THEN
X			($say "You don't see the robot here.\n")
X		)
X	 ELSE
X		{ Everything is	OK.  Add 25 points to the score	}
X		(IF ($not ($prop robot TOLD)) THEN
X			($setg Score ($plus @Score 25))
X			($setp robot TOLD TRUE)
X		)
X		($exit 0)
X	)
X	($exit 1)
X;
Xtell( ACTION ) =
X	{ Tell the player that we heard	him }
X	($say "\"Sure thing, Boss.\"\n")
X
X	{ Delete the old action	}
X	($delact robot)
X
X	{ Add the new action - a non-interactive actor }
X	($actor	robot @Dobj FALSE)
X;
X
X
Xshout( PREACT )	=
X	(IF	($and @Iobj ($ne @Iobj robot)) THEN
X		{ Shouting at things other than	the robot }
X		($say "AAARRRGGGHHH!\n")
X	 ELSEIF	($ge @Dobj 0) THEN
X		{ Shouting things other	than strings }
X		($say "EEEYYYAAAHHH!\n")
X	 ELSEIF	($prop robot BROKEN) THEN
X		($say "There is	no response.\n")
X	 ELSE
X		{ Shouting at the robot	- same as telling the robot }
X		(IF ($not ($prop robot TOLD)) THEN
X			($setg Score ($plus @Score 25))
X			($setp robot TOLD TRUE)
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 67	-
X
X
X		)
X		($exit 0)
X	)
X	($exit 1)
X;
Xshout( ACTION )	=
X	{ Tell the player we heard him }
X	(IF ($ne ($loc robot) ($loc me)) THEN
X		($say "In the distance you hear	the words, ")
X	)
X	($say "\"Sure thing, Boss\"\n")
X
X	{ Delete the old robot action }
X	($delact robot)
X
X	{ Add the new robot action }
X	($actor	robot @Dobj FALSE)
X;
X
X
Xpush( PREACT ) =
X	{ Expect a plain direct	object }
X	(Expect	($or ONE_OBJ PLAIN_OBJ)	NO_OBJ)
X	(CheckAvail)
X;
Xpush( ACTION ) =
X	(Sayer "That doesn't seem to do	anything")
X	($exit 1)
X;
X
X
Xscore(PREACT) =
X	{ Score	can accept no objects }
X	(Expect	NO_OBJ NO_OBJ)
X	(Skore)
X	($exit 1)
X;
X
X
X{ Object properties }
X
Xbutton(	SDESC )	=
X	(IF ($eq ($prop	button BSTATE) B_OFF) THEN
X		($say "a button")
X	 ELSEIF	($eq ($prop button BSTATE) B_FLASH) THEN
X		($say "an urgently flashing button")
X	 ELSE
X		($say "a brightly lit button")
X	)
X;
Xbutton(	ACTION ) =
X	(IF ($and	(Myself)
X			($or	($eq @Verb push)
X				($eq @Verb take)
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 68	-
X
X
X				($eq @Verb touch)
X			)
X		)
X	 THEN
X		{ The player tried to do something with	the button }
X		($say
X"As you	reach for the button, a	10,000,000 volt	bolt of	lightning
Xarcs toward your finger, disintegrating	you upon impact.\n"
X		)
X		(Die)
X	 ELSEIF	($and ($eq @Verb push) ($eq ($prop button BSTATE) B_OFF)) THEN
X		{ The robot pushed the button }
X		($setp button BSTATE B_FLASH)
X		($setg Score ($plus @Score 50))
X		($sfus me Lifter 4)
X		($exit 1)
X	 ELSEIF	($eq @Verb take) THEN
X		{ Can't	take the button	}
X		($setg Skip TRUE)
X	)
X;
X
X
XSimpleRobot = "I am just a simple robot";
Xrobot( LDESC ) = ($say "There is a robot here.\n");
Xrobot( SDESC ) = ($say "a robot");
Xrobot( ACTION )	=
X	(IF (Myself) THEN
X		{ I'm doing something with the robot }
X		(IF ($eq @Verb tell) THEN
X			(IF ($prop robot BROKEN) THEN
X				($say "There is	no response.\n")
X				($exit 1)
X			)
X		 ELSEIF	($eq @Verb take) THEN
X			($say "The robot weighs	at least 500 pounds!\n")
X			($exit 1)
X		)
X	 ELSEIF	($eq ($phase) 2) THEN
X		{ This is being	called as the Actor ACTION }
X		(ActAction)
X		(IF ($and	($ne @Verb push)
X				($ne @Verb go)
X				($ne @Verb wait)
X				($ne @Verb take)
X				($or ($lt @Verb	north) ($gt @Verb down)))
X		 THEN
X			{ The robot has	a VERY simple vocabulary }
X			(Sayer SimpleRobot)
X			($delact robot)
X			($exit 1)
X		)
X	 ELSEIF	($eq @Verb take) THEN
X		{ The robot is trying to take itself }
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 69	-
X
X
X		(Sayer "Mmmph!	Akkk!!	GGGGRR!!  No can do.  Sorry")
X		($setg Skip TRUE)
X	 ELSE
X		{ The robot is doing something to itself }
X		(Sayer SimpleRobot)
X		($delact robot)
X		($exit 1)
X	)
X;
Xrobot( SAVESENT	) = RobSave;
X
X
X
X{	We break me( ACTION ) out into a named routine because
X	StdInit	overwrites that	property and we	need to	restore	it	}
X
XMeAct =
X	(IF ($eq ($phase) 2) THEN
X		{ This is the Actor ACTION - call standard's actor action }
X		(ActAction)
X	 ELSEIF	($eq @Verb take) THEN
X		(Sayer "I thought you would never ask")
X		($setg Skip TRUE)
X	)
X;
X
X
X{	We break hatch(	SDESC )	out into a named routine because
X	the hatch isn't	visible	until after Lifter has executed		}
X
XHatchSD	= ($say	"an open hatch");
XHatchMSG = "The	hatch doesn't budge";
Xhatch( ACTION )	=
X	(IF ($eq @Verb take) THEN
X		{ Can't	take the hatch }
X		(Sayer HatchMSG)
X		($setg Skip TRUE)
X	 ELSEIF	($or ($eq @Verb	open) ($eq @Verb push))	THEN
X		{ Can't	open or	push it, either	}
X		(Sayer HatchMSG)
X		($exit 1)
X	)
X;
Xhatch( OPENS ) = TRUE;
Xhatch( NOTAKE )	= TRUE;
X
X
Xdoor( SDESC ) =	($say "a door");
Xdoor( ACTION ) =
X	(IF ($eq @Verb take) THEN
X		($say "You can't take a	door!\n")
X		($setg Skip TRUE)
X	)
X;
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 70	-
X
X
Xdoor( OPENS ) =	TRUE;
X
X
X{	Transition routines.  Note that	RobMov is used in $miss.
X	This produces the 'The robot exits to the <direction>
X	messages.  The calls to	RobEntr	produce	the messages like
X	'The robot enters from the <direction>.		}
X
XBluerm(	ACTION ) =
X	($miss RobMov NoGo NoGo	NoGo NoGo TrapCk 0 0 0 0)
X	($hit .ME Redrm	0 0 0 0	Cellar 0 0 0 0)
X	(RobEntr)
X;
X
X
XRedrm( ACTION )	=
X	($miss NoGo BlueCk RobMov NoGo NoGo NoGo 0 0 0 0)
X	($hit .ME 0 Bluerm Greenrm 0 0 0 0 0 0 0)
X	(RobEntr)
X;
X
X
XGreenrm( ACTION	) =
X	($miss NoGo NoGo NoGo RobMov NoGo NoGo 0 0 0 0)
X	($hit .ME 0 0 0	Redrm 0	0 0 0 0	0)
X	(RobEntr)
X;
X
X
XCellar(	ACTION ) =
X	($miss DoorCk NoGo NoGo	NoGo BlueCk NoGo 0 0 0 0)
X	($hit .ME Endrm	0 0 0 Bluerm 0 0 0 0 0)
X	(RobEntr)
X;
X
X
X{ Routines }
X
X{ (Myself) - returns 1 if "me" is the current actor; 0 otherwise }
XMyself =
X	($return ($eq .ME me))
X;
X
X
X{	(Sayer str) - Says a string with appropriate quoting, depending
X	on whether the robot or	the player is doing the	saying.		}
XSayer =
X	(IF (Myself) THEN
X		($say %1 ".\n")
X	 ELSEIF	($eq ($loc robot) ($loc	me)) THEN
X		($say "\"" %1 ", Boss.\"\n")
X	 ELSE
X		($say "You hear	a muffled voice	in the distance.\n")
X	)
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 71	-
X
X
X;
X
X
X{	(NoGo) - "You can't go that way"	}
XNoGo =
X	(Sayer "You can't go that way")
X	($exit 1)
X;
X
X
X{	(Header	str arg0) - To accomplish the printing of header lines,
X	each location SDESC need to return a string if a parameter is
X	passed to it.  By doing	($return (Header <sdesc> %0)), we can
X	centralize the saying/returning	decision.	}
XHeader =
X	(IF ($not %2) THEN
X		($say %1 ".\n")
X	)
X	($return %1)
X;
X
X
XRobMov =
X	(IF ($and ($not	(Myself)) ($eq ($loc robot) ($loc me)))	THEN
X		($say
X			"The robot exits to the	"
X			(IF ($eq @Verb e) THEN
X				($val "east")
X			 ELSEIF	($eq @Verb w) THEN
X				($val "west")
X			 ELSEIF	($eq @Verb s) THEN
X				($val "south")
X			 { The robot can't be seen leaving to the north	}
X			)
X			".\n"
X		)
X	)
X;
X
X
XRobEntr	=
X	(IF ($and ($not	(Myself)) ($eq ($loc robot ) ($loc me))) THEN
X		($say
X			(IF ($eq @Verb north) THEN
X				($val "The robot enters	from the south.\n")
X			 ELSEIF	($eq @Verb east) THEN
X				($val "The robot enters	from the west.\n")
X			 ELSEIF	($eq @Verb west) THEN
X				($val "The robot enters	from the east.\n")
X			 { The robot can't enter from the north	in
X			   this	scenario }
X			)
X		)
X	)
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 72	-
X
X
X;
X
X
XDoorCk =
X	(IF ($not ($prop door OPENED)) THEN
X		($say "The door	seems to be closed.\n")
X		($exit 1)
X	)
X;
X
X
XTrapCk =
X	(IF ($ne ($prop	button BSTATE) B_LIT) THEN
X		(NoGo)
X	)
X;
X
X
X{	(BlueCk) - make	sure that only one actor is in the blue	room
X	at one time.	}
XBlueCk =
X	(IF ($or ($eq ($loc me)	Bluerm)	($eq ($loc robot) Bluerm)) THEN
X		(IF (Myself) THEN
X			($say
X"The room is too small for both	you and	the robot to fit.\n"
X			)
X		)
X		($exit 1)
X	 ELSEIF	($and ($not (Myself)) ($eq ($prop button BSTATE) B_LIT)) THEN
X		(RobMov)
X		($say "You hear	a loud CRASH! in the distance.\n")
X		($setg Score ($minus @Score 10))
X		($setp robot BROKEN TRUE)
X		($move robot Bluerm)
X		($delact robot)
X		($exit 1)
X	)
X	(RobMov)
X;
X
X
X{	(Die) -	kill off the player	}
XDie =
X	($setg Score ($minus @Score 50))
X	(Skore)
X	($say "Do you wish to restart the game?	")
X	(IF ($yorn) THEN
X		($spec 2)
X	 ELSE
X		($spec 3)
X	)
X;
X
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 73	-
X
X
X{	(Lifter) - Lift	the hatch, possibly killing the	robot or
X	the player	}
XLifter =
X	(IF ($eq ($loc me) Bluerm) THEN
X		($say
X"All of	a sudden, the floor lifts up, and you are crushed between it
Xand the	wall!  "
X		)
X		(Die)
X	 ELSE
X		($say "In the distance,	you hear a loud	CRASH!\n")
X		(IF ($eq ($loc robot) Bluerm) THEN
X			($setg Score ($minus @Score 10))
X			($setp robot BROKEN TRUE)
X			($delact robot)
X		)
X	)
X	($setp hatch SDESC HatchSD)
X	($setp button BSTATE B_LIT)
X	($setp Bluerm SEEN FALSE)
X;
X
X
X{	Prompt - print the status line and a prompt	}
XPROMPT =
X	($spec 9 (($sdesc ($loc	.ME)) 1) @Score	($turns))
X	($say "> ")
X;
X
X
X{	Increment - increment the turn counter	}
XINCREMENT =
X	(IF (Myself) THEN
X		{ We only want to increment once per turn }
X		($incturn)
X	 ELSE
X		{ We don't want	Looker executing for the robot }
X		($exit 0)
X	)
X;
X
X
X{	(Skore)	- print	out the	current	score.	}
XSkore =
X	($say	"You have scored " ($str @Score)
X		" out of a possible 100	in " ($str ($turns)) " moves.\n")
X;
X
X
X{	Dwimming routines	}
XDWIMI =	(Dwimmer %1);
XDWIMD =	(Dwimmer %1);
X
XSTART =
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 74	-
X
X
X	($spec MARGIN 69)	{ Set the screen to 69 wide }
X	($sdem INCREMENT)	{ Turn counter increment }
X	(StdInit me)		{ Initialize standard }
X	($setp me ACTION MeAct)	{ Restore me( ACTION ) }
X	($setv n s e w u d 0 0 0 0)	{ Use our own transition vector	}
X	($prompt PROMPT)	{ and our own prompter }
X	($setg Indent TRUE)	{ Indent the object descriptions }
X;
X
X{*** EOF actdemo.adl ***}
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 75	-
X
X
XAppendix 3 - Glossary
X
XActor		An Actor in ADL	is similar to an Actor in  a
X		play, in that the Actor	has a script to	fol-
X		low (the lines typed  by  the  player),	 and
X		there may be more than one Actor acting	at a
X		time.
X
XAdjective	An adjective  is  a  part  of  speech  which
X		describes  a  noun.   "Red", "green", "big",
X		and "rusty" are	all adjectives.
X
XArgument	An argument to an ADL routine is one of	 the
X		list  of "things" which	the routine was	told
X		to operate on.	For example, in	the  routine
X		call  ($plus 20	30 40) the first argument is
X		20, the	second argument	is 30, and the third
X		argument is 40.
X
XArticle		An article is a	part of	speech	which  often
X		conveys	some sense of "definiteness".  "The"
X		is an article, as are  "a"  and	 "an".	 ADL
X		ignores	 articles  in  player  sentences, so
X		their proper use is of little importance.
X
XASCII		ASCII (which stands  for  American  Standard
X		Code  for Information Interchange, as if you
X		really	wanted	to  know)  is  a  method  of
X		representing  characters  (such	as "a",	"b",
X		"9", etc.) as numbers  for  the	 purpose  of
X		computer   manipulation.   Thus,  the  ASCII
X		representation of the letter "A" is 65.	 The
X		expression  "the ASCII representation of the
X		number 45308" is often	heard.	 This  means
X		that  the number 45308 is represented as the
X		ASCII string "45308".  This is slightly	dif-
X		ferent than the	ASCII code of a	character.
X
XBNF		BNF is a method	of representing	 the  syntax
X		of a language in a concise way.	 In English,
X		one may	say that "A list is  a	sequence  of
X		things."  In  BNF,  one	may say	that "list =
X		thing *" which means that a list consists of
X		zero  or  more things.	(This is actually an
X		extended form of BNF which is  more  concise
X		than  the  original).	Other things one may
X		say include "foo = bar +" which	 means	that
X		foo consists of	one or more bars;  "bletch =
X		[ ack ]	gag" which means that a	bletch is an
X		optional ack followed by a gag.	 Parentheses
X		may be used for	grouping; for example "abcbc
X		= a ( b	c ) *" means that an abcbc is an "a"
X		followed by zero or more occurrences of	 the
X		two-element list "b c".
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 76	-
X
X
XBuffer		See Line Buffer.
X
XConjunction	A conjunction is a part	of speech  which  is
X		used   to  join	 two  parts  of	 a  sentence
X		together.   Conjunctions  include  the	word
X		"and", the word	"but", and the comma ",".
X
XContainer	A container  is	 an  object  which  contains
X		another	object,	just as	in real	life.
X
XDaemon		A daemon is  a	routine	 which	is  executed
X		periodically.  For example, in real life Joe
X		Blow  goes  on	a  coffee  break  every	  15
X		minutes.   A coffee break could	then be	con-
X		sidered	a daemon  which	 executes  every  15
X		minutes	 (and  Joe  Blow could be considered
X		lazy).	ADL daemons execute once every turn.
X
XDirect Object	A direct object	is a part of speech on which
X		the verb is "acting" directly.	For example,
X		in the sentence	"Take  the  food"  the	word
X		"food" is the direct object.  Direct objects
X		may consist of more than one word.
X
XFuse		A fuse is similar to a	daemon	except	that
X		instead	 of  being executed periodically, it
X		waits a	for some time to pass then  executes
X		exactly	 once.	 For  example,	in real	life
X		setting	your alarm to go off at	six  o'clock
X		in  the	morning	could be considered activat-
X		ing a fuse.
X
XGlobal		See Variable.
X
XGlobal Variable	See Variable.
X
XImplementor	The implementor	is the person who wrote	 the
X		ADL  compiler  and ADL interpreter which run
X		on your	computer.  Send	the implementor	lots
X		of praise and/or money.
X
XIndirect Object	An indirect object is a	part of	speech which
X		is  indirectly	acted upon by the verb.	 For
X		example, in the	sentence "Take the rock	from
X		the stream", "stream" is the indirect object
X		as it is not directly affected by  the	verb
X		"take".	  Usually an indirect object is	pre-
X		ceded by a preposition.	 There is  one	case
X		where  it  is not.  For	example, in the	sen-
X		tence "Give the	frog the  bait"	 it  is	 the
X		bait  which  is	 being given.  This may	seem
X		confusing but if you rewrite the sentence as
X		"Give  the  bait  to the frog" it makes	more
X		sense.
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 77	-
X
X
XLine Buffer	A line buffer is an area in  the  memory  of
X		the  computer  where the last line which was
X		typed by a player is  stored.	Words  which
X		are  read  by  the Parser are read from	this
X		buffer,	not directly from the keyboard.
X
XLocal Variable	See Variable.
X
XLocation	The location of	some specified object is the
X		object which contains the specified object.
X
XModifier	A modifier is a	 part  of  speech  which  is
X		essentially  the  same	as  an	adjective in
X		function.  ADL allows some verbs to  act  as
X		modifiers  in  order  to  better  mimic	 the
X		English	language.
X
XNoun		A noun is a person, place, or thing.  A	desk
X		is  a noun.  America is	a noun.	 Fred Rogers
X		is a noun.  "Noun" and "object"	are normally
X		interchangeable	  terms.   Usually  however,
X		when a reference is made to something  being
X		a  "noun"  it implies that something is	just
X		one word (as in	"desk"), and not  two  words
X		(as in "blue streak").
X
XObject		See Noun.
X
XParse		Parsing	is the process of breaking  down  an
X		input  string  into  structured	 data.	 For
X		example, parsing the string "Take the  green
X		brick  and  the	 nail  from  the wall" would
X		parse  into  the  verb	"Take",	 the  direct
X		objects	"green brick" and "nail", the prepo-
X		sition	"from",	 and  the  indirect   object
X		"wall".
X
XPlayer		A player is a person who plays a game.	Gen-
X		erally,	a player is associated with an Actor
X		in an ADL scenario.
X
XPreposition	A preposition is  a  part  of  speech  which
X		often  specifies some location (like "under"
X		or "beside") or	some destination (like	"in"
X		or  "on").  Prepositions are generally found
X		before Indirect	Objects	 in  sentences,	 but
X		occasionally modify Verbs.
X
XPrompt		A prompt is some sort of  message  from	 the
X		computer  to  a	 human	indicating that	some
X		input is expected.
X
XProgrammer	The programmer (in  this  documentation,  at
X		least)	is  the	 person	who created the	game
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 78	-
X
X
X		scenario which is compiled  and	 interpreted
X		by  ADL.  Send the programmer lots of praise
X		and/or money too.
X
XRoom		A room is any object that a player may even-
X		tually enter.
X
XRoutine		A routine is a series of instructions to the
X		computer  telling  it  what  to	say, what to
X		move, what to read, and/or where to go.
X
XScenario	A "scenario" is	like a scene in	a play -  it
X		specifies  where  Objects  are located,	what
X		events might occur, who	is present, and	what
X		they  may  do.	 A scenario is somewhat	more
X		general	than a scene since scenarios contain
X		rules  for  generating	many possible scenes
X		whereas	scenes are static.
X
XSeparator	A  separator  is  a  part  of  speech  which
X		separates two sentences.  A separator can be
X		a period ".", the word "then", or the end of
X		a line.
X
XString		A string is a series of	characters (letters,
X		etc.)  surrounded  by quote marks.  "foo bar
X		bletch"	is a string (legal in both the	com-
X		pilation  and  execution  phases of ADL) and
X		'Hi, there!' is	a string (legal	only in	 the
X		execution phase	of ADL).
X
XStack		A stack	is like	a stack	of dishes:  you	 may
X		put  a new dish	on top of the stack (this is
X		known as "pushing") or you may take  a	dish
X		from  the top of the stack (this is known as
X		"popping").  You may not  take	dishes	from
X		the bottom or middle of	the stack; likewise,
X		a computer stack doesn't allow the  deletion
X		of elements in the middle of the stack.
X
XSyntax		The syntax of a	language is the	set of rules
X		which  say how things may be put together in
X		order  to  make	 a  valid  program  in	that
X		language.
X
XUser		See Player.
X
XVariable	A variable is a	location in the	memory of  a
X		computer  in  which  values  may  be stored,
X		changed, and erased.  Global  variables	 (or
X		globals	 for  short) are variables which are
X		directly accessible by name to all  routines
X		of  an	ADL  program.	Local  variables (or
X		locals)	 are  variables	  which	  are	only
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X			   - 79	-
X
X
X		directly  accessible by	the routine in which
X		they are named.	 They  are  only  indirectly
X		accessible by other routines.
X
XVerb		A verb is a part  of  speech  which  implies
X		some action.  "Take", "run", "eat", "sleep",
X		and "hide" are all verbs.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
X
X
X
X
X
X
X			  Table	of Contents
X
X
X	  1.  Introduction ---------------------------------- 1
X	  2.  ADL Data types -------------------------------- 3
X	  2.1.	Objects	   ---------------------------------- 3
X	  2.2.	Verbs	   ---------------------------------- 4
X	  2.3.	Adjectives ---------------------------------- 5
X	  2.4.	Strings	   ---------------------------------- 5
X	  2.5.	Numbers	   ---------------------------------- 5
X	  2.6.	Routines   ---------------------------------- 6
X	  2.7.	Global Variables ---------------------------- 6
X	  2.8.	Local variables	----------------------------- 6
X	  2.9.	Modifiers  ---------------------------------- 6
X	  3.  ADL Internal Structures ----------------------- 7
X	  3.1.	Actors	   ---------------------------------- 7
X	  3.2.	Daemons	   ---------------------------------- 8
X	  3.3.	Fuses	   ---------------------------------- 8
X	  3.4.	Prompter   ---------------------------------- 8
X	  3.5.	Run-Time Macros	----------------------------- 8
X	  4.  Putting It All Together ----------------------- 10
X	  4.1.	The Flow of Execution ----------------------- 10
X	  4.2.	$exit	   ---------------------------------- 13
X	  5.  ADL Programs ---------------------------------- 15
X	  6.  Routines	   ---------------------------------- 20
X	  7.  ADL Built-in Routines ------------------------- 23
X	  7.1.	Object Routines	----------------------------- 24
X	  7.2.	Verb Routines ------------------------------- 27
X	  7.3.	Arithmetic Routines ------------------------- 28
X	  7.4.	Boolean	Routines ---------------------------- 29
X	  7.5.	Global Value Routines ----------------------- 32
X	  7.6.	Transition Routines ------------------------- 34
X	  7.7.	String Manipulation Routines ---------------- 35
X	  7.8.	Name Routines ------------------------------- 38
X	  7.9.	Conversion Routines ------------------------- 39
X	  7.10.	 Internal Structure Manipulation Routines --- 40
X	  7.11.	 Special Routines --------------------------- 43
X	  7.12.	 Miscellaneous Routines	--------------------- 46
X	  8.  ADL Program Structure ------------------------- 49
X	  9.  ADL Sentence Structure ------------------------ 51
X	  10.  standard.adl --------------------------------- 52
X	  10.1.	 Object	properties -------------------------- 52
X	  10.2.	 Constants ---------------------------------- 53
X	  10.3.	 Words	   ---------------------------------- 55
X	  10.4.	 Verbs and their actions -------------------- 55
X	  10.5.	 Routines  ---------------------------------- 57
X	  Appendix 1 - A Tiny Dungeon ----------------------- 61
X	  Appendix 2 - A scenario with multiple	Actors ------ 63
X	  Appendix 3 - Glossary	----------------------------- 75
X
X
X
X
X
X
X
X
X	    c 1987 Ross	Cunniff	and Tim	Brengle
X
X
END_OF_man/doc.ac
if test 38154 -ne `wc -c <man/doc.ac`; then
    echo shar: \"man/doc.ac\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 2 \(of 11\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 11 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
    echo Making adl.doc
    (cd man; cat doc.aa doc.ab doc.ac >adl.doc; rm doc.a[a-c])
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
