summaryrefslogtreecommitdiff
path: root/src/GF/Compile/NoParse.hs
blob: c8f8289703dc50285f85393ab3b5326e78bbb2df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
     _ -> []