Newsgroups: rec.arts.int-fiction
Subject: Re: Custom parsing, or what? [Inform]
References: <3d193204$0$79555$3c090ad1@news.plethora.net> <3d19428a$1@news.uow.edu.au>
X-Newsreader: NN version 6.5.6 (NOV)
From: kaf03@uow.edu.au (Kenneth Alexander Finlayson)
NNTP-Posting-Host: nepthys.cs.uow.edu.au
Message-ID: <3d194a76@news.uow.edu.au>
Date: 26 Jun 2002 15:00:38 +1000
X-Trace: news.uow.edu.au 1025067638 nepthys.cs.uow.edu.au (26 Jun 2002 15:00:38 +1000)
Organization: University of Wollongong
Lines: 59
Path: news.duke.edu!newsgate.duke.edu!nntp-out.monmouth.com!newspeer.monmouth.com!news.maxwell.syr.edu!news1.optus.net.au!optus!news.usyd.edu.au!news.newcastle.edu.au!news.uow.edu.au!kaf03
Xref: news.duke.edu rec.arts.int-fiction:105479

kaf03@uow.edu.au (Kenneth Alexander Finlayson) writes:

>seebs@plethora.net (Peter Seebach) writes:

>>I
>>can't add my own parsing routine, so far as I can tell, because any
>>parsing routine I wish to add has to return some object's number, if
>>it is to succeed

>parse_name is your friend. [...] Some generous soul may post a
>working example, but for the time, I shall direct you to the DM, since
>my Inform is rusty.

But, it appears, not so rusty that I can't hack out a simple solution:

Object  calendar "calendar" Break_Room
 with   parse_name
        [ w matches;

                matches = 0;

                while( w = NextWord() )
                {
                        switch(w)
                        {
                                'ms', 'calendar':
                                        matches++;

                                'jan', 'january':
                                        self.month = 1;
                                        matches++;

                                'feb', 'february':
                                        self.month = 2;
                                        matches++;

                                ! etc.
                        }
                }

                return matches;
        ],
        month 7,
        description
        [;
                "The calendar is turned to the ", self.month,
                "th month.";
        ];

I admit this is not a terribly sophisticated object. For instance,
a player could EXAMINE MS AUGUST FEBRUARY and have Ms. February
described. But it illustrates parse_name, and does what you want
(or at least, lays the groundwork).

Cheers,
Ken
--
If ever there was a show made for women, this is it.
                              -- Paul Zalunardo, writing about "Friends"
