tmi2_fluffos_v2/
tmi2_fluffos_v2/bin/
tmi2_fluffos_v2/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/ChangeLog.old/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/Win32/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/simuls/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/clone/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/command/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/data/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/master/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/log/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/compiler/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/efuns/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/operators/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/u/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/tmp/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/windows/
tmi2_fluffos_v2/lib/
tmi2_fluffos_v2/lib/adm/
tmi2_fluffos_v2/lib/adm/daemons/languages/
tmi2_fluffos_v2/lib/adm/daemons/network/I3/
tmi2_fluffos_v2/lib/adm/daemons/virtual/
tmi2_fluffos_v2/lib/adm/daemons/virtual/template/
tmi2_fluffos_v2/lib/adm/news/
tmi2_fluffos_v2/lib/adm/obj/
tmi2_fluffos_v2/lib/adm/obj/master/
tmi2_fluffos_v2/lib/adm/priv/
tmi2_fluffos_v2/lib/adm/shell/
tmi2_fluffos_v2/lib/adm/tmp/
tmi2_fluffos_v2/lib/cmds/
tmi2_fluffos_v2/lib/d/
tmi2_fluffos_v2/lib/d/Conf/
tmi2_fluffos_v2/lib/d/Conf/adm/
tmi2_fluffos_v2/lib/d/Conf/boards/
tmi2_fluffos_v2/lib/d/Conf/cmds/
tmi2_fluffos_v2/lib/d/Conf/data/
tmi2_fluffos_v2/lib/d/Conf/logs/
tmi2_fluffos_v2/lib/d/Conf/obj/
tmi2_fluffos_v2/lib/d/Conf/text/help/
tmi2_fluffos_v2/lib/d/Fooland/adm/
tmi2_fluffos_v2/lib/d/Fooland/data/
tmi2_fluffos_v2/lib/d/Fooland/data/attic/
tmi2_fluffos_v2/lib/d/Fooland/items/
tmi2_fluffos_v2/lib/d/TMI/
tmi2_fluffos_v2/lib/d/TMI/adm/
tmi2_fluffos_v2/lib/d/TMI/boards/
tmi2_fluffos_v2/lib/d/TMI/data/
tmi2_fluffos_v2/lib/d/TMI/rooms/
tmi2_fluffos_v2/lib/d/grid/
tmi2_fluffos_v2/lib/d/grid/adm/
tmi2_fluffos_v2/lib/d/grid/data/
tmi2_fluffos_v2/lib/d/std/
tmi2_fluffos_v2/lib/d/std/adm/
tmi2_fluffos_v2/lib/data/adm/
tmi2_fluffos_v2/lib/data/adm/daemons/
tmi2_fluffos_v2/lib/data/adm/daemons/doc_d/
tmi2_fluffos_v2/lib/data/adm/daemons/emoted/
tmi2_fluffos_v2/lib/data/adm/daemons/network/http/
tmi2_fluffos_v2/lib/data/adm/daemons/network/services/mail_q/
tmi2_fluffos_v2/lib/data/adm/daemons/network/smtp/
tmi2_fluffos_v2/lib/data/adm/daemons/news/archives/
tmi2_fluffos_v2/lib/data/attic/connection/
tmi2_fluffos_v2/lib/data/attic/user/
tmi2_fluffos_v2/lib/data/std/connection/b/
tmi2_fluffos_v2/lib/data/std/connection/l/
tmi2_fluffos_v2/lib/data/std/user/a/
tmi2_fluffos_v2/lib/data/std/user/b/
tmi2_fluffos_v2/lib/data/std/user/d/
tmi2_fluffos_v2/lib/data/std/user/f/
tmi2_fluffos_v2/lib/data/std/user/l/
tmi2_fluffos_v2/lib/data/std/user/x/
tmi2_fluffos_v2/lib/data/u/d/dm/working/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/smtp/
tmi2_fluffos_v2/lib/doc/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/interactive/
tmi2_fluffos_v2/lib/doc/driverdoc/concepts/
tmi2_fluffos_v2/lib/doc/driverdoc/driver/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/arrays/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/buffers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/compile/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/ed/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/filesystem/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/floats/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/functions/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/general/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/mappings/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/numbers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/parsing/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/constructs/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/preprocessor/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/types/
tmi2_fluffos_v2/lib/doc/driverdoc/platforms/
tmi2_fluffos_v2/lib/doc/mudlib/
tmi2_fluffos_v2/lib/ftp/
tmi2_fluffos_v2/lib/include/driver/
tmi2_fluffos_v2/lib/log/
tmi2_fluffos_v2/lib/log/driver/
tmi2_fluffos_v2/lib/obj/net/
tmi2_fluffos_v2/lib/obj/shells/
tmi2_fluffos_v2/lib/obj/tools/
tmi2_fluffos_v2/lib/std/adt/
tmi2_fluffos_v2/lib/std/board/
tmi2_fluffos_v2/lib/std/body/
tmi2_fluffos_v2/lib/std/fun/
tmi2_fluffos_v2/lib/std/living/
tmi2_fluffos_v2/lib/std/object/
tmi2_fluffos_v2/lib/std/shop/
tmi2_fluffos_v2/lib/std/socket/
tmi2_fluffos_v2/lib/std/user/
tmi2_fluffos_v2/lib/std/virtual/
tmi2_fluffos_v2/lib/student/
tmi2_fluffos_v2/lib/student/kalypso/
tmi2_fluffos_v2/lib/student/kalypso/armor/
tmi2_fluffos_v2/lib/student/kalypso/rooms/
tmi2_fluffos_v2/lib/student/kalypso/weapons/
tmi2_fluffos_v2/lib/u/l/leto/
tmi2_fluffos_v2/lib/u/l/leto/cmds/
tmi2_fluffos_v2/lib/www/errors/
tmi2_fluffos_v2/lib/www/gateways/
tmi2_fluffos_v2/lib/www/images/
tmi2_fluffos_v2/old/
tmi2_fluffos_v2/win32/
.\"try to match a string with a given pattern
.TH parse_command 3 "5 Sep 1994" MudOS "LPC Library Functions"
 
.SH NAME
parse_command() - try to match a string with a given pattern
 
.SH SYNOPSIS
.nf
int parse_command( string command, object env|object *oblist,
                   string pattern, mixed arg, ... );
 
.SH DESCRIPTION
parse_command() is a piffed up sscanf(3) operating on word basis.  
It works similar to sscanf(3) in that it takes a pattern and a variable set 
of destination arguments. It is together with sscanf(3) the only efun to use
pass by reference for other variables than arrays.  That is, parse_command()
returns values in its arguments.
.PP
parse_command() returns 1 if 'command' is considered to have matched 
'pattern'. 
.PP
The 'env' or 'oblist' parameter either holds an object or a list
of objects. If it holds a single object than a list of objects are
automatically created by adding the deep_inventory of the object, ie this
is identical:
.PP
.nf
   parse_command(cmd, environment(), pattern, arg)
.fi
.PP
and
.PP
.nf
   parse_command( cmd, ({ environment() }) +
                  deep_inventory(environment()), pattern, arg)
.fi
.PP
'pattern' is a list of words and formats:
.PP
.nf
   Example string = " 'get' / 'take' %i "
        Syntax:
                'word'          obligatory text
                [word]          optional text
                /               Alternative marker
                %o              Single item, object
                %l              Living objects
                %s              Any text
                %w              Any word
                %p              One of a list (prepositions)
                %i              Any items
                %d              Number 0- or tx(0-99)
.fi
.PP
The 'arg' list is zero or more arguments. These are the result variables
as in sscanf. Note that one variable is needed for each %_
.PP
The return types of different %_ is:
.nf
                %o      Returns an object
                %s      Returns a string of words
                %w      Returns a string of one word
                %p      Can on entry hold a list of word in array
                        or an empty variable
                        Returns:
                           if empty variable: a string
                           if array: array[0] = matched word
                %i      Returns a special array on the form:
                        [0] = (int) +(wanted) -(order) 0(all)
                        [1..n] (object) Objectpointers  
                %l      Returns a special array on the form:
                        [0] = (int) +(wanted) -(order) 0(all)
                        [1..n] (object) Objectpointers
                                        These are only living objects.
                %d      Returns a number
.fi
.PP
The only types of % that uses all the loaded information from the objects
are %i and %l. These are in fact identical except that %l filters out
all nonliving objects from the list of objects before trying to parse.
.PP
The return values of %i and %l is also the most complex. They return an
array consisting of first a number and then all possible objects matching.
As the typical string matched by %i/%l looks like: 'three red roses',
'all nasty bugs' or 'second blue sword' the number indicates which 
of these numerical constructs was matched:
.PP
.nf
   if numeral >0 then three, four, five etc were matched
   if numeral <0 then second, twentyfirst etc were matched
   if numeral==0 then 'all' or a generic plural form such as
                  'apples' were matched.
.fi
.PP
NOTE!
.IP
  The efun makes no semantic implication on the given numeral. It does
  not matter if 'all apples' or 'second apple' is given. A %i will
  return ALL possible objects matching in the array. It is up to the
  caller to decide what 'second' means in a given context.
  Also when given an object and not an explicit array of objects the
  entire recursive inventory of the given object is searched. It is up
  to the caller to decide which of the objects are actually visible
  meaning that 'second' might not at all mean the second object in
  the returned array of objects.
                        
.SH CAVEAT
Patterns of type: "%s %w %i"
Might not work as one would expect.  %w will always succeed so the arg
corresponding to %s will always be empty.
 
.SH BUGS
Patterns of the type: 'word' and [word]
The 'word' can not contain spaces.  It must be a single word. 
This is so because the pattern is exploded on " " (space) and a
pattern element can therefore not contain spaces.
 
As another effect of the exploding on space, separate pieces of 
a pattern MUST be separated with space, ie not " 'word'/%i " but
" 'word' / %i"
.PP
EXAMPLE:
.nf 
     if (parse_command("spray car",environment(this_player()),
                       " 'spray' / 'paint' [paint] %i ",items))  
         {      
            /*
              If the pattern matched then items holds a return array as
              described under 'destargs' %i above.
            */
         }
.fi
.PP
MUDLIB SUPPORT
.PP
To make the efun useful it must have a certain support from the mudlib,
there is a set of functions that it needs to call to get relevant
information before it can parse in a sensible manner.
.PP
In earlier versions it used the normal id() lfun in the LPC objects to
find out if a given object was identified by a certain string. This was
highly inefficient as it could result in hundreds or maybe thousands of
calls when very long commands were parsed. 
.PP  
The new version relies on the LPC objects to give it three lists of 'names'.
.PP
.nf
   1 - The normal singular names.
   2 - The plural forms of the names.
   3 - The acknowledged adjectives of the object.
.fi
.PP
These are fetched by calls to the functions:
.PP
.nf
   1 - string *parse_command_id_list();
   2 - string *parse_command_plural_id_list();
   3 - string *parse_command_adjectiv_id_list();
.fi
.PP
The only really needed list is the first. If the second does not exist
than the efun will try to create one from the singluar list.  For 
grammatical reasons it does not always succeed in a perfect way.  This is
especially true when the 'names' are not single words but phrases.
.PP
The third is very nice to have because it makes constructs like
'get all the little blue ones' possible.
.PP
Apart from these functions that should exist in all objects, and which
are therefore best put in the base mudlib object there is also a set of 
functions needed in the master object.  These are not absolutely necessary 
but they give extra power to the efun.
.PP
Basically these master object lfuns are there to give default values for the 
lists of names fetched from each object.
.PP
The names in these lists are applicable to any and all objects, the first
three are identical to the lfuns in the objects:
.PP
.nf
   string *parse_command_id_list()
      - Would normally return: ({ "one", "thing" })
 
   string *parse_command_plural_id_list()
      - Would normally return: ({ "ones", "things", "them" })
 
   string *parse_command_adjectiv_id_list()
      - Would normally return ({ "iffish" })
.fi
.PP
The last two are the default list of the prepositions and a single so called
'all' word. 
.nf
   string *parse_command_prepos_list()
      - Would normally return: ({ "in", "on", "under" })
 
   string parse_command_all_word()
      - Would normally return: "all"
.fi