mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
Honor the --name flag when generating output files. Set module name in generated Haskell modules correctly.
This commit is contained in:
@@ -27,24 +27,26 @@ import Data.List --(isPrefixOf, find, intersperse)
|
||||
import qualified Data.Map as Map
|
||||
|
||||
-- | the main function
|
||||
grammar2haskell :: PGF -> String
|
||||
grammar2haskell gr = encodeUTF8 $ foldr (++++) [] $
|
||||
haskPreamble ++ [datatypes gr', gfinstances gr']
|
||||
grammar2haskell :: PGF
|
||||
-> String -- ^ Module name.
|
||||
-> String
|
||||
grammar2haskell gr name = encodeUTF8 $ foldr (++++) [] $
|
||||
haskPreamble name ++ [datatypes gr', gfinstances gr']
|
||||
where gr' = hSkeleton gr
|
||||
|
||||
grammar2haskellGADT :: PGF -> String
|
||||
grammar2haskellGADT gr = encodeUTF8 $ foldr (++++) [] $
|
||||
grammar2haskellGADT :: PGF -> String -> String
|
||||
grammar2haskellGADT gr name = encodeUTF8 $ foldr (++++) [] $
|
||||
["{-# OPTIONS_GHC -fglasgow-exts #-}"] ++
|
||||
haskPreamble ++ [datatypesGADT gr', gfinstances gr']
|
||||
haskPreamble name ++ [datatypesGADT gr', gfinstances gr']
|
||||
where gr' = hSkeleton gr
|
||||
|
||||
-- | by this you can prefix all identifiers with stg; the default is 'G'
|
||||
gId :: OIdent -> OIdent
|
||||
gId i = 'G':i
|
||||
|
||||
haskPreamble =
|
||||
haskPreamble name =
|
||||
[
|
||||
"module GSyntax where",
|
||||
"module " ++ name ++ " where",
|
||||
"",
|
||||
"import PGF.CId",
|
||||
"import PGF.Data",
|
||||
|
||||
Reference in New Issue
Block a user