module Data.Avc.Encode (toString) where
import qualified Data.ByteString.Char8 as BS
import Data.Monoid ((<>))
import Data.Avc.Type
toString :: Statement -> BS.ByteString
toString (Repeat rep devcyc vec comment) =
BS.unwords["R" <> BS.pack (show rep)
, devcyc
, vec
, ";"
, commentToString comment]
toString (Format sigs comment) =
BS.unwords $ ["FORMAT"] ++ map sigToString sigs ++ [";", commentToString comment]
toString (EOF) = ""
sigToString :: Signal -> BS.ByteString
sigToString (Sig name) = name
sigToString (SigGroup name) = name
commentToString :: Comment -> BS.ByteString
commentToString (Comment c) = c
commentToString CNil = ""