diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-05-20 11:47:44 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-05-20 11:47:44 +0000 |
| commit | 31bf84122b21efb444aa8d055472e166ffb90783 (patch) | |
| tree | 1f051909336f1534346bcccde8dda59beab02f64 /src-2.9/GF/Embed/EmbedParsing.hs | |
| parent | 74f048dcf41de3540778de54dfa7541fa5b39c46 (diff) | |
moved all old source code to src-2.9 ; src will be for GF 3 development
Diffstat (limited to 'src-2.9/GF/Embed/EmbedParsing.hs')
| -rw-r--r-- | src-2.9/GF/Embed/EmbedParsing.hs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src-2.9/GF/Embed/EmbedParsing.hs b/src-2.9/GF/Embed/EmbedParsing.hs new file mode 100644 index 000000000..43909f355 --- /dev/null +++ b/src-2.9/GF/Embed/EmbedParsing.hs @@ -0,0 +1,65 @@ +---------------------------------------------------------------------- +-- | +-- Module : EmbedParsing +-- Maintainer : AR +-- Stability : (stable) +-- Portability : (portable) +-- +-- > CVS $Date: +-- > CVS $Author: +-- > CVS $Revision: +-- +-- just one parse method, for use in embedded GF systems +----------------------------------------------------------------------------- + +module GF.Embed.EmbedParsing where + +import GF.Infra.CheckM +import qualified GF.Canon.AbsGFC as C +import GF.Canon.GFC +import GF.Canon.MkGFC (trExp) ---- +import GF.Canon.CMacros +import GF.Grammar.MMacros (refreshMetas) +import GF.UseGrammar.Linear +import GF.Data.Str +import GF.CF.CF +import GF.CF.CFIdent +import GF.Infra.Ident +import GF.Grammar.TypeCheck +import GF.Grammar.Values +import GF.UseGrammar.Tokenize +import GF.CF.Profile +import GF.Infra.Option +import GF.Compile.ShellState +import GF.Embed.EmbedCustom +import GF.CF.PPrCF (prCFTree) +import qualified GF.Parsing.GFC as New + + +-- import qualified GF.Parsing.GFC as New + +import GF.Data.Operations + +import Data.List (nub) +import Control.Monad (liftM) + +-- AR 26/1/2000 -- 8/4 -- 28/1/2001 -- 9/12/2002 + +parseString :: Options -> StateGrammar -> CFCat -> String -> Err [Tree] +parseString os sg cat = liftM fst . parseStringMsg os sg cat + +parseStringMsg :: Options -> StateGrammar -> CFCat -> String -> Err ([Tree],String) +parseStringMsg os sg cat s = do + (ts,(_,ss)) <- checkStart $ parseStringC os sg cat s + return (ts,unlines ss) + +parseStringC :: Options -> StateGrammar -> CFCat -> String -> Check [Tree] +parseStringC opts0 sg cat s = do + let opts = unionOptions opts0 $ stateOptions sg + algorithm = "f" -- default algorithm: FCFG + strategy = "bottomup" + tokenizer = customOrDefault opts useTokenizer customTokenizer sg + toks = tokenizer s + ts <- checkErr $ New.parse algorithm strategy (pInfo sg) (absId sg) cat toks + checkErr $ allChecks $ map (annotate (stateGrammarST sg) . refreshMetas []) ts + |
