summaryrefslogtreecommitdiff
path: root/src/GF/Parsing/FCFG.hs
blob: f4aa806d5a8cf24716f6f59aef6f207989e175f2 (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
----------------------------------------------------------------------
-- |
-- Maintainer  : Krasimir Angelov
-- Stability   : (stable)
-- Portability : (portable)
--
-- FCFG parsing
-----------------------------------------------------------------------------

module GF.Parsing.FCFG
    (parseFCF, module GF.Parsing.FCFG.PInfo) where

import GF.Data.Operations (Err(..))

import GF.Formalism.Utilities
import GF.Formalism.GCFG
import GF.Formalism.MCFG
import GF.Parsing.FCFG.PInfo

import qualified GF.Parsing.FCFG.Active as Active
import GF.Infra.Print

----------------------------------------------------------------------
-- parsing

parseFCF :: (Print c, Ord c, Print n, Ord n, Print t, Ord t) => String -> Err (FCFParser c n t)
parseFCF prs | prs `elem` strategies = Ok $ parseFCF' prs
	     | otherwise = Bad $ "FCFG parsing strategy not defined: " ++ prs 

strategies = words "bottomup topdown"

parseFCF' :: (Print c, Ord c, Print n, Ord n, Print t, Ord t) => String -> FCFParser c n t
parseFCF' "bottomup" pinfo starts toks = Active.parse "b" pinfo starts toks 
parseFCF' "topdown"  pinfo starts toks = Active.parse "t" pinfo starts toks