Fix label and Op show
This commit is contained in:
parent
08049e9955
commit
27f24389ae
36
lib/Bril.hs
36
lib/Bril.hs
|
|
@ -120,24 +120,24 @@ instrFromString s
|
|||
|
||||
instance Show InstrOperation where
|
||||
show op = case op of
|
||||
Nop -> "add"
|
||||
Add -> "sub"
|
||||
Sub -> "mul"
|
||||
Mul -> "eq"
|
||||
Eq -> "lt"
|
||||
Lt -> "gt"
|
||||
Gt -> "le"
|
||||
Le -> "ge"
|
||||
Ge -> "not"
|
||||
Not -> "and"
|
||||
And -> "or"
|
||||
Or -> "jmp"
|
||||
Jmp -> "br"
|
||||
Br -> "ret"
|
||||
Ret -> "call"
|
||||
Call -> "print"
|
||||
Print -> "id"
|
||||
Id -> "nop"
|
||||
Add -> "add"
|
||||
Sub -> "sub"
|
||||
Mul -> "mul"
|
||||
Eq -> "eq"
|
||||
Lt -> "lt"
|
||||
Gt -> "gt"
|
||||
Le -> "le"
|
||||
Ge -> "ge"
|
||||
Not -> "not"
|
||||
And -> "and"
|
||||
Or -> "or"
|
||||
Jmp -> "jmp"
|
||||
Br -> "br"
|
||||
Ret -> "ret"
|
||||
Call -> "call"
|
||||
Print -> "print"
|
||||
Id -> "id"
|
||||
Nop -> "nop"
|
||||
|
||||
|
||||
optionalArrayField :: FromJSON a => Data.Aeson.Object -> Data.Aeson.Key -> Parser [a]
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@ testInstrs = TestCase $ do
|
|||
(eitherDecode "{\"op\": \"id\", \"dest\": \"a\", \"type\": \"bool\", \"args\": [\"b\"]}")
|
||||
(Right $ B.ValueInstr B.Id B.Bool "a" ["b"] [] [])
|
||||
|
||||
assertEqual "parse label"
|
||||
(eitherDecode "{\"label\": \"test\"}")
|
||||
(Right $ B.Label "test")
|
||||
|
||||
testProgramFromFiles :: Test
|
||||
testProgramFromFiles = TestCase $ do
|
||||
res <- try $ (B.parseBrilFromPath "bril-sources/add.json") :: IO (Either IOError (Either String B.Program))
|
||||
|
|
|
|||
Loading…
Reference in New Issue