summaryrefslogtreecommitdiff
path: root/src/GF/Devel/GFC.hs
blob: 0e3c7550127911e971360541bc9f8a5686e22b8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Main where

import GF.Devel.Compile
import GF.Devel.GrammarToGFCC
import GF.Canon.GFCC.CheckGFCC
import GF.Canon.GFCC.PrintGFCC
import GF.Canon.GFCC.DataGFCC
import GF.Devel.UseIO
import GF.Infra.Option
---import GF.Devel.PrGrammar ---

import System


main = do
  xx <- getArgs
  let (opts,fs) = getOptions "-" xx
  case opts of
    _ | oElem (iOpt "help") opts -> putStrLn "usage: gfc (--make) FILES"
    _ | oElem (iOpt "-make") opts -> do
      gr <- batchCompile opts fs
      let name = justModuleName (last fs)
      let (abs,gc0) = mkCanon2gfcc opts name gr
      gc <- check gc0
      let target = abs ++ ".gfcc"
      writeFile target (printGFCC gc)
      putStrLn $ "wrote file " ++ target
    _ -> do
      mapM_ (batchCompile opts) (map return fs)
      putStrLn "Done."

check gc0 = do
  let gfcc = mkGFCC gc0
  (gc,b) <- checkGFCC gfcc
  putStrLn $ if b then "OK" else "Corrupted GFCC"
  return gc