mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-24 10:22:50 -06:00
Making cf2gf to work...
This commit is contained in:
@@ -6,7 +6,6 @@ import PGrammar
|
|||||||
import TypeCheck
|
import TypeCheck
|
||||||
import Compile
|
import Compile
|
||||||
import ShellState
|
import ShellState
|
||||||
import GetGrammar
|
|
||||||
|
|
||||||
import Modules
|
import Modules
|
||||||
import Option
|
import Option
|
||||||
@@ -38,11 +37,6 @@ string2annotTree gr m = annotate gr . string2absTerm (prt m) ---- prt
|
|||||||
|
|
||||||
shellStateFromFiles :: Options -> ShellState -> FilePath -> IOE ShellState
|
shellStateFromFiles :: Options -> ShellState -> FilePath -> IOE ShellState
|
||||||
shellStateFromFiles opts st file = case fileSuffix file of
|
shellStateFromFiles opts st file = case fileSuffix file of
|
||||||
"cf" -> do
|
|
||||||
let opts' = addOptions (options [beVerbose]) opts
|
|
||||||
sgr <- getCFGrammar opts' file
|
|
||||||
ioeIO $ print sgr -----
|
|
||||||
return st
|
|
||||||
"gfcm" -> do
|
"gfcm" -> do
|
||||||
(_,_,cgr) <- compileOne opts (compileEnvShSt st []) file
|
(_,_,cgr) <- compileOne opts (compileEnvShSt st []) file
|
||||||
ioeErr $ updateShellState opts st (cgr,(emptyMGrammar,[]))
|
ioeErr $ updateShellState opts st (cgr,(emptyMGrammar,[]))
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ getCFRule mo s = getcf (wrds s) where
|
|||||||
fun : cat : _ : its = words s
|
fun : cat : _ : its = words s
|
||||||
mkIt ('"':w@(_:_)) = atomCFTerm (string2CFTok (init w))
|
mkIt ('"':w@(_:_)) = atomCFTerm (string2CFTok (init w))
|
||||||
mkIt w = CFNonterm (string2CFCat mo w)
|
mkIt w = CFNonterm (string2CFCat mo w)
|
||||||
getcf _ = Bad "invalid rule"
|
getcf _ = Bad (" invalid rule:" +++ s)
|
||||||
wrds = takeWhile (/= ";") . words -- to permit semicolon in the end
|
wrds = takeWhile (/= ";") . words -- to permit semicolon in the end
|
||||||
|
|
||||||
pCF :: String -> String -> Err CF
|
pCF :: String -> String -> Err CF
|
||||||
|
|||||||
@@ -55,10 +55,13 @@ batchCompileOld f = compileOld defOpts f
|
|||||||
|
|
||||||
compileModule :: Options -> ShellState -> FilePath ->
|
compileModule :: Options -> ShellState -> FilePath ->
|
||||||
IOE (GFC.CanonGrammar, (SourceGrammar,[(FilePath,ModTime)]))
|
IOE (GFC.CanonGrammar, (SourceGrammar,[(FilePath,ModTime)]))
|
||||||
compileModule opts st0 file | oElem showOld opts = do
|
|
||||||
|
compileModule opts st0 file | oElem showOld opts || fileSuffix file == "cf" = do
|
||||||
let putp = putPointE opts
|
let putp = putPointE opts
|
||||||
let path = [] ----
|
let path = [] ----
|
||||||
grammar1 <- putp ("- parsing old gf" +++ file) $ getOldGrammar opts file
|
grammar1 <- if fileSuffix file == "cf"
|
||||||
|
then putp ("- parsing cf" +++ file) $ getCFGrammar opts file
|
||||||
|
else putp ("- parsing old gf" +++ file) $ getOldGrammar opts file
|
||||||
let mods = modules grammar1
|
let mods = modules grammar1
|
||||||
let env = compileEnvShSt st0 []
|
let env = compileEnvShSt st0 []
|
||||||
(_,sgr,cgr) <- foldM (comp putp path) env mods
|
(_,sgr,cgr) <- foldM (comp putp path) env mods
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ getCFGrammar :: Options -> FilePath -> IOE SourceGrammar
|
|||||||
getCFGrammar opts file = do
|
getCFGrammar opts file = do
|
||||||
let mo = takeWhile (/='-') file
|
let mo = takeWhile (/='-') file
|
||||||
s <- ioeIO $ readFileIf file
|
s <- ioeIO $ readFileIf file
|
||||||
cf <- ioeErr $ pCF mo file
|
cf <- ioeErr $ pCF mo s
|
||||||
defs <- return $ cf2grammar cf
|
defs <- return $ cf2grammar cf
|
||||||
let g = A.OldGr A.NoIncl defs
|
let g = A.OldGr A.NoIncl defs
|
||||||
ioeErr $ transOldGrammar opts file g
|
ioeErr $ transOldGrammar opts file g
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ i, import: i File
|
|||||||
.gfr precompiled GF resource
|
.gfr precompiled GF resource
|
||||||
.gfcm multilingual canonical GF
|
.gfcm multilingual canonical GF
|
||||||
*.ebnf Extended BNF format
|
*.ebnf Extended BNF format
|
||||||
*.cf Context-free (BNF) format
|
.cf Context-free (BNF) format
|
||||||
options:
|
options:
|
||||||
-old old: parse in GF<2.0 format
|
-old old: parse in GF<2.0 format
|
||||||
-v verbose: give lots of messages
|
-v verbose: give lots of messages
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module Today where today = "Wed Mar 24 16:54:35 CET 2004"
|
module Today where today = "Wed Mar 24 17:14:49 CET 2004"
|
||||||
|
|||||||
Reference in New Issue
Block a user