Fix id, ret parsing
This commit is contained in:
parent
8e5112ed93
commit
b635fde2c5
|
|
@ -74,11 +74,11 @@ data Arity =
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
valueOps = toSortedList ([
|
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])
|
] :: [T.Text])
|
||||||
|
|
||||||
effectOps = toSortedList ([
|
effectOps = toSortedList ([
|
||||||
"nop", "call", "jmp", "br", "print", "lt", "gt", "le", "ge", "not", "and", "or"
|
"nop", "call", "jmp", "br", "print", "ret"
|
||||||
] :: [T.Text])
|
] :: [T.Text])
|
||||||
|
|
||||||
arity instr
|
arity instr
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,10 @@ testInstrs = TestCase $ do
|
||||||
(eitherDecode "{\"op\": \"br\", \"labels\": [\"a\", \"b\"], \"args\": [\"z\"]}")
|
(eitherDecode "{\"op\": \"br\", \"labels\": [\"a\", \"b\"], \"args\": [\"z\"]}")
|
||||||
(Right $ B.EffectInstr B.Br ["z"] [] ["a", "b"])
|
(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 :: Test
|
||||||
testProgramFromFiles = TestCase $ do
|
testProgramFromFiles = TestCase $ do
|
||||||
res <- try $ (B.parseBrilFromPath "bril-sources/add.json") :: IO (Either IOError (Either String B.Program))
|
res <- try $ (B.parseBrilFromPath "bril-sources/add.json") :: IO (Either IOError (Either String B.Program))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue