From c8ebe093150509d9f01d82f0d698ef5df09bd985 Mon Sep 17 00:00:00 2001 From: krasimir Date: Mon, 21 Mar 2016 13:27:44 +0000 Subject: initial support for BNFC syntax in context-free grammars for GF. Not all features are supported yet. Based on contribution from Gleb Lobanov --- src/compiler/GF/Compiler.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/compiler/GF/Compiler.hs') diff --git a/src/compiler/GF/Compiler.hs b/src/compiler/GF/Compiler.hs index 79ed66e7c..66d88eb69 100644 --- a/src/compiler/GF/Compiler.hs +++ b/src/compiler/GF/Compiler.hs @@ -9,6 +9,7 @@ import GF.Compile.Export import GF.Compile.ConcreteToHaskell(concretes2haskell) import GF.Compile.CFGtoPGF import GF.Compile.GetGrammar +import GF.Grammar.BNFC import GF.Grammar.CFG --import GF.Infra.Ident(showIdent) @@ -85,12 +86,12 @@ linkGrammars opts (t_src,~cnc_grs@(~(cnc,gr):_)) = compileCFFiles :: Options -> [FilePath] -> IOE () compileCFFiles opts fs = do - rules <- fmap concat $ mapM (getCFRules opts) fs + bnfc_rules <- fmap concat $ mapM (getBNFCRules opts) fs + let rules = bnfc2cf bnfc_rules startCat <- case rules of (CFRule cat _ _ : _) -> return cat _ -> fail "empty CFG" let pgf = cf2pgf (last fs) (uniqueFuns (mkCFG startCat Set.empty rules)) ---let cnc = justModuleName (last fs) unless (flag optStopAfterPhase opts == Compile) $ do probs <- liftIO (maybe (return . defaultProbabilities) readProbabilitiesFromFile (flag optProbsFile opts) pgf) let pgf' = setProbabilities probs $ if flag optOptimizePGF opts then optimizePGF pgf else pgf -- cgit v1.2.3