(self, stack, tokens, key)
Deals with annotations
Deals with annotations
Deals with annotations
def _enter_annotation(self, stack, tokens, key):
        """Deals with annotations"""
        #pylint: disable=unused-argument

        term = self.get_expression(tokens)

        tk = tokens.consume()
        while tk != ")":
            if not tk.startswith(":"):
                raise PysmtSyntaxError("Annotations keyword should start with"
                                       " colon! Offending token: '%s'" % tk,
                                       tokens.pos_info)
            keyword = tk[1:]
            tk = tokens.consume()
            value = None
            if tk == "(":
                counter = 1
                buff = [tk]
                while counter != 0:
                    tk = tokens.raw_read()
                    if tk == "(":
                        counter += 1
                    elif tk == ")":
                        counter -= 1
                    buff.append(tk)
                value = "".join(buff)
            else:
                value = tk
            tk = tokens.consume()
            self.cache.annotations.add(term, keyword, value)

        assert len(stack[-1]) == 0
        # re-add the ")" to the tokenizer because we consumed it, but
        # get_expression needs it
        tokens.add_extra_token(")")
        stack[-1].append(lambda : term)
def _enter_annotation ( self , stack , tokens , key ) : #pylint: disable=unused-argument term = self . get_expression ( tokens ) tk = tokens . consume ( ) while tk != ")" : if not tk . startswith ( ":" ) : raise PysmtSyntaxError ( "Annotations keyword should start with" " colon! Offending token: '%s'" % tk , tokens . pos_info ) keyword = tk [ 1 : ] tk = tokens . consume ( ) value = None if tk == "(" : counter = 1 buff = [ tk ] while counter != 0 : tk = tokens . raw_read ( ) if tk == "(" : counter += 1 elif tk == ")" : counter -= 1 buff . append ( tk ) value = "" . join ( buff ) else : value = tk tk = tokens . consume ( ) self . cache . annotations . add ( term , keyword , value ) assert len ( stack [ - 1 ] ) == 0 # re-add the ")" to the tokenizer because we consumed it, but # get_expression needs it tokens . add_extra_token ( ")" ) stack [ - 1 ] . append ( lambda : term )