From bbd09ecf4f5006fbc9535f31338683eafeab5e46 Mon Sep 17 00:00:00 2001 From: Ilya Rezvov Date: Sun, 4 Apr 2021 17:19:25 -0700 Subject: [PATCH] remove redundant clauses --- src/Language/Wasm/Parser.y | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Language/Wasm/Parser.y b/src/Language/Wasm/Parser.y index 194f950..289bbe4 100644 --- a/src/Language/Wasm/Parser.y +++ b/src/Language/Wasm/Parser.y @@ -730,8 +730,7 @@ function :: { ModuleField } : 'func' opt(ident) export_import_typeuse_locals_body { $3 $2 } export_import_typeuse_locals_body :: { Maybe Ident -> ModuleField } - : ')' { \i -> MFFunc emptyFunction { ident = i } } - | instruction_list(')') { + : instruction_list(')') { \i -> MFFunc emptyFunction { ident = i, body = snd $1 } } | '(' export_import_typeuse_locals_body1 { $2 } @@ -751,14 +750,14 @@ import_typeuse_locals_body1 :: { Maybe Ident -> ModuleField } let (ft, _) = $5 in \ident -> MFImport $ Import [] $2 $3 $ ImportFunc ident ft } - | typeuse1_cont(func_mid1, func_end) { + | typeuse1_cont(func_mid1, instruction_list(')')) { let (funcType, rest) = $1 in - let (locals, body) = either (\a -> ([], a)) id rest in + let (locals, body) = either (\a -> ([], snd a)) id rest in \ident -> MFFunc $ emptyFunction { locals, body, ident, funcType } } func_mid :: { ([LocalType], [Instruction]) } - : func_end { ([], $1) } + : instruction_list(')') { ([], snd $1) } | '(' func_mid1 { $2 } func_mid1 :: { ([LocalType], [Instruction]) } @@ -766,10 +765,6 @@ func_mid1 :: { ([LocalType], [Instruction]) } | 'local' ident valtype ')' func_mid { (LocalType (Just $2) $3 : fst $5, snd $5) } | folded_instr_list(')') { ([], snd $1) } -func_end - : ')' { [] } - | instruction_list(')') { snd $1 } - -- FUNCTION END -- -- GLOBAL --