ppMatcher
functor
signature PPMATCHER
functor ppMatcher
(LABEL) : PPMATCHER
This functor creates from an alphabet a structure containing functions to create, display and use a pattern matcher, allowing search for occurrences of patterns from a regular set of pattern sequences over the alphabet.
eqtype t
datatype
s
= Dummy| Pat of t
datatype re = datatype RegExp.re
structure M : PPCFM
val matcher : t re -> s M.machine
val display : t re -> OS.Process.status
val find : t re -> t list -> int list
eqtype t
datatype
s
= Dummy| Pat of t
datatype re = datatype RegExp.re
matcher r
display r
find r l
LABEL, RegExp, ppCFm
We need the extension by a dummy symbol since otherwise the automaton created from the regular expression would have exactly the symbols in the regular expressions as alphabet. Symbols in an input sequence that do not occur in the regular expression are treated as the dummy symbol by the automaton.
Example:
structure Match = ppMatcher(StringLabels) ; open Match; val patM = (Times [Atom "a",Star(Atom "a")]); display patM; find patM ["a","b","a","a","cd","a"]
Example:
- datatype alphabet = a | b; structure alphabetLabels = struct type label = alphabet fun toString a = "a" | toString b = "b" end; structure Match = ppMatcher(alphabetLabels); open Match; - val pat = Plus[Times [Star(Atom a),Atom b],Times[Atom a,Atom a]]; display pat; - find pat [a,b,a,a,b,a]; val it = [2,4,5] : int list