summaryrefslogtreecommitdiff
path: root/src/runtime/haskell/PGF/Parse.hs
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-09-27 15:09:48 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-09-27 15:09:48 +0000
commit426bc49a52b4efa0ef0129d713842d8c9abdf0ff (patch)
treed9f5985559de0347448e77ff26ce5a2d3ee2f245 /src/runtime/haskell/PGF/Parse.hs
parentb138899512d9aea248160eb17df3007e55dd03da (diff)
a major refactoring in the C and the Haskell runtimes. Note incompatible change in the PGF format!!!
The following are the outcomes: - Predef.nonExist is fully supported by both the Haskell and the C runtimes - Predef.BIND is now an internal compiler defined token. For now it behaves just as usual for the Haskell runtime, i.e. it generates &+. However, the special treatment will let us to handle it properly in the C runtime. - This required a major change in the PGF format since both nonExist and BIND may appear inside 'pre' and this was not supported before.
Diffstat (limited to 'src/runtime/haskell/PGF/Parse.hs')
-rw-r--r--src/runtime/haskell/PGF/Parse.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/runtime/haskell/PGF/Parse.hs b/src/runtime/haskell/PGF/Parse.hs
index 7057db3bc..e50f8436e 100644
--- a/src/runtime/haskell/PGF/Parse.hs
+++ b/src/runtime/haskell/PGF/Parse.hs
@@ -244,14 +244,12 @@ getParseOutput (PState abs cnc chart cnt) ty@(DTyp _ start _) dp =
flit _ = Nothing
ftok toks = TrieMap.unionWith Set.union (TrieMap.compose Nothing toks)
- cutAt ppos toks seqid =
+ cutAt ppos toks seqid =
let seq = unsafeAt (sequences cnc) seqid
init = take (ppos-1) (elems seq)
tail = case unsafeAt seq (ppos-1) of
- SymKS ts -> let ts' = reverse (drop (length toks) (reverse ts))
- in if null ts' then [] else [SymKS ts']
- SymKP ts _ -> let ts' = reverse (drop (length toks) (reverse ts))
- in if null ts' then [] else [SymKS ts']
+ SymKS t -> drop (length toks) [SymKS t]
+ SymKP ts _ -> reverse (drop (length toks) (reverse ts))
sym -> []
in init ++ tail
@@ -307,11 +305,18 @@ process flit ftok cnc (item@(Active j ppos funid seqid args key0):items) acc cha
Nothing -> process flit ftok cnc items4 acc' chart{active=insertAC key (Set.singleton item,new_sc) (active chart)}
Just (set,sc) | Set.member item set -> process flit ftok cnc items acc chart
| otherwise -> process flit ftok cnc items2 acc chart{active=insertAC key (Set.insert item set,IntMap.unionWith Set.union new_sc sc) (active chart)}
- SymKS toks -> let !acc' = ftok_ toks (Active j (ppos+1) funid seqid args key0) acc
+ SymKS tok -> let !acc' = ftok_ [tok] (Active j (ppos+1) funid seqid args key0) acc
in process flit ftok cnc items acc' chart
- SymKP strs vars
- -> let !acc' = foldl (\acc toks -> ftok_ toks (Active j (ppos+1) funid seqid args key0) acc) acc
- (strs:[strs' | Alt strs' _ <- vars])
+ SymNE -> process flit ftok cnc items acc chart
+ SymBIND -> let !acc' = ftok_ ["&+"] (Active j (ppos+1) funid seqid args key0) acc
+ in process flit ftok cnc items acc' chart
+ SymKP syms vars
+ -> let to_tok (SymKS t) = [t]
+ to_tok SymBIND = ["&+"]
+ to_tok _ = []
+
+ !acc' = foldl (\acc syms -> ftok_ (concatMap to_tok syms) (Active j (ppos+1) funid seqid args key0) acc) acc
+ (syms:[syms' | (syms',_) <- vars])
in process flit ftok cnc items acc' chart
SymLit d r -> let PArg hypos fid = args !! d
key = AK fid r