+ (newdict,next) = convertDTF xs (nstate newdtf) (ndatacnt newdtf) (ninstrcnt newdtf) (ndict newdtf)
+
+ ndatacnt (DTF_Org adr)
+ | state == InData = adr
+ | otherwise = datacnt
+ ndatacnt (DTF_Data _ _ _ _ _) = inc datacnt
+
+ ninstrcnt (DTF_Org adr)
+ | state == InText = adr
+ | otherwise = instrcnt
+ ninstrcnt (DTF_Instr _ _ _ _ _) = inc instrcnt
+
+ nstate (DTF_State s) = s
+ nstate _ = state
+
+ ndict (DTF_Label l _ a) = dict `add_label` (l,a)
+ ndict (DTF_SectionToDet a _ _ l _) = dict `add_label` (l,a)
+ ndict (DTF_InstrToParse a _ _ l _) = dict `add_label` (l,a)
+ ndict (DTF_Data a _ _ l _) = dict `add_label` (l,a)
+ ndict (DTF_Instr a _ _ l _) = dict `add_label` (l,a)
+
+ newdtf = case (parse parseDTFLine "" (str++"\n")) of
+ Left err -> error "couldn't parse line " ++ (show lno) ++ ": " ++ (show err)
+ Right (DTF_SectionToDet _ v c l s) ->
+ case state of
+ NoState -> error "missing .data or .text"
+ InData -> (DTF_Data datacnt v c l s)
+ InText -> (DTF_Instr instrcnt v c l s)
+ Right (DTF_InstrToParse _ v c l s) ->
+ (DTF_InstrToParse instrcnt v c l s)
+ Right y@(DTF_Org _) ->
+ case state of
+ NoState -> error "missing .data or .text"
+ _ -> y
+ Right (DTF_Label l c _) ->
+ case state of
+ NoState -> error "missing .data or .text"
+ InData -> (DTF_Label l c datacnt)
+ InText -> (DTF_Label l c instrcnt)
+ Right z -> z -- DTF_Comment, DTF_State
+
+