DEFINITION MODULE WildCard;

        (********************************************************)
        (*                                                      *)
        (*            String matching with wildcards            *)
        (*                                                      *)
        (*  Programmer:         P. Moylan                       *)
        (*  Started:            12 November 2019                *)
        (*  Last edited:        17 November 2019                *)
        (*  Status:             Working                         *)
        (*                                                      *)
        (* Yet another approach to both-ends scanning.  This    *)
        (* turns out to be the fastest of my wildcard string    *)
        (* matching algorithms, so for now I am setting it as   *)
        (* the default.                                         *)
        (*                                                      *)
        (********************************************************)


TYPE CharSet = SET OF CHAR;

PROCEDURE WildMatch (VAR (*IN*) input, template: ARRAY OF CHAR): BOOLEAN;

    (* Returns TRUE if template and input are equal, with the extra     *)
    (* rules:                                                           *)
    (*   1. Character case is not significant.                          *)
    (*   2. A '?' in template matches any single character.             *)
    (*   3. A '*' in template matches any string of zero or more        *)
    (*      characters.                                                 *)

PROCEDURE SubstringMatch (VAR (*IN*) input, template: ARRAY OF CHAR): BOOLEAN;

    (* Returns TRUE if template matches a substring of input, with the  *)
    (* extra rules:                                                     *)
    (*   1. Character case is not significant.                          *)
    (*   2. A '?' in template matches any single character.             *)
    (*   3. A '*' in template matches any string of zero or more        *)
    (*      characters.                                                 *)

END WildCard.

