From f4ecc458317fd3f9ec507f9c47e28f401792e377 Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 22 Dec 2004 12:49:44 +0000 Subject: [PATCH] ShellState.changeMain --- src/GF/Compile/ShellState.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs index 1c90d1369..34224e641 100644 --- a/src/GF/Compile/ShellState.hs +++ b/src/GF/Compile/ShellState.hs @@ -208,6 +208,16 @@ purgeShellState sh = ShSt { purge = nubBy (\x y -> fst x == fst y) . filter (flip elem needed . fst) acncs = maybe [] singleton (abstract sh) ++ map (snd . fst) (concretes sh) +changeMain :: Maybe Ident -> ShellState -> Err ShellState +changeMain Nothing (ShSt _ _ cs ms ss cfs pis mos os rs acs s) = + return (ShSt Nothing Nothing cs ms ss cfs pis mos os rs acs s) +changeMain (Just c) (ShSt _ _ cs ms ss cfs pis mos os rs acs s) = + case lookup c (map fst cs) of + Just i -> do + a <- M.abstractOfConcrete ms i + return (ShSt (Just a) (Just i) cs ms ss cfs pis mos os rs acs s) + _ -> P.prtBad "The state has no concrete syntax named" c + -- form just one state grammar, if unique, from a canonical grammar grammar2stateGrammar :: Options -> CanonGrammar -> Err StateGrammar