add complie function
This commit is contained in:
@@ -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!"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user