Test.hs 942 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. module Main where
  2. import Gidl.Types
  3. import Gidl.Parse
  4. main :: IO ()
  5. main = test "tests/testtypes.sexpr"
  6. test :: FilePath -> IO ()
  7. test f = do
  8. c <- readFile f
  9. print $ parseDecls c
  10. --- below is just a stash
  11. hb_t :: Type
  12. hb_t = StructType $ Struct
  13. [ ("mode", "mode_t")
  14. , ("time", "time_micros_t")
  15. ]
  16. mode_t :: Type
  17. mode_t = StructType $ Struct
  18. [ ("armed", "bool_t")
  19. , ("controlsource", "controlsource_t" )
  20. ]
  21. controlsource_t :: Type
  22. controlsource_t = EnumType $ EnumT Bits8
  23. [ ("manual", 0)
  24. , ("auto", 1)
  25. ]
  26. time_micros_t :: Type
  27. time_micros_t = NewtypeType $ Newtype "uint8_t"
  28. typeEnv' :: TypeEnv
  29. typeEnv' = TypeEnv
  30. [ ("hb_t", hb_t)
  31. , ("mode_t", mode_t)
  32. , ("controlsource_t", controlsource_t)
  33. , ("time_micros_t", time_micros_t)
  34. ]
  35. data Sys = Sys TypeEnv Streams Attrs
  36. data Attrs = Attrs [(String, Either Type Attrs)]
  37. data Streams = Streams [(String, Type)]