summaryrefslogtreecommitdiff
path: root/src/GF/Compile/ShellState.hs
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2006-04-18 12:42:20 +0000
committerbringert <bringert@cs.chalmers.se>2006-04-18 12:42:20 +0000
commita663a046edf310247cf1e82761c79397d9bd42ad (patch)
tree16eca208e65faad7dc34db9fc35e9b2734721fa1 /src/GF/Compile/ShellState.hs
parent5ccf994499a215480bebecc31411db0217debb93 (diff)
Look at both command-line and grammar startcat falgs in pg commands.
Diffstat (limited to 'src/GF/Compile/ShellState.hs')
-rw-r--r--src/GF/Compile/ShellState.hs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs
index 0718814c5..7f8ae17e7 100644
--- a/src/GF/Compile/ShellState.hs
+++ b/src/GF/Compile/ShellState.hs
@@ -43,8 +43,11 @@ import qualified GF.OldParsing.ConvertGrammar as CnvOld -- OBSOLETE
import qualified GF.Conversion.GFC as Cnv
import qualified GF.Parsing.GFC as Prs
+import Control.Monad (mplus)
import Data.List (nub,nubBy)
import qualified Data.Map as Map
+import Data.Maybe (fromMaybe)
+
-- AR 11/11/2001 -- 17/6/2003 (for modules) ---- unfinished
@@ -458,13 +461,20 @@ firstCatOpts opts sgr =
firstAbsCat :: Options -> StateGrammar -> G.QIdent
firstAbsCat opts = cfCat2Cat . firstCatOpts opts
+-- | Gets the start category for the grammar from the options.
+-- If the startcat is not set in the options, we look
+-- for a flag in the grammar. If there is no flag in the
+-- grammar, S is returned.
+startCatStateOpts :: Options -> StateGrammar -> CFCat
+startCatStateOpts opts sgr =
+ string2CFCat a (fromMaybe "S" (optsStartCat `mplus` grStartCat))
+ where optsStartCat = getOptVal opts gStartCat
+ grStartCat = getOptVal (stateOptions sgr) gStartCat
+ a = P.prt (absId sgr)
+
-- | a grammar can have start category as option startcat=foo ; default is S
stateFirstCat :: StateGrammar -> CFCat
-stateFirstCat sgr =
- maybe (string2CFCat a "S") (string2CFCat a) $
- getOptVal (stateOptions sgr) gStartCat
- where
- a = P.prt (absId sgr)
+stateFirstCat = startCatStateOpts noOptions
stateIsWord :: StateGrammar -> String -> Bool
stateIsWord sg = isKnownWord (stateMorpho sg)