diff --git a/doc/gf-history.html b/doc/gf-history.html index 7b4e1091c..c58d39fa5 100644 --- a/doc/gf-history.html +++ b/doc/gf-history.html @@ -14,26 +14,54 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2

-5/1 (BB) New grammar printers slf_sub and slf_sub_graphviz -for creating SLF networks with sub-automata. - -


- -6/1/2006 (AR) Concatenative string patterns to help morphology definitions. -The pattern Predef.CC p1 p2 matches a string literal s -with the first (i.e. shortest-prefix) division s1 + s2 = s such that -p1 matches s1 and p2 matches s2. For example, -the following expression produces the English plural forms -boy-boys, play-plays, fly-flies, dog-dogs: +7/1 (AR) Full set of regular expression patterns, with +as-patterns to enable variable bindings to matched expressions: + +The last three apply to all types of patterns, the first two only to token strings. +Example: plural formation in Swedish 2nd declension +(pojke-pojkar, nyckel-nycklar, seger-segrar, bil-bilar):
-  plur : Str -> Str = \s -> case s of {
-    CC x (CC ("a" | "o") "y") => s + "s" ;
-    CC x "y"                  => x + "ies" ;
-    _                         => s + "s"
+  plural2 : Str -> Str = \w -> case w of {
+    pojk + "e"                       => pojk + "ar" ;
+    nyck + "e" + l@("l" | "r" | "n") => nyck + l + "ar" ;
+    bil                              => bil + "ar"
     } ;
 
+Semantics: variables are always bound to the first match, in the sequence defined +as the list Match p v as follows: +
+  Match (p1|p2) v = Match p1 v ++ Match p2 v
+  Match (p1+p2) s = [Match p1 s1 ++ Match p2 s2 | i <- [0..length s], (s1,s2) = splitAt i s]
+  Match p*      s = Match "" s ++ Match p s ++ Match (p + p) s ++ ...
+  Match c       v = [[]] if c == v  -- for constant patterns c
+  Match x       v = [[(x,v)]]       -- for variable patterns x
+  Match x@p     v = [[(x,v)]] + M   if M = Match p v /= []
+  Match p       v = [] otherwise    -- failure
+
+Examples: + +

+ +6/1 (AR) Concatenative string patterns to help morphology definitions... This can be seen as a step towards regular expression string patterns. The natural notation p1 + p2 will be considered later. +Note. This was done on 7/1. + +

+ +5/1/2006 (BB) New grammar printers slf_sub and slf_sub_graphviz +for creating SLF networks with sub-automata.


diff --git a/src/GF/Grammar/PatternMatch.hs b/src/GF/Grammar/PatternMatch.hs index f850981f0..2724bd263 100644 --- a/src/GF/Grammar/PatternMatch.hs +++ b/src/GF/Grammar/PatternMatch.hs @@ -105,7 +105,7 @@ tryMatch (p,t) = do return (concat matches) (PRep p1, ([],K s, [])) -> checks [ - trym (foldr (const (PSeq p1)) (PString "") [0..n]) t' | n <- [1 .. length s] + trym (foldr (const (PSeq p1)) (PString "") [1..n]) t' | n <- [0 .. length s] ] _ -> prtBad "no match in case expr for" t