1
0
forked from GitHub/gf-core

Nonlinear patterns in concrete syntax are now detected and reported as errors

Before, they were silently converted to linear patterns.
Nonlinear patterns in MorphoCat.gf, ParadigmsGre.gf and ParadigmsFin.gf have
been make linear by renaming pattern variables.
This commit is contained in:
hallgren
2013-09-09 19:52:08 +00:00
parent 3543cb7a16
commit bf5dfb2293

View File

@@ -39,7 +39,7 @@ import GF.Grammar.Printer
import GF.Data.Operations
import Control.Monad
import Data.List (nub)
import Data.List (nub,(\\))
import Text.PrettyPrint
-- | this gives top-level access to renaming term input in the cc command
@@ -235,8 +235,14 @@ renameTerm env vars = ren vars where
-- | vars not needed in env, since patterns always overshadow old vars
renamePattern :: Status -> Patt -> Check (Patt,[Ident])
renamePattern env patt = case patt of
renamePattern env patt =
do r@(p',vs) <- renp patt
let dupl = vs \\ nub vs
unless (null dupl) $ checkError (hang (text "[C.4.13] Pattern is not linear:") 4
(ppPatt Unqualified 0 patt))
return r
where
renp patt = case patt of
PMacro c -> do
c' <- renid $ Vr c
case c' of
@@ -301,8 +307,6 @@ renamePattern env patt = case patt of
_ -> return (patt,[])
where
renp = renamePattern env
renid = renameIdentTerm env
renid' = renameIdentTerm' env