summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Compile/NoParse.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/NoParse.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/NoParse.hs')
-rw-r--r--src-3.0/GF/Compile/NoParse.hs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src-3.0/GF/Compile/NoParse.hs b/src-3.0/GF/Compile/NoParse.hs
new file mode 100644
index 000000000..c8f828970
--- /dev/null
+++ b/src-3.0/GF/Compile/NoParse.hs
@@ -0,0 +1,49 @@
+----------------------------------------------------------------------
+-- |
+-- Module : NoParse
+-- Maintainer : AR
+-- Stability : (stable)
+-- Portability : (portable)
+--
+-- > CVS $Date: 2005/11/14 16:03:41 $
+-- > CVS $Author: aarne $
+-- > CVS $Revision: 1.1 $
+--
+-- Probabilistic abstract syntax. AR 30\/10\/2005
+--
+-- (c) Aarne Ranta 2005 under GNU GPL
+--
+-- Contents: decide what lin rules no parser is generated.
+-- Usually a list of noparse idents from 'i -boparse=file'.
+
+-----------------------------------------------------------------------------
+
+module GF.Compile.NoParse (
+ NoParse -- = Ident -> Bool
+ ,getNoparseFromFile -- :: Opts -> IO NoParse
+ ,doParseAll -- :: NoParse
+ ) where
+
+import GF.Infra.Ident
+import GF.Data.Operations
+import GF.Infra.Option
+
+
+type NoParse = (Ident -> Bool)
+
+doParseAll :: NoParse
+doParseAll = const False
+
+getNoparseFromFile :: Options -> FilePath -> IO NoParse
+getNoparseFromFile opts file = do
+ let f = maybe file id $ getOptVal opts noparseFile
+ s <- readFile f
+ let tree = buildTree $ flip zip (repeat ()) $ concat $ map getIgnores $ lines s
+ tree `seq` return $ igns tree
+ where
+ igns tree i = isInBinTree i tree
+
+-- where
+getIgnores s = case dropWhile (/="--#") (words s) of
+ _:"noparse":fs -> map identC fs
+ _ -> []