Fix id, ret parsing

This commit is contained in:
Enrico Lumetti 2024-10-06 12:28:06 +02:00
parent 8e5112ed93
commit b635fde2c5
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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))