



MakeMatch (lines 3938-3972)
Back to List
Browsing parserm.h
3938 ! MakeMatch looks at how good a match is. If it's the best so far, then
3939 ! wipe out all the previous matches and start a new list with this one.
3940 ! If it's only as good as the best so far, add it to the list.
3941 ! If it's worse, ignore it altogether.
3942 !
3943 ! The idea is that "red panic button" is better than "red button" or "panic".
3944 !
3945 ! number_matched (the number of words matched) is set to the current level
3946 ! of quality.
3947 !
3948 ! We never match anything twice, and keep at most 64 equally good items.
3949 ! ----------------------------------------------------------------------------
3950
3951 [ MakeMatch obj quality i;
3952 #Ifdef DEBUG;
3953 if (parser_trace >= 6) print " Match with quality ",quality,"^";
3954 #Endif; ! DEBUG
3955 if (token_filter ~= 0 && UserFilter(obj) == 0) {
3956 #Ifdef DEBUG;
3957 if (parser_trace >= 6) print " Match filtered out: token filter ", token_filter, "^";
3958 #Endif; ! DEBUG
3959 rtrue;
3960 }
3961 if (quality < match_length) rtrue;
3962 if (quality > match_length) { match_length = quality; number_matched = 0; }
3963 else {
3964 if (2*number_matched >= MATCH_LIST_SIZE) rtrue;
3965 for (i=0 : i<number_matched : i++)
3966 if (match_list-->i == obj) rtrue;
3967 }
3968 match_list-->number_matched++ = obj;
3969 #Ifdef DEBUG;
3970 if (parser_trace >= 6) print " Match added to list^";
3971 #Endif; ! DEBUG
3972 ];
Last updated 27 February 2004. The librarian in charge of this page is Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight. Please email any comments, suggestions or corrections to cedenqs@inform-fiction.org.