summaryrefslogtreecommitdiff
path: root/src/GF/OldParsing/ParseCFG.hs
blob: 03c1d7dcc12de5db73341b4d68f3b55120def97c (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
----------------------------------------------------------------------
-- |
-- Module      : ParseCFG
-- Maintainer  : PL
-- Stability   : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/04/21 16:22:49 $ 
-- > CVS $Author: bringert $
-- > CVS $Revision: 1.2 $
--
-- Main parsing module for context-free grammars
-----------------------------------------------------------------------------


module GF.OldParsing.ParseCFG (parse) where

import Data.Char (toLower)
import GF.OldParsing.Utilities
import GF.OldParsing.CFGrammar
import qualified GF.OldParsing.ParseCFG.General as PGen
import qualified GF.OldParsing.ParseCFG.Incremental as PInc


parse :: (Ord n, Ord c, Ord t, Show t) => 
	 String -> CFParser n c t
parse = decodeParser . map toLower

decodeParser ['g',s]   = PGen.parse (decodeStrategy s)
decodeParser ['i',s,f] = PInc.parse (decodeStrategy s, decodeFilter f)
decodeParser _ = decodeParser "ibn"

decodeStrategy 'b' = (True, False)
decodeStrategy 't' = (False, True)

decodeFilter 'a' = (True, True)
decodeFilter 'b' = (True, False)
decodeFilter 't' = (False, True)
decodeFilter 'n' = (False, False)