☜ | pattern1995 Version of ANSI (Equivalent to Current ISO Version) of Standard | ☞ |
The pattern match operator ? tests the form of the string which is its left-hand operand. S ? P is true if and only if S is a member of the class of strings specified by the pattern P.
A pattern is a concatenated list of pattern atoms.
pattern | ::= | │ │ │ |
patatom ... @ expratom V pattern |
│ │ │ |
Assume that pattern has n patatoms. S ? pattern is true if and only if there exists a partition of S into n substrings
S = S1 S2 ... Sn
such that there is a one-to-one order-preserving correspondence between the Si and the pattern atoms, and each Si satisfies its respective pattern atom. Note that some of the Si may be empty.
Each pattern atom consists of a repeat count repcount, followed by either a pattern code patcode or a string literal strlit. A substring Si of S satisfies a pattern atom if it, in turn, can be decomposed into a number of concatenated substrings, each of which satisfies the associated patcode or strlit.
patatom | ::= | repcount | │ │ │ │ |
patcode patstr alternation |
│ │ │ │ |
repcount | ::= | │ │ │ |
intlit [ intlit1 ] . [ intlit2 ] |
│ │ │ |
patcode | ::= | [ ' ] | │ │ │ │ |
Y patnonY Y Z patnonZ Z patnonYZ |
│ │ │ │ |
... |
patnonY | ::= | any of the characters in ident except Y |
patnonZ | ::= | any of the characters in ident except Z |
patnonYZ | ::= | any of the characters in ident except Y and Z |
alternation | ::= | ( patatom [ , patatom ] ... ) |
patcodes beginning with the initial letter Y are available for use by M programmers. patcodes beginning with the initial letter Z are available for use by implementors. patcodes are specified in Character Set Profiles.
Patcodes differing only in the use of corresponding upper and lower case letters are equivalent. Each patcode is satisfied by any single character in the union of the classes of characters represented, each class denoted by its own patcode letter. Whether or not a specific character belongs to a patcode class is determined by a process’ Character Set Profile ( charset ).
An alternation is satisfied if any one of its patatom components individually matches the corresponding Si.
Each strlit is satisfied by, and only by, the value of strlit.
If repcount has the form of an indefinite multiplier ".", patatom is satisfied by a concatenation of any number of Si (including none), each of which meets the specification of patatom.
If repcount has the form of a single intlit, patatom is satisfied by a concatenation of exactly intlit Si, each of which meets the specification of patatom. In particular, if the value of intlit is zero, the corresponding Si is empty.
If repcount has the form of a range, intlit1.intlit2, the first intlit gives the lower bound, and the second intlit the upper bound. If the upper bound is less than the lower bound an error condition occurs with ecode="M10". If the lower bound is omitted, so that the range has the form .intlit2 , the lower bound is taken to be zero. If the upper bound is omitted, so that the range has the form intlit1. , the upper bound is taken to be indefinite; that is, the range is at least intlit1 occurrences. Then patatom is satisfied by the concatenation of a number of Si, each of which meets the specification of patatom, where the number must be within the expressed or implied bounds of the specified range, inclusive.
The dual operator '? is defined by:
A '? B = '(A ? B)
Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.
This page most recently updated on 15-Nov-2023, 13:19:37.
For comments, contact Ed de Moel (demoel@jacquardsystems.com)