summaryrefslogtreecommitdiff
path: root/src/GF/Grammar
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-10-02 23:34:35 +0000
committerkrasimir <krasimir@chalmers.se>2009-10-02 23:34:35 +0000
commit4c77dcf9388315411539b513aaac5f48b5c875ad (patch)
tree0a857e4c41fee417a35d41a0e3adffc9c100a3de /src/GF/Grammar
parentd64419f2f25f0fb5a28bddf198dce6ac26b75296 (diff)
merge GF.Grammar.API into GF.Grammar
Diffstat (limited to 'src/GF/Grammar')
-rw-r--r--src/GF/Grammar/API.hs58
-rw-r--r--src/GF/Grammar/Printer.hs14
2 files changed, 14 insertions, 58 deletions
diff --git a/src/GF/Grammar/API.hs b/src/GF/Grammar/API.hs
deleted file mode 100644
index 8dc86c10e..000000000
--- a/src/GF/Grammar/API.hs
+++ /dev/null
@@ -1,58 +0,0 @@
-module GF.Grammar.API (
- Grammar,
- emptyGrammar,
- checkTerm,
- computeTerm,
- showTerm,
- TermPrintStyle(..), TermPrintQual(..),
- ) where
-
-import GF.Infra.Ident
-import GF.Infra.CheckM
-import GF.Infra.Modules (greatestResource)
-import GF.Compile.GetGrammar
-import GF.Grammar.Macros
-import GF.Grammar.Parser
-import GF.Grammar.Printer
-import GF.Grammar.Grammar
-
-import GF.Compile.Rename (renameSourceTerm)
-import GF.Compile.CheckGrammar (inferLType)
-import GF.Compile.Compute (computeConcrete)
-
-import GF.Data.Operations
-import GF.Infra.Option
-
-import qualified Data.ByteString.Char8 as BS
-import Text.PrettyPrint
-
-type Grammar = SourceGrammar
-
-emptyGrammar :: Grammar
-emptyGrammar = emptySourceGrammar
-
-checkTerm :: Grammar -> Term -> Err Term
-checkTerm gr t = do
- mo <- maybe (Bad "no source grammar in scope") return $ greatestResource gr
- checkTermAny gr mo t
-
-checkTermAny :: Grammar -> Ident -> Term -> Err Term
-checkTermAny gr m t = (fmap fst . runCheck) $ do
- t <- renameSourceTerm gr m t
- (t,_) <- inferLType gr [] t
- return t
-
-computeTerm :: Grammar -> Term -> Err Term
-computeTerm = computeConcrete
-
-showTerm :: TermPrintStyle -> TermPrintQual -> Term -> String
-showTerm style q t = render $
- case style of
- TermPrintTable -> vcat [p <+> s | (p,s) <- ppTermTabular q t]
- TermPrintAll -> vcat [ s | (p,s) <- ppTermTabular q t]
- TermPrintDefault -> ppTerm q 0 t
-
-data TermPrintStyle
- = TermPrintTable
- | TermPrintAll
- | TermPrintDefault
diff --git a/src/GF/Grammar/Printer.hs b/src/GF/Grammar/Printer.hs
index e0edadbec..80195b2d1 100644
--- a/src/GF/Grammar/Printer.hs
+++ b/src/GF/Grammar/Printer.hs
@@ -18,6 +18,8 @@ module GF.Grammar.Printer
, ppPatt
, ppValue
, ppConstrs
+
+ , showTerm, TermPrintStyle(..)
) where
import GF.Infra.Ident
@@ -301,3 +303,15 @@ getLet :: Term -> ([LocalDef], Term)
getLet (Let l e) = let (ls,e') = getLet e
in (l:ls,e')
getLet e = ([],e)
+
+showTerm :: TermPrintStyle -> TermPrintQual -> Term -> String
+showTerm style q t = render $
+ case style of
+ TermPrintTable -> vcat [p <+> s | (p,s) <- ppTermTabular q t]
+ TermPrintAll -> vcat [ s | (p,s) <- ppTermTabular q t]
+ TermPrintDefault -> ppTerm q 0 t
+
+data TermPrintStyle
+ = TermPrintTable
+ | TermPrintAll
+ | TermPrintDefault