(self, tokens)
Returns the pysmt representation of the given parsed expression
Returns the pysmt representation of the given parsed expression
Returns the pysmt representation of the given parsed expression
def get_expression(self, tokens):
        """
        Returns the pysmt representation of the given parsed expression
        """
        mgr = self.env.formula_manager
        stack = []

        try:
            while True:
                tk = tokens.consume_maybe()

                if tk == "(":
                    while tk == "(":
                        stack.append([])
                        tk = tokens.consume()

                    if tk in self.interpreted:
                        fun = self.interpreted[tk]
                        fun(stack, tokens, tk)
                    else:
                        stack[-1].append(self.atom(tk, mgr))

                elif tk == ")":
                    try:
                        lst = stack.pop()
                        fun = lst.pop(0)
                    except IndexError:
                        raise PysmtSyntaxError("Unexpected ')'",
                                               tokens.pos_info)

                    try:
                        res = fun(*lst)
                    except TypeError as err:
                        if not callable(fun):
                            raise NotImplementedError("Unknown function '%s'" % fun)
                        raise err

                    if len(stack) > 0:
                        stack[-1].append(res)
                    else:
                        return res

                else:
                    try:
                        stack[-1].append(self.atom(tk, mgr))
                    except IndexError:
                        return self.atom(tk, mgr)
        except StopIteration:
            # No more data when trying to consume tokens
            return
def get_expression ( self , tokens ) : mgr = self . env . formula_manager stack = [ ] try : while True : tk = tokens . consume_maybe ( ) if tk == "(" : while tk == "(" : stack . append ( [ ] ) tk = tokens . consume ( ) if tk in self . interpreted : fun = self . interpreted [ tk ] fun ( stack , tokens , tk ) else : stack [ - 1 ] . append ( self . atom ( tk , mgr ) ) elif tk == ")" : try : lst = stack . pop ( ) fun = lst . pop ( 0 ) except IndexError : raise PysmtSyntaxError ( "Unexpected ')'" , tokens . pos_info ) try : res = fun ( * lst ) except TypeError as err : if not callable ( fun ) : raise NotImplementedError ( "Unknown function '%s'" % fun ) raise err if len ( stack ) > 0 : stack [ - 1 ] . append ( res ) else : return res else : try : stack [ - 1 ] . append ( self . atom ( tk , mgr ) ) except IndexError : return self . atom ( tk , mgr ) except StopIteration : # No more data when trying to consume tokens return