From 4c06c3f825130724b6bd7612dc2fdede29d6f701 Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Tue, 16 Feb 2021 21:01:01 +0100 Subject: [PATCH] Add case for when pre is not followed by anything --- src/runtime/haskell/LPGF.hs | 3 ++- testsuite/lpgf/Pre.gf | 1 + testsuite/lpgf/Pre.treebank | 5 +++++ testsuite/lpgf/Pre.trees | 2 ++ testsuite/lpgf/PreCnc.gf | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/runtime/haskell/LPGF.hs b/src/runtime/haskell/LPGF.hs index 85be9d481..b7c170cdb 100644 --- a/src/runtime/haskell/LPGF.hs +++ b/src/runtime/haskell/LPGF.hs @@ -167,6 +167,7 @@ lin2string l = case l of LFSpace -> "" -- when encountered at beginning/end LFToken tok -> tok LFTuple [l] -> lin2string l + LFPre pts df -> lin2string df -- when encountered at end LFConcat (LFPre pts df) l2 -> lin2string $ LFConcat l1 l2 where l2' = lin2string l2 @@ -177,7 +178,7 @@ lin2string l = case l of LFConcat LFCapit l2 -> let l = lin2string l2 in T.toUpper (T.take 1 l) `T.append` T.drop 1 l LFConcat LFAllCapit l2 -> let tks = T.words (lin2string l2) in T.unwords $ T.toUpper (head tks) : tail tks LFConcat l1 l2 -> T.unwords $ filter (not.T.null) [lin2string l1, lin2string l2] - x -> T.pack $ printf "[%s]" (show x) + x -> T.pack $ printf "<%s>" (show x) -- | List indexing with more verbose error messages (!!) :: (Show a) => [a] -> Int -> a diff --git a/testsuite/lpgf/Pre.gf b/testsuite/lpgf/Pre.gf index 5f8955d26..c1a015250 100644 --- a/testsuite/lpgf/Pre.gf +++ b/testsuite/lpgf/Pre.gf @@ -4,4 +4,5 @@ abstract Pre = { ant, dog: N ; a, the: Det ; mkS : Det -> N -> S; + detS : Det -> S; } diff --git a/testsuite/lpgf/Pre.treebank b/testsuite/lpgf/Pre.treebank index d7eedf79c..f2a9bb0ad 100644 --- a/testsuite/lpgf/Pre.treebank +++ b/testsuite/lpgf/Pre.treebank @@ -10,3 +10,8 @@ PreCnc: a dog Pre: mkS the dog PreCnc: the dog +Pre: detS a +PreCnc: a + +Pre: detS the +PreCnc: the diff --git a/testsuite/lpgf/Pre.trees b/testsuite/lpgf/Pre.trees index c3ccbcd17..506b078cf 100644 --- a/testsuite/lpgf/Pre.trees +++ b/testsuite/lpgf/Pre.trees @@ -2,3 +2,5 @@ mkS a ant mkS the ant mkS a dog mkS the dog +detS a +detS the diff --git a/testsuite/lpgf/PreCnc.gf b/testsuite/lpgf/PreCnc.gf index 0a7927185..011e915dd 100644 --- a/testsuite/lpgf/PreCnc.gf +++ b/testsuite/lpgf/PreCnc.gf @@ -12,4 +12,5 @@ concrete PreCnc of Pre = { } } ; the = { s = "the" } ; mkS det n = { s = det.s ++ n.s } ; + detS det = { s = det.s } ; }