diff --git a/lib/Bril.hs b/lib/Bril.hs index a7a08f7..c4d4c4b 100644 --- a/lib/Bril.hs +++ b/lib/Bril.hs @@ -74,11 +74,11 @@ data Arity = deriving (Eq, Show) valueOps = toSortedList ([ - "add", "mul", "sub", "div", "eq", "lt", "gt", "le", "ge", "not", "and", "or" + "add", "mul", "sub", "div", "eq", "lt", "gt", "le", "ge", "not", "and", "or", "id" ] :: [T.Text]) effectOps = toSortedList ([ - "nop", "call", "jmp", "br", "print", "lt", "gt", "le", "ge", "not", "and", "or" + "nop", "call", "jmp", "br", "print", "ret" ] :: [T.Text]) arity instr diff --git a/tests/Main.hs b/tests/Main.hs index 55c0bdb..671c9f9 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -77,6 +77,10 @@ testInstrs = TestCase $ do (eitherDecode "{\"op\": \"br\", \"labels\": [\"a\", \"b\"], \"args\": [\"z\"]}") (Right $ B.EffectInstr B.Br ["z"] [] ["a", "b"]) + assertEqual "parse id" + (eitherDecode "{\"op\": \"id\", \"dest\": \"a\", \"type\": \"bool\", \"args\": [\"b\"]}") + (Right $ B.ValueInstr B.Id B.Bool "a" ["b"] [] []) + testProgramFromFiles :: Test testProgramFromFiles = TestCase $ do res <- try $ (B.parseBrilFromPath "bril-sources/add.json") :: IO (Either IOError (Either String B.Program))