當前位置: 首頁>>代碼示例>>Python>>正文


Python symbol.expr方法代碼示例

本文整理匯總了Python中symbol.expr方法的典型用法代碼示例。如果您正苦於以下問題:Python symbol.expr方法的具體用法?Python symbol.expr怎麽用?Python symbol.expr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在symbol的用法示例。


在下文中一共展示了symbol.expr方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: decorator

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def decorator(self, nodelist):
        # '@' dotted_name [ '(' [arglist] ')' ]
        assert len(nodelist) in (3, 5, 6)
        assert nodelist[0][0] == token.AT
        assert nodelist[-1][0] == token.NEWLINE

        assert nodelist[1][0] == symbol.dotted_name
        funcname = self.decorator_name(nodelist[1][1:])

        if len(nodelist) > 3:
            assert nodelist[2][0] == token.LPAR
            expr = self.com_call_function(funcname, nodelist[3])
        else:
            expr = funcname

        return expr 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,代碼來源:transformer.py

示例2: parseexpr

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def parseexpr(self, text):
        """Return a modified parse tree for the given expression text."""
        return self.transform(parser.expr(text)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:transformer.py

示例3: yield_stmt

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def yield_stmt(self, nodelist):
        expr = self.com_node(nodelist[0])
        return Discard(expr, lineno=expr.lineno) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:transformer.py

示例4: exec_stmt

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def exec_stmt(self, nodelist):
        # exec_stmt: 'exec' expr ['in' expr [',' expr]]
        expr1 = self.com_node(nodelist[1])
        if len(nodelist) >= 4:
            expr2 = self.com_node(nodelist[3])
            if len(nodelist) >= 6:
                expr3 = self.com_node(nodelist[5])
            else:
                expr3 = None
        else:
            expr2 = expr3 = None

        return Exec(expr1, expr2, expr3, lineno=nodelist[0][2]) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:transformer.py

示例5: testlist

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def testlist(self, nodelist):
        # testlist: expr (',' expr)* [',']
        # testlist_safe: test [(',' test)+ [',']]
        # exprlist: expr (',' expr)* [',']
        return self.com_binary(Tuple, nodelist) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:transformer.py

示例6: expr

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def expr(self, nodelist):
        # xor_expr ('|' xor_expr)*
        return self.com_binary(Bitor, nodelist) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:transformer.py

示例7: com_try_except_finally

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def com_try_except_finally(self, nodelist):
        # ('try' ':' suite
        #  ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite]
        #   | 'finally' ':' suite))

        if nodelist[3][0] == token.NAME:
            # first clause is a finally clause: only try-finally
            return TryFinally(self.com_node(nodelist[2]),
                              self.com_node(nodelist[5]),
                              lineno=nodelist[0][2])

        #tryexcept:  [TryNode, [except_clauses], elseNode)]
        clauses = []
        elseNode = None
        finallyNode = None
        for i in range(3, len(nodelist), 3):
            node = nodelist[i]
            if node[0] == symbol.except_clause:
                # except_clause: 'except' [expr [(',' | 'as') expr]] */
                if len(node) > 2:
                    expr1 = self.com_node(node[2])
                    if len(node) > 4:
                        expr2 = self.com_assign(node[4], OP_ASSIGN)
                    else:
                        expr2 = None
                else:
                    expr1 = expr2 = None
                clauses.append((expr1, expr2, self.com_node(nodelist[i+2])))

            if node[0] == token.NAME:
                if node[1] == 'else':
                    elseNode = self.com_node(nodelist[i+2])
                elif node[1] == 'finally':
                    finallyNode = self.com_node(nodelist[i+2])
        try_except = TryExcept(self.com_node(nodelist[2]), clauses, elseNode,
                               lineno=nodelist[0][2])
        if finallyNode:
            return TryFinally(try_except, finallyNode, lineno=nodelist[0][2])
        else:
            return try_except 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:42,代碼來源:transformer.py

示例8: com_with_item

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def com_with_item(self, nodelist, body, lineno):
        # with_item: test ['as' expr]
        if len(nodelist) == 4:
            var = self.com_assign(nodelist[3], OP_ASSIGN)
        else:
            var = None
        expr = self.com_node(nodelist[1])
        return With(expr, var, body, lineno=lineno) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:transformer.py

示例9: com_list_comprehension

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def com_list_comprehension(self, expr, node):
        return self.com_comprehension(expr, None, node, 'list') 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:4,代碼來源:transformer.py

示例10: com_generator_expression

# 需要導入模塊: import symbol [as 別名]
# 或者: from symbol import expr [as 別名]
def com_generator_expression(self, expr, node):
        # comp_iter: comp_for | comp_if
        # comp_for: 'for' exprlist 'in' test [comp_iter]
        # comp_if: 'if' test [comp_iter]

        lineno = node[1][2]
        fors = []
        while node:
            t = node[1][1]
            if t == 'for':
                assignNode = self.com_assign(node[2], OP_ASSIGN)
                genNode = self.com_node(node[4])
                newfor = GenExprFor(assignNode, genNode, [],
                                    lineno=node[1][2])
                fors.append(newfor)
                if (len(node)) == 5:
                    node = None
                else:
                    node = self.com_comp_iter(node[5])
            elif t == 'if':
                test = self.com_node(node[2])
                newif = GenExprIf(test, lineno=node[1][2])
                newfor.ifs.append(newif)
                if len(node) == 3:
                    node = None
                else:
                    node = self.com_comp_iter(node[3])
            else:
                raise SyntaxError, \
                        ("unexpected generator expression element: %s %d"
                         % (node, lineno))
        fors[0].is_outmost = True
        return GenExpr(GenExprInner(expr, fors), lineno=lineno) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:35,代碼來源:transformer.py


注:本文中的symbol.expr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。