Interactive Parsing

version 3 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Section 2 - Verbs

    Include (-
        ! Only check for a comma (a "someone, do something" command) if we are
        ! not already in the middle of one. (This simplification stops us from
        ! worrying about "robot, wizard, you are an idiot", telling the robot to
        ! tell the wizard that she is an idiot.)
        
        if (actor == player) {
            for (j=2 : j<=num_words : j++) {
                i=NextWord();
                if (i == comma_word) jump Conversation;
            }
        }
        jump NotConversation;
        
        ! NextWord nudges the word number wn on by one each time, so we've now
        ! advanced past a comma. (A comma is a word all on its own in the table.)
        
        .Conversation;
        
        j = wn - 1; ! Now j = word number of the comma itself

    ! ------------IP CHANGE HERE-----------------
        MatchUpTo(j, EX_VERB, "Verb not found, was it conversation?");
    ! ------------IP CHANGE DONE-----------------

        if (j == 1) {
            L__M(##Miscellany, 22);

    ! ------------IP CHANGE HERE-----------------
            if (pre_command == PERFORMING)
                pre_command = ERROR_GIVEN;
            MatchUpTo(0, EX_VERB, "Not conversation!");
    ! ------------IP CHANGE DONE-----------------

            jump ReType;
        }

        ! Use NounDomain (in the context of "animate creature") to see if the
        ! words make sense as the name of someone held or nearby
        
        wn = 1; lookahead = HELD_TOKEN;
        scope_reason = TALKING_REASON;
        l = NounDomain(player,actors_location,6);
        scope_reason = PARSING_REASON;
        if (l == REPARSE_CODE) jump ReParse;
        if (l == 0) {
            if (verb_word && ((verb_word->#dict_par1) & 1)) jump NotConversation;
            L__M(##Miscellany, 23);
            
    ! ------------IP CHANGE HERE-----------------
            if (pre_command == PERFORMING)
                pre_command = ERROR_GIVEN;
    ! ------------IP CHANGE DONE-----------------

            ! No MatchUpTo as we've used Noun Domain
                    
            jump ReType;
        }
        
        .Conversation2;
        
        ! The object addressed must at least be "talkable" if not actually "animate"
        ! (the distinction allows, for instance, a microphone to be spoken to,
        ! without the parser thinking that the microphone is human).
        
        if (l hasnt animate && l hasnt talkable) {
            L__M(##Miscellany, 24, l);
            
    ! ------------IP CHANGE HERE-----------------
            if (pre_command == PERFORMING)
                pre_command = ERROR_GIVEN;
    ! ------------IP CHANGE DONE-----------------

            jump ReType;
        }
        
        ! Check that there aren't any mystery words between the end of the person's
        ! name and the comma (eg, throw out "dwarf sdfgsdgs, go north").
        
        if (wn ~= j) {
            if (verb_word && ((verb_word->#dict_par1) & 1)) jump NotConversation;
            L__M(##Miscellany, 25);

    ! ------------IP CHANGE HERE-----------------
            if (pre_command == PERFORMING)
                pre_command = ERROR_GIVEN;
    ! ------------IP CHANGE DONE-----------------

            jump ReType;
        }
        
        ! The player has now successfully named someone. Adjust "him", "her", "it":
        
        PronounNotice(l);
        
        ! Set the global variable "actor", adjust the number of the first word,
        ! and begin parsing again from there.
        
        verb_wordnum = j + 1;
        
        ! Stop things like "me, again":
        
        if (l == player) {
            wn = verb_wordnum;
            if (NextWordStopped() == AGAIN1__WD or AGAIN2__WD or AGAIN3__WD) {
                L__M(##Miscellany, 20);

    ! ------------IP CHANGE HERE-----------------
                if (pre_command == PERFORMING)
                    pre_command = ERROR_GIVEN;
    ! ------------IP CHANGE DONE-----------------

                jump ReType;
            }
        }
        
        actor = l;
        actors_location = ScopeCeiling(l);
        #Ifdef DEBUG;
        if (parser_trace >= 1)
            print "[Actor is ", (the) actor, " in ", (name) actors_location, "]^";
        #Endif; ! DEBUG
        jump BeginCommand;

    -) instead of "Parser Letter C" in "Parser.i6t".