mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
GF.Compile.ConcreteToHaskell: some documentation
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
module GF.Compile.ConcreteToHaskell where
|
-- | Translate concrete syntax to Haskell
|
||||||
|
module GF.Compile.ConcreteToHaskell(concretes2haskell,concrete2haskell) where
|
||||||
import Data.List(sort,sortBy)
|
import Data.List(sort,sortBy)
|
||||||
import Data.Function(on)
|
import Data.Function(on)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
@@ -18,14 +19,19 @@ import GF.Infra.Option
|
|||||||
import GF.Compile.Compute.ConcreteNew(normalForm,resourceValues)
|
import GF.Compile.Compute.ConcreteNew(normalForm,resourceValues)
|
||||||
import Debug.Trace
|
import Debug.Trace
|
||||||
|
|
||||||
|
-- | Generate Haskell code for the all concrete syntaxes associated with
|
||||||
|
-- the named abstract syntax in given the grammar.
|
||||||
concretes2haskell opts absname gr =
|
concretes2haskell opts absname gr =
|
||||||
[(cncname,concrete2haskell opts gr cenv absname cnc cncmod)
|
[(cncname,concrete2haskell opts gr cenv absname cnc cncmod)
|
||||||
| let cenv = resourceValues opts gr,
|
| let cenv = resourceValues opts gr,
|
||||||
cnc<-allConcretes gr absname,
|
cnc<-allConcretes gr absname,
|
||||||
let cncname = render cnc ++ ".hs"
|
let cncname = render cnc ++ ".hs" :: FilePath
|
||||||
Ok cncmod = lookupModule gr cnc
|
Ok cncmod = lookupModule gr cnc
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- | Generate Haskell code for the given concrete module.
|
||||||
|
-- The only options that make a difference are
|
||||||
|
-- @-haskell=noprefix@ and @-haskell=variants@.
|
||||||
concrete2haskell opts gr cenv absname cnc modinfo =
|
concrete2haskell opts gr cenv absname cnc modinfo =
|
||||||
renderStyle style{lineLength=80,ribbonsPerLine=1} $
|
renderStyle style{lineLength=80,ribbonsPerLine=1} $
|
||||||
haskPreamble va absname cnc $$ "" $$
|
haskPreamble va absname cnc $$ "" $$
|
||||||
|
|||||||
Reference in New Issue
Block a user