summaryrefslogtreecommitdiff
path: root/src/GF/UseGrammar
diff options
context:
space:
mode:
authoraarne <unknown>2003-10-03 13:03:15 +0000
committeraarne <unknown>2003-10-03 13:03:15 +0000
commit719fcd09ea0501d864af3afacc843186d24f6c94 (patch)
tree7f45380d8063f174ff8c33f9d5de4ce0e88ddd35 /src/GF/UseGrammar
parentcfe8ebc1fbbf60d7d90aaa4776b029b5eb84ae98 (diff)
Building interface to PL's parser.
Diffstat (limited to 'src/GF/UseGrammar')
-rw-r--r--src/GF/UseGrammar/Linear.hs38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/GF/UseGrammar/Linear.hs b/src/GF/UseGrammar/Linear.hs
index 9cf391393..929273562 100644
--- a/src/GF/UseGrammar/Linear.hs
+++ b/src/GF/UseGrammar/Linear.hs
@@ -8,6 +8,9 @@ import Ident
import PrGrammar
import CMacros
import Look
+import LookAbs
+import MMacros
+import TypeCheck (annotate) ----
import Str
import Unlex
----import TypeCheck -- to annotate
@@ -115,7 +118,6 @@ linTree2string mk gr m e = err id id $ do
let ss = strs2strings $ sTables2strs $ strTables2sTables ts
ifNull (prtBad "empty linearization of" e) (return . head) ss
-
-- argument is a Tree, value is a list of strs; needed in Parsing
allLinsOfTree :: CanonGrammar -> Ident -> A.Tree -> [Str]
@@ -165,23 +167,19 @@ allLinsOfFun gr f = do
-}
-
-
-
-{- ----
-- returns printname if one exists; otherwise linearizes with metas
-printOrLinearize :: CanonGrammar -> Fun -> String
-printOrLinearize gr f =
-{- ----
- errVal (prtt f) $ case lookupPrintname cnc f of
- Ok s -> return s
- _ -> -}
-
- unlines $ take 1 $ err singleton id $
- do
- t <- lookupFunType gr f
- f' <- ref2exp [] t (AC f) --- []
- lin f'
- where
- lin = linearizeToStrings gr (const id) ----
--}
+
+printOrLinearize :: CanonGrammar -> Ident -> A.Fun -> String
+printOrLinearize gr c f@(m, d) = errVal (prt fq) $
+ case lookupPrintname gr (CIQ c d) of
+ Ok t -> do
+ ss <- strsFromTerm t
+ let s = strs2strings [ss]
+ return $ ifNull (prt fq) head s
+ _ -> do
+ ty <- lookupFunType gr m d
+ f' <- ref2exp [] ty (A.QC m d)
+ tr <- annotate gr f'
+ return $ linTree2string noMark gr c tr
+ where
+ fq = CIQ m d