From 3addd3dbb1b7c7a7fbb801969d9a73b11ad20829 Mon Sep 17 00:00:00 2001 From: Sergey Romanovsky Date: Sat, 28 Apr 2018 16:35:41 -0700 Subject: [PATCH] +WasmFileFormat --- exec/Wasm/WasmParser.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/exec/Wasm/WasmParser.hs b/exec/Wasm/WasmParser.hs index 311c596..a4c20a8 100644 --- a/exec/Wasm/WasmParser.hs +++ b/exec/Wasm/WasmParser.hs @@ -3,6 +3,13 @@ module Wasm.WasmParser where import Options.Applicative import Data.Semigroup ((<>)) +data WasmFileFormat = WasmText | WasmBinary | WasmScript deriving (Read, Show) + +instance Read WasmFileFormat where + readsPrec _ ("WAT":xs) = [ (WasmText, xs) ] + readsPrec _ ("WAST":xs) = [ (WasmScript, xs) ] + readsPrec _ ("WASM":xs) = [ (WasmBinary, xs) ] + data WasmParser = WasmParser { hello :: String , quiet :: Bool