Interactive Parsing

version 3 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 2 - Simple Dictionary Check

    Include (-

    [ GetBaseColourOfNextWord wordnum print_buffer
        i j
        ;

        wn = wordnum;
        i = NextWordStopped();
        if (i == 0) return ERROR;
        
        j = RetrieveLongerVersionOf(i);
        if (j == i) return VALID;

    ! glk_set_window((+main-window+).ref_number);
    ! print "Checking full-length word for ", (address) i, " which is ", (string) j, " ... ";

        if (CompareTextAndPlayersInput(j, wordnum, print_buffer))
        {
    ! print " okay!^";
            return VALID;
        }
        
    ! print " no good...^";
        return LONGWORD_ERROR;
        
    ];

    [ ColourLastWord print_buffer word_num;

        if (word_colours->word_num ~= VALID && ~~LastWordFinished(print_buffer, word_num))
            word_colours->word_num = NORMAL;

    ];

    [ LastWordFinished print_buffer wordnum i;
        if (wordnum == WordCount())
            i = (print_buffer-->0);
        else
            i = CharacterNumber(wordnum + 1);
        return (print_buffer->(i + WORDSIZE - 1) == ' ' or '.' or ',' or '"');

    ];

    -);