'Read a DNS master file and build a zone object.
@raises dns.zone.NoSOA: No SOA RR was found at the zone origin
@raises dns.zone.NoNS: No NS RRset was found at the zone origin'

def read(self):

    try:
        while 1:
            token = self.tok.get(True, True).unescape()
            if token.is_eof():
                if (not (self.current_file is None)):
                    self.current_file.close()
                if (len(self.saved_state) > 0):
                    (self.tok, self.current_origin, self.last_name, self.current_file, self.ttl) = self.saved_state.pop((-1))
                    continue
                break
            elif token.is_eol():
                continue
            elif token.is_comment():
                self.tok.get_eol()
                continue
            elif (token.value[0] == '$'):
                u = token.value.upper()
                if (u == '$TTL'):
                    token = self.tok.get()
                    if (not token.is_identifier()):
                        raise dns.exception.SyntaxError('bad    $TTL')
                    self.ttl = dns.ttl.from_text(token.value)
                    self.tok.get_eol()
                elif (u == '$ORIGIN'):
                    self.current_origin = self.tok.get_name()
                    self.tok.get_eol()
                    if (self.zone.origin is None):
                        self.zone.origin = self.current_origin
                elif ((u == '$INCLUDE') and self.allow_include):
                    token = self.tok.get()
                    filename = token.value
                    token = self.tok.get()
                    if token.is_identifier():
                        new_origin = dns.name.from_text(token.value, self.current_origin)
                        self.tok.get_eol()
                    elif (not token.is_eol_or_eof()):
                        raise dns.exception.SyntaxError('bad    origin    in    $INCLUDE')
                    else:
                        new_origin = self.current_origin
                    self.saved_state.append((self.tok, self.current_origin, self.last_name, self.current_file, self.ttl))
                    self.current_file = file(filename, 'r')
                    self.tok = dns.tokenizer.Tokenizer(self.current_file, filename)
                    self.current_origin = new_origin
                elif (u == '$GENERATE'):
                    self._generate_line()
                else:
                    raise dns.exception.SyntaxError((("Unknown    master    file    directive    '" + u) + "'"))
                continue
            self.tok.unget(token)
            self._rr_line()
    except dns.exception.SyntaxError as detail:
        (filename, line_number) = self.tok.where()
        if (detail is None):
            detail = 'syntax    error'
        raise dns.exception.SyntaxError(('%s:%d:    %s' % (filename, line_number, detail)))
    if self.check_origin:
        self.zone.check_origin()
