mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 03:09:33 -06:00
GF.Data.Str: change matchPrefix to agree with the GF book and the run-time system
The matchPrefix function is used in str2strings and the partial evaluator to
compute pre{...} tokens. But unlike the description in the GF book and
the implementation in the run-time system, matchPrefix looked at
the concatenation(!) of all following tokens and not just the next token
when deciding how to compute a pre{...} token.
This is a backwards incompatible change, but it is subtle and probably won't
cause any problems. In particular, the example grammars are unaffected.
This commit is contained in:
@@ -44,8 +44,8 @@ type Ss = [String]
|
|||||||
-- matching functions in both ways
|
-- matching functions in both ways
|
||||||
|
|
||||||
matchPrefix :: Ss -> [(Ss,[String])] -> [String] -> Ss
|
matchPrefix :: Ss -> [(Ss,[String])] -> [String] -> Ss
|
||||||
matchPrefix s vs t =
|
matchPrefix s vs t =
|
||||||
head $ [u | let t' = concat (unmarkup t),
|
head $ [u | t':_ <- [unmarkup t],
|
||||||
(u,as) <- vs,
|
(u,as) <- vs,
|
||||||
any (`isPrefixOf` t') as]
|
any (`isPrefixOf` t') as]
|
||||||
++ [s]
|
++ [s]
|
||||||
|
|||||||
Reference in New Issue
Block a user