summaryrefslogtreecommitdiff
path: root/src-3.0/GF/GFCC/PrintGFCC.hs
blob: 6eee6f11209b0fc363b10119ab853d926e6d98bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module GF.GFCC.PrintGFCC where

import GF.GFCC.DataGFCC (GFCC)
import GF.GFCC.Raw.ConvertGFCC (fromGFCC)
import GF.GFCC.Raw.PrintGFCCRaw (printTree)
import GF.GFCC.GFCCtoHaskell
import GF.GFCC.GFCCtoJS
import GF.Infra.Option
import GF.Text.UTF8

-- top-level access to code generation

prGFCC :: OutputFormat -> GFCC -> String
prGFCC fmt gr = case fmt of
  FmtGFCC        -> printGFCC gr
  FmtJavaScript  -> gfcc2js gr
  FmtHaskell     -> grammar2haskell gr
  FmtHaskellGADT -> grammar2haskellGADT gr

printGFCC :: GFCC -> String
printGFCC = encodeUTF8 . printTree . fromGFCC