DIRECTORY Rope USING [ROPE]; PatternMatch: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; MatchProc: TYPE = PROC [value: ROPE, pattern: ROPE, pparsed: REF ¬ NIL] RETURNS [match: BOOLEAN, nothingGreater: BOOLEAN ¬ FALSE, pparsedNew: REF ¬ NIL]; Equal: MatchProc; Prefix: MatchProc; Wildcard: MatchProc; RE: MatchProc; SoundexMatch: MatchProc; SoundexPrefix: MatchProc; Subrange: MatchProc; NumSubrange: MatchProc; DateSubrange: MatchProc; DateAndTime: MatchProc; DWIM: PROC [pattern: ROPE] RETURNS [ptype: ROPE]; CheckPattern: PROC [pattern: ROPE, proc: MatchProc] RETURNS [ok: BOOLEAN ¬ TRUE, info: ROPE ¬ NIL]; Lookup: PROC [name: ROPE] RETURNS [proc: MatchProc]; Register: PROC [name: ROPE, proc: MatchProc]; EachPairAction: TYPE = PROC [name: ROPE, proc: MatchProc] RETURNS [quit: BOOL ¬ FALSE]; Pairs: PROC [action: EachPairAction] RETURNS [BOOL]; END. – PatternMatch.mesa Copyright Σ 1987, 1992 by Xerox Corporation. All rights reserved. Doug Terry, July 20, 1987 5:38:35 pm PDT Brian Oki, March 12, 1990 1:53 pm PST A collection of pattern matching routines of general utility, and a facility for registering them and retrieving them by name. Compares the presented value to the pattern; match indicates the result of the comparison. If nothingGreater=TRUE then no value lexicographically greater than or equal to the presented value could possibly match the pattern; nothingGreater=FALSE implies nothing about such comparisons. To possibly improve performance when comparing a set of values against a single pattern, pparsedNew is returned by the initial call; this should be treated as opaque and passed as the pparsed argument to subsequent calls. This allows the cost of parsing the pattern to be amortized over several calls. Warning: a returned pparsed ref should only be passed to the same MatchProc that returned it and only if the pattern is identical. Compares the value and pattern for equality. Checks if the pattern is a prefix of the value. Prefix[v, "p"] is the same as Wildcard[v, "p*"], though faster. The pattern may contain zero or more wildcards (the character "*") that match anything. The pattern is taken to be a regular expression as defined in RegularExpressionDoc.tioga. Compares the value and pattern based on their Soundex codes. The Soundex encoding tends to group together variants of the same name; for instance, Johnson, Jansen, and Johansen have identical Soundex codes. Like Soundex except the code of the pattern need only be a prefix of the value's code. For example, "John" is a soundex prefix of "Jansen". Checks if the value is in the range specified by the pattern. The pattern consists of two prefixes separated by a "-". Checks if the value is in the numerical range specified by the pattern. The pattern should consist of two positive integers separated by a "-". If the value can not be parsed as an integer then match=FALSE is returned; if the pattern is bad then match=FALSE and nothingGreater=TRUE is returned. Checks if the value is in the chronological range specified by the pattern. The pattern should consist of two date and times (as can be parsed by Tempus) separated by a "-". If the value can not be parsed as a date and time then match=FALSE is returned; if the pattern is bad then match=FALSE and nothingGreater=TRUE is returned. Checks if the value matches the pattern within the time precision of the pattern. The pattern, as well as the value, should be a date and time (as can be parsed by Tempus). If the value can not be parsed as a date and time then match=FALSE is returned; if the pattern is bad then match=FALSE and nothingGreater=TRUE is returned. A match can not occur unless the pattern is no more precise than the value. For example, a pattern of "Wednesday" will match a value of "Wednesday at 2 pm", but not vice versa. Trys to deduce an appropriate pattern matcher from the given pattern. The returned ptype can be passed to Lookup to get the associated MatchProc. Checks if the given pattern is suitable for input to the given pattern matcher. For instance, proc=DateSubrange returns ok=TRUE only if the pattern is a valid date range. The returned info is a human readable analysis of the pattern. Get a pattern matcher by name. Register a name for a pattern matcher. ... enumerates pairs currently in the pattern matcher registry in unspecified order; applies action to each pair until action returns TRUE or no more pairs; returns TRUE if some action returns TRUE. Doug Terry, April 14, 1987 12:50:27 pm PDT Moved from LoganQuery. changes to: DIRECTORY, PatternMatch, ~ ΚΑ•NewlineDelimiter –(cedarcode) style™codešœ™Kšœ Οeœ7™BKšœ(™(K™%K™K™K™~K™—šΟk ˜ Kšœžœžœ˜—K˜KšΠbl œžœž ˜šœž˜K˜Kšžœžœžœ˜K˜šœ žœžœ žœ žœ žœžœžœ žœžœžœžœžœ˜™Kšœ ™ Kšœ³™³—K˜šΟnœ ž˜K™,—K˜šΟbœ ˜K™p—K˜š œ ž˜KšœW™W—K˜š œ ž˜KšœY™Y—K˜š  œ ž˜K™Ο—K˜š  œ ž˜K™Œ—K˜š œ ˜K™w—K˜š  œ ˜Kšœ¨™¨—K™š  œ ˜KšœΛ™Λ—K˜š  œ ˜Kšœύ™ύ—K˜š  œžœ žœžœ žœ˜1K™’K™—š  œžœ žœžœžœžœžœžœ˜cK™λK™—š œžœžœžœ˜4K™—K˜š œžœžœ˜-K™&—K˜š œžœžœžœžœžœžœ˜WK™—š œžœžœžœ˜4Kšœ†žœžœž™ΖK™——Kšžœ˜™*K™Kšœ Οr™&—K™—…—lΓ