summaryrefslogtreecommitdiff
path: root/src/runtime/haskell/PGF/Forest.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-03-18 20:12:26 +0000
committerhallgren <hallgren@chalmers.se>2012-03-18 20:12:26 +0000
commit07af8988d3e42bf7e18c06cf8c9dabaa34c60578 (patch)
tree165108cebfa23228f3483eb2dc0c9534c5d4c078 /src/runtime/haskell/PGF/Forest.hs
parent771c1a0ad7a58e3d4832a93609958a8b3a44f84c (diff)
PGF run-time library: function names in BracketedString (experimental)
+ Make room for function names in the BracketedString data structure. + Fill in function names when linearizing an abstract syntax tree to a BracketedString. + Fill in wildCId when it is not obvious what the function is. + Function bracketedLinearize: for compatibility with the other linearization functions, return Leaf "" instead of error "cannot linearize". + Export flattenBracketedString from module PGF. + PGFServce: make function names available in the JSON representation of BracketedString.
Diffstat (limited to 'src/runtime/haskell/PGF/Forest.hs')
-rw-r--r--src/runtime/haskell/PGF/Forest.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/runtime/haskell/PGF/Forest.hs b/src/runtime/haskell/PGF/Forest.hs
index 6a5a0c629..24bafb475 100644
--- a/src/runtime/haskell/PGF/Forest.hs
+++ b/src/runtime/haskell/PGF/Forest.hs
@@ -57,9 +57,9 @@ linearizeWithBrackets dp = head . snd . untokn "" . bracketedTokn dp
bracketedTokn :: Maybe Int -> Forest -> BracketedTokn
bracketedTokn dp f@(Forest abs cnc forest root) =
case [computeSeq isTrusted seq (map (render forest) args) | (seq,args) <- root] of
- ([bs@(Bracket_ _ _ _ _ _)]:_) -> bs
- (bss:_) -> Bracket_ wildCId 0 0 [] bss
- [] -> Bracket_ wildCId 0 0 [] []
+ ([bs@(Bracket_{})]:_) -> bs
+ (bss:_) -> Bracket_ wildCId 0 0 wildCId [] bss
+ [] -> Bracket_ wildCId 0 0 wildCId [] []
where
isTrusted (_,fid) = IntSet.member fid trusted
@@ -67,8 +67,8 @@ bracketedTokn dp f@(Forest abs cnc forest root) =
render forest arg@(PArg hypos fid) =
case IntMap.lookup fid forest >>= Set.maxView of
- Just (p,set) -> let (ct,es,(_,lin)) = descend (if Set.null set then forest else IntMap.insert fid set forest) p
- in (ct,es,(map getVar hypos,lin))
+ Just (p,set) -> let (ct,fun,es,(_,lin)) = descend (if Set.null set then forest else IntMap.insert fid set forest) p
+ in (ct,fun,es,(map getVar hypos,lin))
Nothing -> error ("wrong forest id " ++ show fid)
where
descend forest (PApply funid args) = let (CncFun fun lins) = cncfuns cnc ! funid
@@ -78,9 +78,9 @@ bracketedTokn dp f@(Forest abs cnc forest root) =
Just (DTyp _ cat _,_,_,_) -> cat
largs = map (render forest) args
ltable = mkLinTable cnc isTrusted [] funid largs
- in ((cat,fid),either (const []) id $ getAbsTrees f arg Nothing dp,ltable)
+ in ((cat,fid),wildCId,either (const []) id $ getAbsTrees f arg Nothing dp,ltable)
descend forest (PCoerce fid) = render forest (PArg [] fid)
- descend forest (PConst cat e ts) = ((cat,fid),[e],([],listArray (0,0) [[LeafKS ts]]))
+ descend forest (PConst cat e ts) = ((cat,fid),wildCId,[e],([],listArray (0,0) [[LeafKS ts]]))
getVar (fid,_)
| fid == fidVar = wildCId