! MakeMatch looks at how good a match is. If it's the best so far, then ! wipe out all the previous matches and start a new list with this one. ! If it's only as good as the best so far, add it to the list. ! If it's worse, ignore it altogether. ! ! The idea is that "red panic button" is better than "red button" or "panic". ! ! number_matched (the number of words matched) is set to the current level ! of quality. ! ! We never match anything twice, and keep at most 64 equally good items. ! ---------------------------------------------------------------------------- [ MakeMatch obj quality i; #Ifdef DEBUG; if (parser_trace >= 6) print " Match with quality ",quality,"^"; #Endif; ! DEBUG if (token_filter ~= 0 && UserFilter(obj) == 0) { #Ifdef DEBUG; if (parser_trace >= 6) print " Match filtered out: token filter ", token_filter, "^"; #Endif; ! DEBUG rtrue; } if (quality < match_length) rtrue; if (quality > match_length) { match_length = quality; number_matched = 0; } else { if (2*number_matched >= MATCH_LIST_SIZE) rtrue; for (i=0 : ii == obj) rtrue; } match_list-->number_matched++ = obj; #Ifdef DEBUG; if (parser_trace >= 6) print " Match added to list^"; #Endif; ! DEBUG ];