[213] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next next in chain last in chain last

Re: match_template() needs help with consistancy

daemon@ATHENA.MIT.EDU (Thu Apr 28 02:49:22 1994 )

From: stewarta@netcom.com (Alex Stewart)
To: ghudson@MIT.EDU (Greg Hudson)
Date: Wed, 27 Apr 1994 23:47:37 -0700 (PDT)
Cc: coldstuff@MIT.EDU
In-Reply-To: <9404280426.AA15198@maze.MIT.EDU> from "Greg Hudson" at Apr 28, 94 00:26:34 am

> My justification:
> * If the user wants to match a wildcard with something that includes
> text that would match the next word pattern, the user should simply
> quote the entire argument as a C string literal, and leave it at that.

I don't think anybody's objecting to this (if I understand what you're
referring to properly).

> * The user generally doesn't want any processing to get in the way
> when it's not necessary; therefore, no processing at all is done on
> the last argument.

This is bad.  It is bad quite simply because it means parsing is handled
differently in some cases than in others and it's not always immediately
obvious which is which.  Rules should be consistent for the entire match or not
exist at all.

> As far as I know, these rules are completely consistent with MOO's
> verb-dobj-preposition-iobj parsing rules, assuming the pattern is of
> the form "foo * bar *".

No, MOO parsing does not function this way (iobjstr quoting is handled exactly
the same as dobjstr quoting, the way it should be), nor does anything else that
I am familiar with.

> > match_template("f * d *", "f \"zz\" cc d foo") => ["f", "zz", "cc", "d", "foo"]

> According to these rules, a wildcard can (apparently) result in more
> than one field.  This requires in-db checking every time you match a
> template containing a wildcard, and worse, it is ambiguous: consider:

This was (I hope) an accident.  The above result should be ["f", "zz cc", "d",
"foo"], in my opinion, which does not produce such bugs and is consistent with
most standard quoting and parsing rules.

In short, I believe the following rules should be used for matching templates:

1.  Quoted portions should match only wildcards, never keywords.
2.  Toplevel quotes should be stripped from match_template output.
3.  Aside from this, standard wildcard rules apply.  Quotes have no
significance in field separation aside from the requirement that a quoted
portion cannot be broken into multiple fields and no portion of it can match a
4.  All rules are consistently applied throughout the match.

Basically, quotes just say "this is not a keyword and it is all one thing" and
that's all they do, and they are transparent to anything beyond the parsing