comparison pattern.rhope @ 161:f5095855c878

Merge
author Mike Pavone <pavone@retrodev.com>
date Fri, 07 Jan 2011 03:19:26 -0500
parents f97a7d499182
children
comparison
equal deleted inserted replaced
159:d1e206ff75f9 161:f5095855c878
85 Pattern@Pattern[p:out] 85 Pattern@Pattern[p:out]
86 { 86 {
87 out <- p 87 out <- p
88 } 88 }
89 89
90 _Match@Empty Pattern[pattern,string,n:num,no match] 90 Match@Empty Pattern[pattern,string:num,no match]
91 { 91 {
92 no match <- Yes 92 no match <- Yes
93 } 93 }
94 94
95 Match@Empty Pattern[pattern,string:num,no match]
96 {
97 no match <- Yes
98 }
99
100 Match@Pattern[pattern,string:num,no match,idx] 95 Match@Pattern[pattern,string:num,no match,idx]
101 { 96 {
102 num,no match,idx <- [pattern]_Match[string,0,[string]Byte[0]] 97 num,no match,idx <- [pattern]_Match[string,0,[string]Byte[0]]
103 } 98 }
104 99 /*
105 _Match@Pattern[pattern,string,n,b:num,no match,idx] 100 _Match@Pattern[pattern,string,n,b:num,no match,idx]
106 { 101 {
107 myb <- [pattern]Byte >> 102 myb <- [pattern]Byte >>
108 If[[b]=[myb]] 103 If[[b]=[myb]]
109 { 104 {
125 }{ 120 }{
126 num, no match, idx <- [[pattern]Right >>]_Match[string, n,b] 121 num, no match, idx <- [[pattern]Right >>]_Match[string, n,b]
127 } 122 }
128 } 123 }
129 } 124 }
125 */
126
127 _Match@Pattern[pattern,string,n,b:num,no match,idx]
128 {
129 myb <- [pattern]Byte >>
130 If[[b]=[myb]]
131 {
132 ,check terminal <- [string]Byte[[n]+[1]]
133 { num,check terminal,idx <- [[pattern]Straight >>]_Match[string, [n]+[1], ~] }
134 Val[check terminal]
135 {
136 ,no match <- If[[pattern]Terminal? >>]
137 {
138 num <- [n]+[1]
139 idx <- Index >>[pattern]
140 }
141 }
142
143 }{
144 If[[b]<[myb]]
145 {
146 num, no match, idx <- [[pattern]Left >>]_Match[string, n,b]
147 }{
148 num, no match, idx <- [[pattern]Right >>]_Match[string, n,b]
149 }
150 }
151 }
152
153 _Match Iter@Empty Pattern[pattern,origpat,n,count,b,if end:out,next,no next,seekfunc,seek]
154 {
155 out <- Call[if end] {
156 }{
157 If[count]
158 {
159 seek <- [count]-[1]
160 seekfunc <- Val[[origpat]_Match Iter[origpat,[n]+[1],0,?,_No Pattern Match[?]]]
161 }{
162 next <- Val[[origpat]_Match Iter[origpat, [n]+[1], 0, ?, _No Pattern Match[?]]]
163 no next <- Val[_No Pattern Match[?]]
164 }
165 }
166 }
167
168 _Match Iter@Pattern[pattern,origpat,n,count,b,if end:out,next,no next,seekfunc,seek]
169 {
170 myb <- [pattern]Byte >>
171 If[[b]=[myb]]
172 {
173 ncount <- [count]+[1]
174 If[[pattern]Terminal? >>]
175 { next if end <- Val[Val[[[[()]Append[n]]Append[ncount]]Append[[pattern]Index >>],?]] }
176 { next if end <- Val[_No Pattern Match[?]] }
177 no next <- Val[next if end]
178
179 next <- Val[[[pattern]Straight >>]_Match Iter[origpat, n, ncount, ?, next if end]]
180 }{
181 If[[b]<[myb]]
182 {
183 out,next,no next,seekfunc,seek <- [[pattern]Left >>]_Match Iter[origpat,n,count,b,if end]
184 }{
185 out,next,no next,seekfunc,seek <- [[pattern]Right >>]_Match Iter[origpat,n,count,b,if end]
186 }
187 }
188 }
189
130 190
131 _Partition@Pattern[delims,string:matched,after,not found] 191 _Partition@Pattern[delims,string:matched,after,not found]
132 { 192 {
193 ,not found <- [string]Iter Bytes[_Match Iter[delims,delims,0,0,?,_No Pattern Match[?]], 0]
194 {
195 matched, after <- [[string]Substring[[~]Index[0], 0]]Slice[[~]Index[1]]
196 }
197 /*
133 not found <- If[[string]=[""]] {} 198 not found <- If[[string]=[""]] {}
134 { 199 {
135 [delims]Match[string] 200 [delims]Match[string]
136 { 201 {
137 matched,after <- [string]Slice[~] 202 matched,after <- [string]Slice[~]
138 }{ 203 }{
139 matched,after,not found <- _Partition[delims, [string]Substring[1, 0]] 204 matched,after,not found <- _Partition[delims, [string]Substring[1, 0]]
140 } 205 }
141 } 206 }
207 */
142 } 208 }
143 209
144 _Partition@Empty Pattern[delims,string:matched,after,not found] 210 _Partition@Empty Pattern[delims,string:matched,after,not found]
145 { 211 {
146 not found <- Yes 212 not found <- Yes