R. Clayton (rclayton@clayton.cs.monmouth.edu)
Wed, 17 Jan 2001 19:01:09 -0500 (EST)
Once a pattern variable is bound to matched text, other occurances of the same
pattern variable in the match text must match the same text.
Yes, once bound, a pattern variable can only match the text to which its
bound.
The match text $4 = $4 + 3 should matched the intermediate code m[3] = m[3] + 3
as i have $4 twice, the component m[3] should also occur twice in the
intermediate code for matching.
Yes.
If I get again $4 in another match text, should this $4 be bound to m[3]
thoughout the pattern file?
No; each pattern binds to its own set of pattern variables. $1 in one pattern
has no influence at all on $1 appearing in any other pattern. Further, a
pattern binds to a fresh set of pattern variables (initially undefined) each
time the pattern's used. The fact that $1 was bound to a particular text
piece the last time its pattern was used has no influence at all the next
time the pattern's used.
For example, does the match text as $2 = 3 + $4 match m[5] = 3 + m[1]? Or can
$4 only match with m[3] instead of m[1]?
If $2 = 3 + $4 is in a pattern different from the pattern containing $4 = $4
+ 3, then $2 = 3 + $4 matches m[5] = 3 + m[1]. If $2 = 3 + $4 appears in the
same pattern as $4 = $4 + 3 (and appears after $4 = $4 + 3), then $2 = 3 + $4
would not match m[5] = 3 + m[1] because $4 is bound to m[3] and m[3] != m[1].
This archive was generated by hypermail 2.0b3 on Thu May 17 2001 - 12:00:05 EDT