--- /dev/null
+module DTFormat where
+
+import Data.Word
+import Text.Printf
+
+type Address = Word32
+type Value = Word32
+type ValueToParse = String
+type Code = String
+type Label = String
+type Comment = String
+
+data DTF =
+ DTF_Data Address Value Code Label Comment |
+ DTF_Instr Address Value Code Label Comment |
+ DTF_Comment Comment |
+ DTF_Label Label |
+ DTF_ToParse Address ValueToParse Code Label Comment
+
+instance Show (DTF) where
+ showsPrec n = showsDTF
+
+showsDTF :: DTF -> ShowS
+showsDTF (DTF_Data a v c l s) = (++) (datins "0" a v c l s)
+showsDTF (DTF_Instr a v c l s) = (++) (datins "1" a v c l s)
+showsDTF (DTF_Comment c) = (++) (printf "2;%s\n" c)
+showsDTF (DTF_Label l) = (++) (printf "3;%s\n" l)
+showsDTF (DTF_ToParse a v c l s) = (++) (printf "lulz\n")
+
+
+datins :: String -> Address -> Value -> Code -> Label -> Comment -> String
+datins = printf "%s;%08x;%08x;%s;%s;%s\n"
+
module Main where
import DT
+import DTFormat
import Control.Applicative hiding ((<|>),many)
import Text.Printf
import Text.Parsec
import Text.Parsec.String
+import Text.Parsec.Combinator
import qualified Data.Map as M
import Data.List
import qualified Data.ByteString.Lazy as BL
main :: IO ()
main = do
args <- getArgs
- src <- getContents
+ content <- getContents
+ let src = convertDTF (filter ((/=) "") $ lines content)
print args
+ print src
+
+{-
case runParser DT.parseInstructions () "stdin" src of
Left err -> print err
Right val -> do
- -- TODO: nicht nur das erste element :/
sequence_ [printf "0x%08X\n" x | x <- val]
- -- mapM (printf "0x%08X\n") val
+-}
+
+-- data instr
+-- convertDTF :: [String] -> Dict -> Dict -> ([DTF],Labels)
+
+convertDTF :: [String] -> [DTF]
+convertDTF [] = []
+convertDTF (str:xs) = (DTF_Comment str):(convertDTF xs)