-- | Read a machine specification, both rules and input.
parseMachine :: String -> (TransMap, [String])
parseMachine stuff = (m,elems)
  where
    desc = lines stuff
    rules = take (length desc - 2) desc
    m = foldr (parseRule . words) ML.empty rules
    elems = envelop parseElem [] $ last desc

-- | Expansions of a given molecule starting at a given split point.
parseMachine :: String -> (TransMap, [String])
parseMachine stuff = (m,elems)
  where
    desc = lines stuff
    rules = take (length desc - 2) desc
    m = foldr (parseRule . words) ML.empty rules
    elems = envelop parseElem [] $ last desc

-- | Expansions of a given molecule starting at a given split point.
parseMachine stuff = (m,elems)
  where
    desc = lines stuff
    rules = take (length desc - 2) desc
    m = foldr (parseRule . words) ML.empty rules
    elems = envelop parseElem [] $ last desc

-- | Expansions of a given molecule starting at a given split point.