add complie function

This commit is contained in:
Ilya Rezvov
2018-04-28 14:31:40 -07:00
parent 1cf5b34d07
commit c5daf5b187
2 changed files with 17 additions and 0 deletions
+16
View File
@@ -1,5 +1,12 @@
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.ByteString.Lazy as LBS
import qualified Language.Wasm.Lexer as Lexer
import qualified Language.Wasm.Parser as Parser
import qualified Language.Wasm.Binary as Binary
data OutputMode = WasmBinary | JSWrapper deriving (Show, Eq)
data WasmConfig = WasmConfig {
@@ -8,6 +15,15 @@ data WasmConfig = WasmConfig {
outputMode :: OutputMode
} deriving (Show, Eq)
compile :: String -> String -> IO ()
compile input output = do
content <- LBS.readFile input
case Lexer.scanner content >>= Parser.parseModule of
Right mod ->
LBS.writeFile output $ Binary.dumpModuleLazy mod
Left reason ->
putStrLn $ "Cannot complie module: " ++ reason
main :: IO ()
main = do
putStrLn "There is no WASM!"
+1
View File
@@ -57,6 +57,7 @@ executable wasm
base >=4.6 && <5.0
, wasm ==0.1.0
, optparse-applicative >= 0.13
, bytestring >=0.10 && <0.11
test-suite test
type: exitcode-stdio-1.0