1999Q2/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev] Text Parsing -->
<!--X-From-R13: Dbff @vpbyy <eavpbyyNybfgvpf.qrzba.pb.hx> -->
<!--X-Date: Tue, 1 Jun 1999 14:01:00 &#45;0700 -->
<!--X-Message-Id: Pine.LNX.4.10.9906012003460.463&#45;100000#lostics,demon.co.uk -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 005401beabd2$9eb9a140$0100a8c0@hell -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev] Text Parsing</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:rnicoll#lostics,demon.co.uk">
</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="msg00371.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00373.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00368.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00369.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00372">Author</A>
&nbsp;|&nbsp;<A HREF="#00372">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00372">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev] Text Parsing</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: Re: [MUD-Dev] Text Parsing</LI>
<LI><em>From</em>: Ross Nicoll &lt;<A HREF="mailto:rnicoll#lostics,demon.co.uk">rnicoll#lostics,demon.co.uk</A>&gt;</LI>
<LI><em>Date</em>: Tue, 1 Jun 1999 21:38:01 +0000 (GMT)</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Sender</em>: <A HREF="mailto:mud-dev-admin#kanga,nu">mud-dev-admin#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
On Tue, 1 Jun 1999, Kylotan wrote:

&gt; &gt; Wouldn't take much memory, but coding time would be very, very long
&gt; &gt; compared to a simple parser, and it would have a much higher CPU usage
&gt; &gt; too (although that may not make so much of a difference).
&gt; Well, I would have thought that something that used to execute within half
&gt; a second on a Z80 CPU would not be a problem, performance-wise.
Really depends on if you're using an interpreted/byte compiled internal
language...

&gt; But then, if I fully understood what was going on here, I wouldn't need
&gt; to be asking :)  I expect, however, that the code in modern
&gt; interactive-fiction engines such as Inform or Tads has a lot more code
&gt; than is needed for a parser of the complexity I am talking about.
Don't think either is really that much ahead actually. Hangon, I'll dig up
some code...

Verb 'take' 'carry' 'hold'
                * multi                          -&gt; Take
                * 'off' worn                     -&gt; Disrobe
                * multiinside 'from' noun        -&gt; Remove
                * multiinside 'off' noun         -&gt; Remove
                * 'inventory'                    -&gt; Inv;


That was a definition for one of the basic functions (suprise suprise).
Basically it defines, for these arguments, use this function. The
difficult bit is working out what arguments are which. Each function can
have globally defined functions that are called before and/or after it is
called, aswell as similar functions of each object.

Hmmm. Okay, I find it easiest to code from examples:

&gt; take the big red chair

I'm pretty sure my MUD could handle that perfectly well. Each object has
it's name (chair, in this case), aliases (chair could also be seat), and
adjectives (big, red and wooden would work here). If you want a copy of
the function that identifies objects, tell me. It's pretty hideous
though...

Another example:

&gt; take cookie then eat cookie

My MUD would fall over at this. It was never hold how to deal with "then".
Simplest method seems to be to split commands up around "then".

&gt; say what happened then
[pauses to shuffle his HDs partitions around]

Would cause problems with that though, as it would create two commands,
"say when happened" and "", so some way of indicating that arguments
should be passed straight onto the function, instead of being parsed,
should probably be included.

At this stage, the program can try sorting through the arguments. So, the
order so far is:

1. Take in a command.
2. Find the function that matches the first word of the command.
3. If the function specifies that arguments should not be parsed, pass the
   arguments straight into the function.
4. Otherwise split up the command into several commands, and parse each
   individually.

Back to the "take" command, as used in Inform. Let's look at the most
simple usage:

&gt; take cup

Anything can parse that. What about a list:

&gt; take cup and saucer

No problem, just split around "and", and call the function for each in
turn. But if we want want three objects, do we write:

&gt; take cup and saucer and spoon

or

&gt; take cup, saucer and spoon

in which case, we have to make sure that the program doesn't start trying
to find "cup," in the room.

Second syntax "take off &lt;object&gt;". Here it gets really fun:

&gt; take off coat

seems simple enough. Thing is, do you first check for an object that can
be described as an "off coat", or first check through the list of possible
arguments to "take" for a match? The first options starts adding reserved
words ("off button" anyone?), the second one has problems with other
syntaxes:

&gt; take small box from wooden table

A search for this syntax would probably be best implemented as a search
for "from", and then a check that the syntax is okay, if a "from" is
found. There is also:

&gt; take gold ring from the small box from wooden table

but quite frankly, anyone typing that in deserves everything they get.

So for parsing the command, after it is split up appropriately, the
sequence that works best is probably:

1. Go through all possible syntaxes of command, checking for a match.
2. Go with first syntax match, or print error message if there are none.
3. Parse lists of objects, splitting around commas and "and"s.
4. Pass the resulting mess to the function.

Although 4 might be a lot simpler if the function was just called once for
each item in a list.

I'd actually really appreciate comments on other possible
problems/solutions with this, because it's looking writable, so I might
just try implementing it all in my latest driver.
-- 
  _   __  __  __
 /_) / / (_  (__
/\  /_/  __)   /
______________/




_______________________________________________
MUD-Dev maillist  -  MUD-Dev#kanga,nu
<A  HREF="http://www.kanga.nu/lists/listinfo/mud-dev">http://www.kanga.nu/lists/listinfo/mud-dev</A>


</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00366" HREF="msg00366.html">Re: [MUD-Dev] Text Parsing</A></STRONG>
<UL><LI><EM>From:</EM> "Kylotan" &lt;kylotan#kylotan,force9.co.uk&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00371.html">Re: [MUD-Dev] Text Parsing</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00373.html">Re: [MUD-Dev] Multi-threaded mud server.</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00368.html">[MUD-Dev] Re[2]: [MUD-Dev] Text Parsing</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00369.html">Re: [MUD-Dev] Text Parsing</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00372"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00372"><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: [MUD-Dev] Text Parsing</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00363" HREF="msg00363.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Kylotan <a href="mailto:kylotan#kylotan,force9.co.uk">kylotan#kylotan,force9.co.uk</a>, Tue 01 Jun 1999, 00:06 GMT
<UL>
<LI><strong><A NAME="00364" HREF="msg00364.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Ross Nicoll <a href="mailto:rnicoll#lostics,demon.co.uk">rnicoll#lostics,demon.co.uk</a>, Tue 01 Jun 1999, 00:30 GMT
<UL>
<LI><strong><A NAME="00366" HREF="msg00366.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Kylotan <a href="mailto:kylotan#kylotan,force9.co.uk">kylotan#kylotan,force9.co.uk</a>, Tue 01 Jun 1999, 02:04 GMT
<UL>
<LI><strong><A NAME="00368" HREF="msg00368.html">[MUD-Dev] Re[2]: [MUD-Dev] Text Parsing</A></strong>, 
Travis Casey <a href="mailto:efindel#io,com">efindel#io,com</a>, Tue 01 Jun 1999, 02:41 GMT
</LI>
<LI><strong><A NAME="00372" HREF="msg00372.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Ross Nicoll <a href="mailto:rnicoll#lostics,demon.co.uk">rnicoll#lostics,demon.co.uk</a>, Tue 01 Jun 1999, 21:01 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00369" HREF="msg00369.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Mik Clarke <a href="mailto:mikclrk#ibm,net">mikclrk#ibm,net</a>, Tue 01 Jun 1999, 05:48 GMT
<UL>
<LI><strong><A NAME="00371" HREF="msg00371.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Marc Hernandez <a href="mailto:marc#ias,jb.com">marc#ias,jb.com</a>, Tue 01 Jun 1999, 06:24 GMT
</LI>
</UL>
</LI>
</ul>
<LI><strong><A NAME="00375" HREF="msg00375.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Wed 02 Jun 1999, 01:38 GMT
<UL>
<LI><strong><A NAME="00376" HREF="msg00376.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Ross Nicoll <a href="mailto:rnicoll#lostics,demon.co.uk">rnicoll#lostics,demon.co.uk</a>, Wed 02 Jun 1999, 03:49 GMT
</LI>
</UL>
</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>