1997Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Command Parsing -->
<!--X-From-R13: @nguna Kbfcr <lbfcrNunjnvv.rqh> -->
<!--X-Date: Mon, 25 Nov 1996 00:06:05 +0100 -->
<!--X-Message-Id: Pine.GSO.3.93.961123230320.3602A&#45;100000#uhunix2,its.Hawaii.Edu -->
<!--X-Content-Type: text/plain -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Command Parsing</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:yospe#hawaii,edu">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00058.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00059.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00059.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00100.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00061">Author</A>
&nbsp;|&nbsp;<A HREF="#00061">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00061">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Command Parsing</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud#bug,belgonet.be">mud#bug,belgonet.be</A></LI>
<LI><em>Subject</em>: Command Parsing</LI>
<LI><em>From</em>: Nathan Yospe &lt;<A HREF="mailto:yospe#hawaii,edu">yospe#hawaii,edu</A>&gt;</LI>
<LI><em>Date</em>: Sun, 24 Nov 1996 13:17:25 -1000</LI>
<LI><em>Reply-To</em>: Nathan Yospe &lt;<A HREF="mailto:yospe#hawaii,edu">yospe#hawaii,edu</A>&gt;</LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>


  Hi all. Either you've all been really quiet recently, or there is
something wrong with my mail server. In any case, I've been developing a
concept and wanted to toss it out to all of you before playing with it.
Incidentally, I know most of you prefer the server design for muds. Mine
is not, as you are probably aware, but is instead a hybrid of sorts, with
primary design in C++ but support for free swapping of C++ functions with
internal language functions that can be designed and activated without a
recompile or reboot, at a penalty of about 5x on speed. Any function
executable by a character class (or an item class bot, which exhibits
character behavior) is referenced, upon parsing, by its name, a unique
character array. There may be duplicate functions... function is a class
with a reference to a function of one of several types, and can all be
accessed by the internal language, provided the author has sufficient
clearance. I'll give an example here of the classes that serve character
execution functions, the ones used by the command parser.

class execfunction: public named{
  // this is a base class, and has no real members
public:
  virtual bool execute(character *ch, mudstring &amp;input, 
                                      bool override, short mode);
};

class hardexec: public execfunction{
  bool (character::*execfunc)(mudstring &amp;input, bool override, 
                                                     short mode);
public:
  bool execute(character *ch, mudstring &amp;input, bool override,
                                                     short mode){
    return ch.*execfunc(input, override, mode);
  }
};

class softexec: public execfunction, public editable{
  program *execfunc;
public:
  bool execute(character *ch, mudstring &amp;input, bool override, 
                                                     short mode){
    runtime *newprogram = execfunc.init();
    newprogram.initcharacter(ch);
    newprogram.initstring(input);
    newprogram.initbool(override);
    newprogram.initmode(mode);
    bool newprogram.launch();
  }
  void readin(ifstream &amp;file);
  void writeout(ofstream &amp;file);
  void edit(mudstring &amp;input);
};

You get the idea. These can be attached to anything, for triggering, but
in the above case, will always fixate itself to the character 'ch' until
the runtime expires. A sample program for above use:

&gt; hunt           // the 'hunt' program

expect
  character ch   // acting character
  string input   // input string
  bool override  // override of 'instincts'
  short mode     // skill based failure mode
end expect

begin
                 // parse the string
string parseword = input:extract()
                 // search through all backpacks, etc for a drone
character drone = ch:getcharfromcontents("drone")

if(drone == null)                 
  // this will only happen if something goes wrong. There should be a
  // check for these drones in the skill that launches this command.
  ch:show("You don't have any hunting drones to deploy.\r\n")
  terminate
end if

drone:moveto(ch:room())
ch:show("You deploy a hunting drone."\r\n)

drone:execute(hunt2, parseword)

terminate
&amp;

&gt; hunt2

expect:
  character drone
  string target
end expect

pause(1) // wait a beat

if(drone:room():getchar(target) != null)
  if(drone:parent() == null)
    drone:master():show("Your drones have aquired a target!!")
    if(drone:room() == drone:parent():room())
      drone:master():show("The target is in this room!!"
    end if
  else
    drone:execute(alert, drone:master())
  end if
  terminate
end if

traverse(exit door = drone:room():exits())
  character newdrone = drone:clone()
  newdrone:addlevel(-1)
  newdrone:move(door)
  newdrone:setparent(drone)
  newdrone:execute(hunt2, target)
end traverse

terminate
&amp;


Still a little sketchy, but you get the idea. Not object oriented.. I was
trying for simplicity.. but a nice method of hybridization. These types of
functions can be called at every level of the code, but are limited to
existing classes. Maybe someone ambitious will correct that situation and
add object orientation in the future. I feel like I've made sufficient
contribution.

I'll post more later.



   __    _   __  _   _   ,  ,  , ,  
  /_  / / ) /_  /_) / ) /| /| / /\            First Light of a Nova Dawn
 /   / / \ /_  /_) / \ /-|/ |/ /_/            Final Night of a World Gone
Nathan F. Yospe - University of Hawaii Dept of Physics - yospe#hawaii,edu
</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00058.html">Re: MUD Design Digest V1 #52</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00059.html">Command Parsers, continued</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00059.html">Command Parsers, continued</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00100.html">command parsing</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00061"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00061"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>Re: Its nice to be back</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00005" HREF="msg00005.html">Re: Its nice to be back</A></strong>, 
Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Sat 15 Feb 1997, 16:51 GMT
</LI>
</ul>
</LI>
<LI><strong><A NAME="00062" HREF="msg00062.html">MUD Design Digest V1 #56</A></strong>, 
coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Wed 18 Dec 1996, 03:42 GMT
<LI><strong><A NAME="00060" HREF="msg00060.html">Re: Call for Opinions: MIGE</A></strong>, 
Chris Lawrence <a href="mailto:clawrenc#xsvr1,cup.hp.com">clawrenc#xsvr1,cup.hp.com</a>, Wed 27 Nov 1996, 17:18 GMT
<LI><strong><A NAME="00059" HREF="msg00059.html">Command Parsers, continued</A></strong>, 
Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Mon 25 Nov 1996, 01:28 GMT
<LI><strong><A NAME="00061" HREF="msg00061.html">Command Parsing</A></strong>, 
Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Sun 24 Nov 1996, 23:06 GMT
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00100" HREF="msg00100.html">command parsing</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Thu 13 Mar 1997, 15:00 GMT
</LI>
<LI><strong><A NAME="00102" HREF="msg00102.html">Re: command parsing</A></strong>, 
Adam Wiggins <a href="mailto:nightfall#inficad,com">nightfall#inficad,com</a>, Thu 13 Mar 1997, 16:22 GMT
</LI>
<LI><strong><A NAME="00125" HREF="msg00125.html">command parsing</A></strong>, 
claw <a href="mailto:claw#null,net">claw#null,net</a>, Tue 18 Mar 1997, 02:08 GMT
</LI>
<LI><strong><A NAME="00132" HREF="msg00132.html">Re: command parsing</A></strong>, 
claw <a href="mailto:claw#null,net">claw#null,net</a>, Tue 18 Mar 1997, 02:11 GMT
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>