'Comments can be anywhere. So break apart the Dockerfile into significant
lines and any comments that precede them. And if a line is a carryover
from the previous via an escaped-newline, bring the directive with it.'

def preparse_iter(self):

    to_yield = {}
    last_directive = None
    lines_processed = 0
    for line in self.lines_iter():
        if (not line):
            continue
        if line.startswith(u'#'):
            comment = line.lstrip('#').strip()
            if (lines_processed == 1):
                if comment.startswith(u'escape='):
                    self.escape_char = comment.split(u'=', 1)[1]
                    continue
            to_yield.setdefault('comments', []).append(comment)
        else:
            if last_directive:
                (directive, payload) = (last_directive, line)
            else:
                (directive, payload) = line.split(u'    ', 1)
            if line.endswith(self.escape_char):
                payload = payload.rstrip(self.escape_char)
                last_directive = directive
            else:
                last_directive = None
            to_yield['directive'] = directive
            to_yield['payload'] = payload.strip()
            (yield to_yield)
            to_yield = {}
