mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-09-13 05:46:00 -06:00
fix string matching in case of metavariables
This commit is contained in:
@@ -559,24 +559,27 @@ patternMatch g s v0 ((env0,ps,args0,t):eqs) = match env0 ps eqs args0
|
|||||||
(PString s1, VEmpty)
|
(PString s1, VEmpty)
|
||||||
| null s1 -> match env ps eqs args
|
| null s1 -> match env ps eqs args
|
||||||
(PSeq min1 max1 p1 min2 max2 p2,v)
|
(PSeq min1 max1 p1 min2 max2 p2,v)
|
||||||
-> case value2string g v of
|
-> let match_seq (Const str) = let n = length str
|
||||||
Const str -> let n = length str
|
lo = min1 `max` (n-fromMaybe n max2)
|
||||||
lo = min1 `max` (n-fromMaybe n max2)
|
hi = (n-min2) `min` fromMaybe n max1
|
||||||
hi = (n-min2) `min` fromMaybe n max1
|
(ds,cs) = splitAt lo str
|
||||||
(ds,cs) = splitAt lo str
|
|
||||||
|
|
||||||
eqs' = matchStr env (p1:p2:ps) eqs (hi-lo) (reverse ds) cs args
|
eqs' = matchStr env (p1:p2:ps) eqs (hi-lo) (reverse ds) cs args
|
||||||
|
in patternMatch g s v0 eqs'
|
||||||
in patternMatch g s v0 eqs'
|
match_seq (CSusp i k) = VSusp i (match_seq . k) []
|
||||||
RunTime -> v0
|
match_seq (CFV c vs) = VFV c (fmap match_seq vs)
|
||||||
NonExist -> patternMatch g s v0 eqs
|
match_seq RunTime = v0
|
||||||
|
match_seq NonExist = patternMatch g s v0 eqs
|
||||||
|
in match_seq (value2string g v)
|
||||||
(PRep minp maxp p, v)
|
(PRep minp maxp p, v)
|
||||||
-> case value2string g v of
|
-> let match_rep (Const str) = let n = length (str::String) `div` (max minp 1)
|
||||||
Const str -> let n = length (str::String) `div` (max minp 1)
|
eqs' = matchRep env n minp maxp p minp maxp p ps ((env,PString []:ps,(arg:args),t) : eqs) (arg:args)
|
||||||
eqs' = matchRep env n minp maxp p minp maxp p ps ((env,PString []:ps,(arg:args),t) : eqs) (arg:args)
|
in patternMatch g s v0 eqs'
|
||||||
in patternMatch g s v0 eqs'
|
match_rep (CSusp i k) = VSusp i (match_rep . k) []
|
||||||
RunTime -> v0
|
match_rep (CFV c vs) = VFV c (fmap match_rep vs)
|
||||||
NonExist -> patternMatch g s v0 eqs
|
match_rep RunTime = v0
|
||||||
|
match_rep NonExist = patternMatch g s v0 eqs
|
||||||
|
in match_rep (value2string g v)
|
||||||
(PChar, VStr [_]) -> match env ps eqs args
|
(PChar, VStr [_]) -> match env ps eqs args
|
||||||
(PChars cs, VStr [c])
|
(PChars cs, VStr [c])
|
||||||
| elem c cs -> match env ps eqs args
|
| elem c cs -> match env ps eqs args
|
||||||
|
|||||||
Reference in New Issue
Block a user