aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-09-09 17:00:09 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-09-09 17:00:09 +0100
commitd24d92034ea278750668daff810147e0aec9dc04 (patch)
treeb4edce0a3c93b3759e0af61d8077837510dca81a
parentbcc469bc7f1d73e66828637b5b518b7cab8e2781 (diff)
downloadmicro-lang-hs-d24d92034ea278750668daff810147e0aec9dc04.tar.gz
micro-lang-hs-d24d92034ea278750668daff810147e0aec9dc04.zip
Pass the version
-rw-r--r--app/Main.hs2
-rw-r--r--src/Micro/Asm/Sdcc.hs8
-rw-r--r--src/Micro/Compiler.hs5
3 files changed, 8 insertions, 7 deletions
diff --git a/app/Main.hs b/app/Main.hs
index db970d9..e1be59d 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -14,8 +14,6 @@ import System.Environment.Blank (getArgs)
import System.Exit (exitFailure, exitSuccess)
import System.IO (hPutStr, hPutStrLn, stderr, stdout)
-version = "0.1.0"
-
data Options = Options
{ optParse :: Bool,
optHelp :: Bool,
diff --git a/src/Micro/Asm/Sdcc.hs b/src/Micro/Asm/Sdcc.hs
index ef655d4..1fb05dd 100644
--- a/src/Micro/Asm/Sdcc.hs
+++ b/src/Micro/Asm/Sdcc.hs
@@ -31,8 +31,8 @@ onlyData symm =
filter (\sym -> symRef sym) $
Map.elems symm
-header :: [String]
-header = [";", "; File created by $$$ v?.?.? (SDCC)", ";"]
+header :: String -> [String]
+header version = [";", "; File created by Micro v" ++ version ++ " (SDCC)", ";"]
module' :: A.Expr -> [String]
module' (A.Module name _) = ["\t.module " ++ name, "\t.optsdcc -mz80"]
@@ -62,5 +62,5 @@ initVars symm =
code :: [String]
code = ["\n\t.area _CODE"]
-generate :: SymMap -> [A.Expr] -> String
-generate symm ast = unlines $ header ++ module' (head ast) ++ exports symm ++ dataVars symm ++ code ++ initVars symm
+generate :: String -> SymMap -> [A.Expr] -> String
+generate version symm ast = unlines $ header version ++ module' (head ast) ++ exports symm ++ dataVars symm ++ code ++ initVars symm
diff --git a/src/Micro/Compiler.hs b/src/Micro/Compiler.hs
index b765c16..de5728a 100644
--- a/src/Micro/Compiler.hs
+++ b/src/Micro/Compiler.hs
@@ -8,6 +8,9 @@ import Micro.Env
import Micro.Error
import Text.Parsec (SourcePos)
+version :: String
+version = "0.1.0"
+
type CompState = (Env, [Error])
data CompResult = CompResult
@@ -207,5 +210,5 @@ compileAll ast = do
_ <- traverse compile ast
((Env sym _), errs) <- get
case errs of
- [] -> pure $ successResult $ generate sym ast
+ [] -> pure $ successResult $ generate version sym ast
_ -> return $ errorResult errs