Skip to content

Commit 22a22aa

Browse files
committed
added evaluation for markup
1 parent 854739e commit 22a22aa

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/compiler/api/GF/Compile/Compute/Concrete2.hs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ data Value
6363
| VFV Choice [Value]
6464
| VAlts Value [(Value, Value)]
6565
| VStrs [Value]
66+
| VMarkup Ident [(Ident,Value)] [Value]
6667
| VSymCat Int LIndex [(LIndex, (Value, Type))]
6768
| VError Doc
6869
-- These two constructors are only used internally
@@ -247,9 +248,18 @@ eval g env s (Alts d as) [] = let (!s1,!s2) = split s
247248
vas = mapC (\s (t1,t2) -> let (!s1,!s2) = split s
248249
in (eval g env s1 t1 [],eval g env s2 t2 [])) s2 as
249250
in VAlts vd vas
250-
eval g env s (Strs ts) [] = VStrs (mapC (\s t -> eval g env s t []) s ts)
251-
eval g env s (TSymCat d r rs) []= VSymCat d r [(i,(fromJust (lookup pv env),ty)) | (i,(pv,ty)) <- rs]
252-
eval g env s t vs = VError ("Cannot reduce term" <+> pp t)
251+
eval g env c (Strs ts) [] = VStrs (mapC (\c t -> eval g env c t []) c ts)
252+
eval g env c (Markup tag as ts) [] =
253+
let (c1,c2) = split c
254+
vas = mapC (\c (id,t) -> (id,eval g env c t [])) c1 as
255+
vs = mapC (\c t -> eval g env c t []) c2 ts
256+
in (VMarkup tag vas vs)
257+
eval g env c (Reset ctl t) [] =
258+
let limit All = id
259+
limit (Limit n) = fmap (genericTake n)
260+
in (VMarkup identW [] [eval g env c t []])
261+
eval g env c (TSymCat d r rs) []= VSymCat d r [(i,(fromJust (lookup pv env),ty)) | (i,(pv,ty)) <- rs]
262+
eval g env c t vs = VError ("Cannot reduce term" <+> pp t)
253263

254264
stdPredef :: Globals -> PredefTable
255265
stdPredef g = Map.fromList
@@ -766,6 +776,10 @@ value2termM flat xs (VAlts vd vas) = do
766776
value2termM flat xs (VStrs vs) = do
767777
ts <- mapM (value2termM flat xs) vs
768778
return (Strs ts)
779+
value2termM flat xs (VMarkup tag as vs) = do
780+
as <- mapM (\(id,v) -> value2termM flat xs v >>= \t -> return (id,t)) as
781+
ts <- mapM (value2termM flat xs) vs
782+
return (Markup tag as ts)
769783
value2termM flat xs (VError msg) = evalError msg
770784
value2termM flat xs (VCRecType lbls) = do
771785
lbls <- mapM (\(lbl,_,v) -> fmap ((,) lbl) (value2termM flat xs v)) lbls

0 commit comments

Comments
 (0)