summaryrefslogtreecommitdiff
path: root/src/GF/Compile/ShellState.hs
diff options
context:
space:
mode:
authoraarne <unknown>2004-12-22 12:49:44 +0000
committeraarne <unknown>2004-12-22 12:49:44 +0000
commitbf022485b33e68737084e9b529cdc33cb663665d (patch)
treef99c12a5f1771cb86bd11d649aeebab9c86e91d5 /src/GF/Compile/ShellState.hs
parent6e1f41b26af8154033fda32c573aba56d7cb89fb (diff)
ShellState.changeMain
Diffstat (limited to 'src/GF/Compile/ShellState.hs')
-rw-r--r--src/GF/Compile/ShellState.hs10
1 files changed, 10 insertions, 0 deletions
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