MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: Parser Problem



On Wed, 30 Aug 1995, Coolin MacKaarmick wrote:

> 
> I'm getting a strange parser error, and I'd love it if someone could 
> explain it/help me work around it.
> 
> ------------------------------
> @verb me:@junk this none any
> @program me:@junk
> player:tell("Hello, world.");
> ..
> 
> @junk me
> Hello, world.
> 
> @junk me nothing
> I don't understand that.

Try writing in-db parsing ;) The tough thing about parsing this would be
that it has to check ALL possibilities, for example, parsing this,
assuming it was 'give <object> <object>'

give lost dog a doggie treat

Assuming you match the largest possible string, and get smaller, the 
matching would go like this:  (This is also assuming the in-db parsing 
seperates things with spaces)

match obj:  lost dog a doggie treat
match obj:  lost dog a doggie
match obj:  lost dog a
match obj:  lost dog   (MATCHED DOBJ)

match obj:  a doggie treat (MATCHED IOBJ)
...
Or, if you started with the SMALLEST possible string:

match obj:  lost
match obj:  lost dog   (MATCHED DOBJ)

match obj:  a
match obj:  a doggie
match obj:  a doggie treat  (MATCHED IOBJ)


...And what about aliases?  If the MOO matched the small part of the 
object, 'a' would have matched...  Making 'doggie treat' seem like junk 
at the end of the command... the parser will think '<object> <object> 
<junk> != <object> <object>'

Compare that TERRIBLE UNEFFICENT WASTEFUL SLOW LAGGY TICK-INTENSIVE 
CPU-HUNGRY statement to:

Find prep
match obj:  what's before the prep
match obj:  what's after the prep

...done.


This brings to mind a new type of parsing.  I haven't got a name for it.. 
'cause I think I stole it from how I *think* muds do it.  As soon as an 
object is either in the room with the player, or in their inventory, it's 
added to a list of commands the player can type.  When the player types 
the command, the object's (whatever) is invoked, and it takes care of the 
rest of the parsing.   A simple 'read' will work for a note in the room, 
even if you don't type it's name.  I've successfully implemented this at 
my RPG MOO, but haven't found anything that will use it... YET.

- Kipp


References:

Home | Subject Index | Thread Index