mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
in the shell, permit 3-letter lang codes as concrete syntax names
This commit is contained in:
@@ -924,7 +924,12 @@ allCommands cod env@(pgf, mos) = Map.fromList [
|
||||
|
||||
optLangs opts = case valStrOpts "lang" "" opts of
|
||||
"" -> languages pgf
|
||||
lang -> map mkCId (chunks ',' lang)
|
||||
lang -> map completeLang (chunks ',' lang)
|
||||
completeLang la = let cla = (mkCId la) in
|
||||
if elem cla (languages pgf)
|
||||
then cla
|
||||
else (mkCId (showCId (abstractName pgf) ++ la))
|
||||
|
||||
optLang opts = head $ optLangs opts ++ [wildCId]
|
||||
|
||||
optOpenTypes opts = case valStrOpts "openclass" "" opts of
|
||||
|
||||
@@ -52,6 +52,13 @@ lookConcr :: PGF -> CId -> Concr
|
||||
lookConcr pgf cnc =
|
||||
lookMap (error $ "Missing concrete syntax: " ++ showCId cnc) cnc $ concretes pgf
|
||||
|
||||
-- use if name fails, use abstract + name; so e.g. "Eng" becomes "DemoEng"
|
||||
lookConcrComplete :: PGF -> CId -> Concr
|
||||
lookConcrComplete pgf cnc =
|
||||
case Map.lookup cnc (concretes pgf) of
|
||||
Just c -> c
|
||||
_ -> lookConcr pgf (mkCId (showCId (absname pgf) ++ showCId cnc))
|
||||
|
||||
lookConcrFlag :: PGF -> CId -> CId -> Maybe Literal
|
||||
lookConcrFlag pgf lang f = Map.lookup f $ cflags $ lookConcr pgf lang
|
||||
|
||||
@@ -196,4 +203,4 @@ updateProductionIndices pgf = pgf{ concretes = fmap updateConcrete (concretes pg
|
||||
getFunctions (PApply funid args) = let CncFun fun _ = cncfuns pinfo Array.! funid in [fun]
|
||||
getFunctions (PCoerce fid) = case IntMap.lookup fid productions of
|
||||
Nothing -> []
|
||||
Just prods -> [fun | prod <- Set.toList prods, fun <- getFunctions prod]
|
||||
Just prods -> [fun | prod <- Set.toList prods, fun <- getFunctions prod]
|
||||
|
||||
@@ -65,7 +65,7 @@ initState pgf lang (DTyp _ start _) =
|
||||
return (Active 0 0 funid seqid args (AK cat lbl))
|
||||
Nothing -> mzero
|
||||
|
||||
cnc = lookConcr pgf lang
|
||||
cnc = lookConcrComplete pgf lang
|
||||
|
||||
in PState pgf
|
||||
cnc
|
||||
|
||||
Reference in New Issue
Block a user