summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Compile/PGrammar.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-05-21 09:26:44 +0000
committeraarne <aarne@cs.chalmers.se>2008-05-21 09:26:44 +0000
commit055c0d0d5a5bb0dc75904fe53df7f2e4f5732a8f (patch)
tree0e63fb68c69c8f6ad0f78893c63420f0a3600e1c /src-3.0/GF/Compile/PGrammar.hs
parent915a1de71783ab8446b1af9e72c7ba7dfbc12d3f (diff)
GF/src is now for 2.9, and the new sources are in src-3.0 - keep it this way until the release of GF 3
Diffstat (limited to 'src-3.0/GF/Compile/PGrammar.hs')
-rw-r--r--src-3.0/GF/Compile/PGrammar.hs77
1 files changed, 77 insertions, 0 deletions
diff --git a/src-3.0/GF/Compile/PGrammar.hs b/src-3.0/GF/Compile/PGrammar.hs
new file mode 100644
index 000000000..521f616b5
--- /dev/null
+++ b/src-3.0/GF/Compile/PGrammar.hs
@@ -0,0 +1,77 @@
+----------------------------------------------------------------------
+-- |
+-- Module : PGrammar
+-- Maintainer : AR
+-- Stability : (stable)
+-- Portability : (portable)
+--
+-- > CVS $Date: 2005/05/25 10:27:12 $
+-- > CVS $Author: bringert $
+-- > CVS $Revision: 1.8 $
+--
+-- (Description of the module)
+-----------------------------------------------------------------------------
+
+module GF.Compile.PGrammar (pTerm, pTrm, pTrms,
+ pMeta, pzIdent,
+ string2ident
+ ) where
+
+---import LexGF
+import GF.Source.ParGF
+import GF.Source.SourceToGrammar (transExp)
+import GF.Grammar.Grammar
+import GF.Infra.Ident
+import qualified GF.Canon.AbsGFC as A
+import qualified GF.Canon.GFC as G
+import GF.Compile.GetGrammar
+import GF.Grammar.Macros
+import GF.Grammar.MMacros
+
+import GF.Data.Operations
+import qualified Data.ByteString.Char8 as BS
+
+pTerm :: String -> Err Term
+pTerm s = do
+ e <- pExp $ myLexer (BS.pack s)
+ transExp e
+
+pTrm :: String -> Term
+pTrm = errVal (vr (zIdent "x")) . pTerm ---
+
+pTrms :: String -> [Term]
+pTrms = map pTrm . sep [] where
+ sep t cs = case cs of
+ ',' : cs2 -> reverse t : sep [] cs2
+ c : cs2 -> sep (c:t) cs2
+ _ -> [reverse t]
+
+pTrm' :: String -> [Term]
+pTrm' = err (const []) singleton . pTerm
+
+pMeta :: String -> Integer
+pMeta _ = 0 ---
+
+pzIdent :: String -> Ident
+pzIdent = zIdent
+
+{-
+string2formsAndTerm :: String -> ([Term],Term)
+string2formsAndTerm s = case s of
+ '[':_:_ -> case span (/=']') s of
+ (x,_:y) -> (pTrms (tail x), pTrm y)
+ _ -> ([],pTrm s)
+ _ -> ([], pTrm s)
+-}
+
+string2ident :: String -> Err Ident
+string2ident s = return $ string2var s
+
+{-
+-- reads the Haskell datatype
+readGrammar :: String -> Err GrammarST
+readGrammar s = case [x | (x,t) <- reads s, ("","") <- lex t] of
+ [x] -> return x
+ [] -> Bad "no parse of Grammar"
+ _ -> Bad "ambiguous parse of Grammar"
+-}