I want to be able to do this:
$ cat myGrammar.cf
S ::= "Hello" "World" ;
$ gf -f gf myGrammar.cf
Writing myGrammar.gf myGrammarCnc.gf
$ cat myGrammar.gf
abstract myGrammar = {
cat S ;
fun S_Hello_World : S ;
}
concrete myGrammarCnc of myGrammar = {
lincat S = Str ;
lin S_Hello_World = "Hello" ++ "World" ;
}
I infer from this line that this has been an intention 12 years ago.
|
cfGF :: FilePath -> IO GF |
However, this line shows that it has never worked:
I see also that the conversion from cf goes directly into PGF here without going to GF source code first:
|
compileCFFiles :: Options -> [FilePath] -> IOE () |
|
compileCFFiles opts fs = do |
|
bnfc_rules <- fmap concat $ mapM (getBNFCRules opts) fs |
|
let rules = bnfc2cf bnfc_rules |
|
startCat <- case rules of |
|
(Rule cat _ _ : _) -> return cat |
|
_ -> fail "empty CFG" |
|
let pgf = cf2pgf (last fs) (mkCFG startCat Set.empty rules) |
|
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 |
|
writePGF opts pgf' |
|
writeOutputs opts pgf' |
Is there any way to piece together generation of GF source code from existing code, such as using any functions that produce canonical GF? I have already tried to use the -f canonical_gf flag, but it doesn't work for cf files as input, only for gf files.
I want to be able to do this:
I infer from this line that this has been an intention 12 years ago.
gf-core/src/compiler/GF/CompilerAPI.hs
Line 63 in 85038d0
However, this line shows that it has never worked:
gf-core/src/compiler/GF/CompilerAPI.hs
Line 89 in 85038d0
I see also that the conversion from cf goes directly into PGF here without going to GF source code first:
gf-core/src/compiler/GF/Compiler.hs
Lines 111 to 123 in 85038d0
Is there any way to piece together generation of GF source code from existing code, such as using any functions that produce canonical GF? I have already tried to use the
-f canonical_gfflag, but it doesn't work for cf files as input, only for gf files.