"(c) Copyright 1978, Massachusetts Institute of Technology. All rights reserved." > > > >>> "Create the structure in which prepositional phrases are stored at parse time. Don't bother when COMPILEing or GLUEing." > (LAST-IT) OBJECT (PREPVEC) > "Randomness" ;"funny falses for SEARCH-LIST and FWIM" ;"VERBs which take BUNCHes" > (BUNCHERS) > \ "EPARSE -- top level entry to parser. calls SPARSE to set up the parse-vector, then, calls SYN-MATCH to see if the sentence matches any syntax of the verb given. If a syntax matches, the orphan vector is cleared out. If no syntax matches, the appropriate message is printed in SYN-MATCH (or below). Only the T/Fness of the value is interesting." > >> ) > (PV LV) (VERB) VERB (ACT) (VB) (STR) STRING (OBJ) (BOBJ) OBJECT (LEN) FIX (UNK) >) > > "AGAIN"> ) ( <=? .STR "O">> .UNK> > 0 > > > .LEN>>> > > )> > > > > <>) (> > ACTION> >>>> >) (<==? .VAL WIN> >) ( > > OBJECT> >) (>)>)> > ,BUNCHERS> > ) (T)>) (>>> "'.">> <>)>) (T)>)>)>> "SPARSE -- set up parse vector. This is done in two steps. In the first, each word of the input is looked up in the various interesting oblists. If a DIRECTION is seen before an ACTION, the parse wins. Also, if any word is not found, the parse fails. As various parts of speech are found, variables are set up saying so In the second, the vector and variables resulting are checked. Any missing are (attempted to be) set up from the orphans of the last parse. If they can't be new orphans are generated. There are three possible results of all this: WIN, which means the parse is done and no syntax checking is needed; the Parse-Vector, meaning the parse needs to have syntax checking done; and a FALSE, meaning the parse has failed." ) (PVR 1 <>> 2 <>>) (ACTIONS ,ACTIONS-POBL) (DIRS ,DIRECTIONS-POBL) FX ROBJ (ORPH ,ORPHANS) (ORFL ) (ANDFLG <>) (HERE ,HERE) (ACTION <>) (PREP <>) (ADJ <>) (BOBJS ,BUNUVEC) (BUNCHFLG <>) NPREP PPREP OBJ POBJ LOBJ NOBJ VAL AVAL (ANDLOC <>) (PREPVEC ,PREPVEC) OS) #DECL ((SV) (VB ORFL BUNCHFLG CONTIN) (ACTIONS WORDS OBJOB DIRS) POBLIST (PV ORPH PVR) VECTOR (FX) FIX (ROBJ EXCEPT) OBJECT (VAL ANDFLG) (HERE) ROOM (ACTION) (NPREP PREP) (ADJ) (AVAL POBJ) ANY (PREPVEC) (LOBJ NOBJ OBJ) (PPREP) PHRASE (SPAROUT) ACTIVATION (BOBJS) (ANDLOC) (OS) VECTOR>>) > (X) PSTRING (Y) STRING) > ) (<=? .Y "THEN"> >> )> ) (<=? .Y "AND"> >> )> )> > >> > ) ( > >> > >>> > > ) (> ;"preposition or adjective?" <>) ;"flush if verb" ( ;"preposition?" <>>>> > > > > ) ( .PACT>)>) (.PREP) ( > > > T)>) ( ;"adjective?" > >>>>) (T)>>) (> ;"object?" >) ( .PACT>)>) (ELSE > )>> ;"is object accessible?" 2> >> > > > > > >>> > 1 .FX>> ) (> .PACT>)>) (.ANDFLG > 1 <1 >>>> > 1 .OBJ> > ) (<==? .PREP > > .OBJ>) (> .PACT>)>) (> > > >) ( .PACT>)> ;"lose, mentioned more than two objects") ( >> OBJECT> <>>>) (ELSE ;"interpret why can't find/see/access object for loser" >) (<==? .VV > ) (ELSE > <1 >> <1 >> FIX>> )> <3 .VV>> <3 .VV>> FIX>>)> >) ()>>) (<==? .OBJ ,NEFALS2> >> ".">> > T) (T >>> <2 .PV> .PREP >>> <3 .VV>> <3 .VV>> FIX>> > "?">) ()>)>)> .PACT>)> > T) (ELSE ;"inform of unknown word" > ) ( <3 .VV>> <3 .VV>> FIX> "'.">)>> .PACT>)> >> )>>> > > > <>>> >> > > >>) (> " here.">>> .SPAROUT>)>>) ( >>>> OBJECT> ;"ask about orphan object" > "?">) ()>> <2 .PV>> <>) ( <2 .PV> .ADJ> > <>) (> ;"orphan prep.?" > <==? <1 .PV> > > OBJECT> .AVAL) (.AVAL <2 .AVAL>)>> > 1 .NPREP> > ) ()>>> > ;"orphan object" ) ()> <>>) (.PREP ;"handle case of 'pick frob up': make it 'pick up frob'" >> OBJECT> ;"if hanging prep., make a prep. phrase" > > ) ()>>> ;> 1 .PPREP> .PV) ( .PREP> .PV)>) (.PV)>)>> (PREPVEC) (PVR) VECTOR (VB) (PPREP) PHRASE (STUFFACT) ACTIVATION (STUFF) ) > > .OBJ> .STUFFACT>) (> .STUFFACT>)>)> > <>) (> > ) ()>>> ) (.OBJ)>> >)>> \ "GET-IT-OBJ -- decide what 'IT' is referring to. Algorithm is highly random and subject to change without notice." ) > OBJECT> >>> .OBJ) ( >> .LI) (>) (>) ( <>>)>> )) #DECL ((L) (OBJ) ) )>> .L> .OBJ> \ "SYN-MATCH -- checks to see if the objects supplied match any of the syntaxes of the sentence's verb. if none do, and there are several possibilities, the one marked 'DRIVER' is used to try to snarf orphans or if all else fails, to make new orphans for next time." ) (OBJS ) (O1 <1 .OBJS>) (O2 <2 .OBJS>) (DFORCE <>) (DRIVE <>) (GWIM <>) (ORPH ,ORPHANS) SYNN (PREP? >)) #DECL ((ACTION) ACTION (PV OBJS) VECTOR (DRIVE DFORCE) (O1 O2) (SYNN) VARG (GWIM) (SYN-ACT) ACTIVATION (ORPH) VECTOR (PREP?) ) .O1> ;"direct object ok?" .O2> ;"indirect object ok?" > >> .SYN-ACT>) ( ;"no indirect object? might still be okay" ) ( <==? .PREP? >>> ;"last tried is default if no driver")>)>) ( .O1>> ;"make 'kill with knife' work, etc." ;"**coming soon to a parser near you!**" > ;"new winning OSLOT2 in orphans for total win" T ;"i.e. turn with wrench => turn what with wrench?")> > ) ( <==? .PREP? >>> )>)>> > > ;"lost for bad syntax" > ;"here try to fill direct object slot" >> > ;"try to fill slot from orphan" >>>> <> <2 .OBJS>> ;"all failed, orphan the verb and prep." >) (> ;"here try to fill indirect object slot" >> > >> >> > ;"all failed, orphan the world" ) (ELSE >>)>) (ELSE <>)>> "SYN-EQUAL -- takes a VARG and an object or phrase. is the object acceptable? That is, is the prep. (if any) a match, and is the object ok (meaning do the OFLAGS slot of the object and the VBIT slot of the verb agree. Example: the object you ATTACK must be a 'victim'). The VFWIM slot is used to determine what objects to try to take." )) #DECL ((VARG) VARG (POBJ) (VBIT) FIX) <1 .POBJ>> .VBIT>>) ( > >) ( <0? .VBIT>>)>> \ "TAKE-IT-OR-LEAVE-IT -- finish setup of parse-vector. take objects from room if allowed, flush prepositions from prepositional phrases. Its value is more or less ignored by everyone." ) (PV2 <3 .PV>) OBJ) #DECL ((SYN) SYNTAX (PV) VECTOR (PV1 PV2) (OBJ) ) .PV1) ( <2 .PV1>)>>> ) (.OBJ > >>)> .PV2) ( <2 .PV2>)>>> >>> T>> "TAKE-IT -- takes object, parse-vector, and syntax bits, tries to perform a TAKE of the object from the room. Its value is more or less ignored." ) ,STAR-BITS> FIX>>>) ( > >> "."> <>) (> >) ( "."> <>)>) (> >) (>) ( "."> <>)>) (>) ( <>>> ) ( <>)>) (>) ( "."> <>)>> "DO-TAKE -- perform a take, returning whether you won" ) (SAV2 <2 .PV>) (SAV3 <3 .PV>)) #DECL ((OBJ) OBJECT (PV) VECTOR (SAV1) (SAV2) (SAV3) (RES) ANY) > > ) ()>> .RES> \ "--------------------------------------------------------------------- GWIM & FWIM -- all this idiocy is used when the loser didn't specify part of the command because it was 'obvious' what he meant. GWIM is used to try to fill it in by searching for the right object in the adventurer's possessions and the contents of the room. ---------------------------------------------------------------------" "GWIM-SLOT -- 'get what i mean' for one slot of the parse-vector. takes a slot number, a syntax spec, an action, and the parse-vector. returns the object, if it won. seems a lot of pain for so little, eh?" > ) ) ( .VARG>> .OBJ)>> "GWIM -- 'get what i mean'. takes attribute to check, what to check in (adventurer and/or room), and verb. does a 'TAKE' of it if found, returns the object." ) (ROBJ? ) (DONT-CARE? >) (AOBJ <>) ROBJ (AV )) #DECL ((BIT) FIX (FWORD) VARG (DONT-CARE? AOBJ? ROBJ? CARE?) (AOBJ ROBJ AV) ) .DONT-CARE?>>)> > .ROBJ? > .DONT-CARE?>> <==? .AV .ROBJ> > >> .ROBJ>)>) (>> ,NEFALS) (.AOBJ)>) (.AOBJ)>> "FWIM -- takes object specs, list of objects to look in, and whether or not we care if can take object. find one that can be manipulated (visible and takeable, or visible and in something that's visible and open)" )) #DECL ((NO-CARE) (BIT) FIX (OBJS) (NOBJ) (DWIM) ACTIVATION) > > )> )> > > ) ()>)>> >)>> .OBJS> .NOBJ> \ "GET-OBJECT -- used to see if an object is accessible. it looks for an object that can be described by an adjective-noun pair. Takes atom (from objects oblist), adjective, and verbosity flag. grovels over: ,STARS; ,HERE; ,WINNER looking for object (looks down to one level of containment). returns: #FALSE () -- if fails because can't find it or it's dark in room NEFALS = #FALSE (1) -- ambiguous object NEFALS2 = #FALSE (2) -- can't reach from in vehicle or object -- if found it. " ) (HERE ,HERE) (AV ) (CHOMP <>) (LIT ) (NEFALS ,NEFALS)) #DECL ((OOBJ OBJ AV) (OBJNAM) PSTRING (HERE) ROOM (ADJ) (CHOMP) (NEFALS) FALSE (OBJL) > (LIT) (GET-OBJ) ACTIVATION) .ADJ>>> >> >> ) ()>) ( >> )> .ADJ>> > ) (> )>)> .ADJ>> > >> .NEFALS) (> .OBJ) (T .OOBJ)>) (T .NEFALS)>) (.OBJ)>) (> .NEFALS) (.CHOMP ,NEFALS2) (.OOBJ) (>) (.ADJ > >> .OBJ)>)>> "SEARCH-LIST -- search room, or adventurer, or stars, or whatever. takes object name, list of objects, and verbosity. if finds one frob under that name on list, returns it. search is to one level of containment. " ) "AUX" (OOBJ <>) (NEFALS ,NEFALS) NOBJ (AMBIG-EMPTY <>)) #DECL ((OBJNAM) PSTRING (SLIST) (OOBJ NOBJ) (ADJ) (FIRST? AMBIG-EMPTY) (NEFALS) FALSE (SL) ACTIVATION (GLOBAL?) >) > >> ) (> ) ()>) ()>) ()>)> > >> .ADJ <>>> ) ()>) (<==? .NOBJ .NEFALS> )>)>> .SLIST> >>> .NEFALS) (.OOBJ)>> \ <> <> <> <> <>]> ) (ACTION <>) (SLOT1 <>) (PREP <>) (NAME <>) (SLOT2 <>)) #DECL ((FLAG) (NAME) (ACTION) (SLOT1 SLOT2) (PREP) ) ,ONAME .NAME> ,OPREP .PREP> ,OSLOT1 .SLOT1> ,OVERB .ACTION> ,OFLAG .FLAG>) (> >)>> ) ORPHAN) #DECL ((SYN) VARG (OBJS ORPH) VECTOR (ORFL) (ORPHAN) (SLOT) FIX) <>) ( ) ()>> >)>> ) "AUX" (PREP )) #DECL ((VARG) VARG (ACTION) ACTION (PREP) (GWIM) (SLOT2) ) 0 " "> 0 " ">> 1 " what?">) ( 0 " what "> > 0 " the " >> ) ( 1 " what?">)> <>> \ "PRSTR -- printing routine to print uc/lc atom pname" > <>>> ) >> > T T>> 5>> 15>> 5>> )) #DECL ((STR) STRING (LEN) FIX) >)) #DECL ((S) STRING (C) FIX) > >> >>)> >> )>> .STR>> )) #DECL ((STR NAM) STRING (1ST LC) ) >)) #DECL ((X Y) STRING (A) FIX) .1ST <==? .X .NAM>> >) (> >> >) (>>)>> .NAM .STR> .STR> \ ;"Here is some code for handling BUNCHes." ; "Action function for BUNCHing. ,BUNCH = UVECTOR of OBJECTS in the bunch ,BUNCH-SYN = SYNTAX for this call (for TAKE-IT-OR-LEAVE-IT) BUNCHEM sets up PRSVEC for each object in the bunch, tries to do the TAKE, etc. if necessary and calls the VERB function. " ) (VFCN ) (PV ,PRSVEC) (OBJS ,BUNCH) (SYN ,BUNCH-SYN) (HERE ,HERE) (BUN ) (EV )) #DECL ((VERB) VERB (VFCN) RAPPLIC (PV) VECTOR (HERE) ROOM (EV) (OBJS) (SYN) SYNTAX (BUN) OBJECT) > > ) (>) OBJ) #DECL ((BUN) (OBJ) OBJECT) >>> 0 ": "> )> > >>)>> "PARSER AUXILIARIES" ;"SET UP INPUT ERROR HANDLER TO CAUSE EPARSE TO FALSE OUT" > (OBJNAM) PSTRING (OBJ) OBJECT (ADJ) ) > FIX> 0>> >> ) (>)>)>> (BRKS) STRING> >) "AUX" (BRKS ,BRKS) (V ,LEXV1) (TV .V) (S1 .S) (QUOT <>) (BRK !\ ) CNT T (THEN-STR <>) (THEN-VEC <>) (INPLEN <- >)) #DECL ((S S1 SX BRKS T) STRING (SILENT? QUOT) (VALUE) (TV V) (INPLEN CNT) FIX (BRK) CHARACTER (THEN-STR) (THEN-VEC) ) ) >>> > >> !\?> 4>>> .TV) () > >> > !\;> > >> > > <==? <1 .S1> !\">>> >) ()>)> <==? .BRK !\,>> <- ,LEXSIZE 1>> > "AND"> > "THEN">>> 3>>>) ( 4>>> )> >) ( >) ( >> 5>> .SLEN>>>> >> >)> >> >)>)> 3>>> >) (<==? .BRK !\.> 4>>> > >)> <- ,LEXSIZE 1>> >> "AND"> <=? .T "THEN">> >> "AND"> <=? .T "THEN">> > 1 >>>>)>)> > <==? .BRK !\;>> >>> "AND"> <=? .T "THEN">>> >>>)> )> >)> >>)>> (INPLEN FOO) FIX (INBUF) STRING (VEC) >) ) ( <- .INPLEN>>> .FOO>>>> ) >>> > >> )>> >)) #DECL ((S) STRING (C) FIX) > >>)>> .STR> .STR>