summaryrefslogtreecommitdiff
path: root/src/GF/Compile/ReadFiles.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-03-16 14:10:30 +0000
committerkrasimir <krasimir@chalmers.se>2009-03-16 14:10:30 +0000
commita391c69fd3937cab699dbf18ec042c7eca93ac9a (patch)
tree4c1ff08c286ed6d5fdb7b875430adf816e21d6b9 /src/GF/Compile/ReadFiles.hs
parent5597cff5cb186616a0db14a2e579f7261f1a32a3 (diff)
use new parser which supports the syntax in GF.Grammar.Grammar directly
Diffstat (limited to 'src/GF/Compile/ReadFiles.hs')
-rw-r--r--src/GF/Compile/ReadFiles.hs27
1 files changed, 5 insertions, 22 deletions
diff --git a/src/GF/Compile/ReadFiles.hs b/src/GF/Compile/ReadFiles.hs
index 492dbdcf2..fbe1fda0b 100644
--- a/src/GF/Compile/ReadFiles.hs
+++ b/src/GF/Compile/ReadFiles.hs
@@ -29,9 +29,8 @@ import GF.Infra.Ident
import GF.Infra.Modules
import GF.Data.Operations
import qualified GF.Source.AbsGF as S
-import GF.Source.LexGF
-import GF.Source.ParGF
-import GF.Source.SourceToGrammar(transModDef)
+import GF.Grammar.Lexer
+import GF.Grammar.Parser
import GF.Grammar.Grammar
import GF.Grammar.Binary
@@ -109,29 +108,13 @@ getAllFiles opts ps env file = do
CSEnv -> return (name, maybe [] snd mb_envmod)
CSRead -> ioeIO $ fmap importsOfModule (decodeModHeader (replaceExtension file "gfo"))
CSComp -> do s <- ioeIO $ BS.readFile file
- ioeErr ((liftM (importsOfModule . modHeaderToModDef) . pModHeader . myLexer) s)
+ case runP pModHeader s of
+ Left (Pn l c,msg) -> ioeBad (file ++ ":" ++ show l ++ ":" ++ show c ++ ": " ++ msg)
+ Right mo -> return (importsOfModule mo)
ioeErr $ testErr (mname == name)
("module name" +++ mname +++ "differs from file name" +++ name)
return (name,st,t,imps,dropFileName file)
--- FIXME: this is pretty ugly, it's just to get around the difference
--- between ModHeader as returned when parsing just the module header
--- when looking for imports, and ModDef, which includes the whole module.
-modHeaderToModDef :: S.ModHeader -> SourceModule
-modHeaderToModDef (S.MModule2 x y z) =
- errVal (error "error in modHeaderToModDef") $ transModDef $ S.MModule x y (modHeaderBodyToModBody z)
- where
- modHeaderBodyToModBody :: S.ModHeaderBody -> S.ModBody
- modHeaderBodyToModBody b = case b of
- S.MBody2 x y -> S.MBody x y []
- S.MNoBody2 x -> S.MNoBody x
- S.MWith2 x y -> S.MWith x y
- S.MWithBody2 x y z -> S.MWithBody x y z []
- S.MWithE2 x y z -> S.MWithE x y z
- S.MWithEBody2 x y z w -> S.MWithEBody x y z w []
- S.MReuse2 x -> S.MReuse x
- S.MUnion2 x -> S.MUnion x
-
isGFO :: FilePath -> Bool
isGFO = (== ".gfo") . takeExtensions