never executed always true always false
1 {- |
2 Module : NITTA.Frontends.FrontendIdentifier
3 Description : Chooses a frontend based on source file extension or format
4 Copyright : (c) Artur Gogiyan, 2022
5 License : BSD3
6 Maintainer : artur.gogiyan@gmail.com
7 Stability : experimental
8 -}
9 module NITTA.Frontends (
10 FrontendType (..),
11 FrontendResult (..),
12 TraceVar (..),
13 prettyLog,
14 getTraceVarFormat,
15 identifyFrontendType,
16 translate,
17 ) where
18
19 import Data.Data
20 import Data.Maybe
21 import NITTA.Frontends.Common
22 import NITTA.Frontends.Lua
23 import NITTA.Frontends.XMILE.Frontend
24 import System.FilePath
25
26 data FrontendType = Lua | XMILE
27 deriving (Show, Data)
28
29 identifyFrontendType fileName frontendType = fromMaybe identifyByExtension frontendType
30 where
31 identifyByExtension =
32 case snd $ splitExtension fileName of
33 ".lua" -> Lua
34 ".xmile" -> XMILE
35 ext -> error $ "unknown file extensions: " <> ext <> " for " <> fileName
36
37 translate Lua = translateLua
38 translate XMILE = translateXMILE