Interactive Parsing

version 3 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 4 - Run the Parser over what we've got So far

    Section 1 - Colour based on parse results

    Include (-

    [ ColourByAdvanceParse
        i
        ;

        command_in_full = false;
        

    #ifdef DEBUG_ADVANCE_PARSING;
        glk_set_window((+main-window+).ref_number);
        print "++++++^";
    #endif;

            word_understood_to = PerformAdvanceParse(true);

    #ifdef DEBUG_ADVANCE_PARSING;
        glk_set_window((+main-window+).ref_number);

    ! print "Scored ", word_understood_to, ".^";
    ! print "-------^";
    #endif;

        if (word_understood_to < WordCount())
        {
            for (i = word_understood_to + 1 : i<= WordCount() : i++)
            {
                if (word_colours->i == VALID)
                    ! we knew the word, but it's not where the parser wants it to be
                    word_colours->i = MISPLACED;
                    
            }
        }
        for (i = 1 : i <= word_understood_to : i++)
        {
            if (word_colours->i == ERROR )
                ! we didn't know the word, but the parser accepted it => it's a <any text> input, so we accept (!!)
                word_colours->i = VALID;
        }
        
    ];

    -)