示例#1
0
    def parse_decl(self, callid, mode, tac, kind, loc):
        # Internal
        h_head = self.h_head
        self._mylog("@parse_decl:before<{}>".format(h_head.peek_line()))

        # Parse declaration
        if h_head.peek_line().startswith("ngs=0"):
            # Parse *solved* goal state
            # Parse rest of header
            h_head.consume_line()  # ngs=0
            h_head.consume_line()  # en(ts)

            # Unpack
            hdr = TacStHdr(callid, mode, tac, kind, FullTac(""), GID_SOLVED, 0,
                           loc)
            ctx = TacStCtx([])
            kern_idx = -1
            mid_idx = -1
        elif TOK_SEP in h_head.peek_line():
            # Parse *live* or *dead* goal state
            # Parse rest of header
            hdr = h_head.consume_line()
            toks = hdr.split(TOK_SEP)
            while len(toks) < 3:
                line = h_head.consume_line()
                hdr += line
                toks = hdr.split(TOK_SEP)
            ngs = int(toks[0].strip())
            pp_tac = toks[1].strip()
            ast_ftac = toks[2].strip()
            if ast_ftac:
                # Literal ' in identifier messes up sexpression parsing. Sigh*
                ast_ftac = ast_ftac.replace('\'', '!@#')
                try:
                    sexp_ftac = sexpdata.loads(ast_ftac,
                                               true="true",
                                               false="false")
                    fvs = FvsTactic()
                    tac_lids = fvs.fvs_tac(sexp_ftac)
                    tac_gids = fvs.globs
                    ftac = FullTac(pp_tac, sexp_ftac, tac_lids, tac_gids)
                except:
                    print(ast_ftac)
                    raise NameError("Sexpr parsing failed in {}".format(
                        self.filename))
            else:
                ftac = FullTac(pp_tac)
            gid = int(toks[3].strip())

            # Unpack (note that we handle error and success here)
            hdr = TacStHdr(callid, mode, tac, kind, ftac, gid, ngs, loc)
            ctx, kern_idx, mid_idx = self.parse_decl_body()
        else:
            raise NameError("Parsing error @line{}: {}".format(
                h_head.line, h_head.peek_line()))
        return TacStDecl(hdr, ctx, kern_idx, mid_idx)
示例#2
0
    def parse_constr(self):
        # Internal
        it = self.it
        self._mylog("@parse_constr:before<{}>".format(it.peek()))

        constrs = []
        while it.has_next() and it.peek().hdr.kind.startswith("Constr("):
            decl = next(it)
            # Constr(stuff), the literal ' throws us off
            str_gc = decl.hdr.kind[7:-1].replace('\'', '!@#')
            sexp_gc = sexpdata.loads(str_gc)
            constrs += [sexp_gc]
        return constrs
示例#3
0
    def parse_constr_inc(self):
        # Internal
        h_head = self.h_head
        self._mylog("ignore_constr_inc<{}>".format(h_head.peek_line()))

        h_head.consume_line()
        while not h_head.peek_line().startswith("Constrs"):
            k, s_gc = self._parse_table_entry()
            s_gc = s_gc.replace('\'', '!@#')
            sexp_gc = sexpdata.loads(s_gc, true="true", false="false")
            self.mid_share[int(k)] = sexp_gc

        h_head.consume_line()
        while not h_head.peek_line().startswith(TOK_END_INC):
            k, v = self._parse_table_entry()
            self.constr_share[int(k)] = v
        h_head.consume_line()