Python symbol.expr() Examples
The following are 30
code examples of symbol.expr().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
symbol
, or try the search function
.
Example #1
Source File: transformer.py From medicare-demo with Apache License 2.0 | 6 votes |
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
Example #2
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: transformer.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
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
Example #4
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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
Example #5
Source File: transformer.py From oss-ftp with MIT License | 6 votes |
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
Example #6
Source File: transformer.py From BinderFilter with MIT License | 6 votes |
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
Example #7
Source File: transformer.py From PokemonGo-DesktopMap with MIT License | 6 votes |
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
Example #8
Source File: transformer.py From ironpython2 with Apache License 2.0 | 6 votes |
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
Example #9
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def yield_stmt(self, nodelist): expr = self.com_node(nodelist[0]) return Discard(expr, lineno=expr.lineno)
Example #10
Source File: transformer.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def parseexpr(self, text): """Return a modified parse tree for the given expression text.""" return self.transform(parser.expr(text))
Example #11
Source File: transformer.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def com_list_comprehension(self, expr, node): return self.com_comprehension(expr, None, node, 'list')
Example #12
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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])
Example #13
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testlist(self, nodelist): # testlist: expr (',' expr)* [','] # testlist_safe: test [(',' test)+ [',']] # exprlist: expr (',' expr)* [','] return self.com_binary(Tuple, nodelist)
Example #14
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def expr(self, nodelist): # xor_expr ('|' xor_expr)* return self.com_binary(Bitor, nodelist)
Example #15
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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 [',' 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
Example #16
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def com_with(self, nodelist): # with_stmt: 'with' expr [with_var] ':' suite expr = self.com_node(nodelist[1]) body = self.com_node(nodelist[-1]) if nodelist[2][0] == token.COLON: var = None else: var = self.com_assign(nodelist[2][2], OP_ASSIGN) return With(expr, var, body, lineno=nodelist[0][2])
Example #17
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def com_with(self, nodelist): # with_stmt: 'with' expr [with_var] ':' suite expr = self.com_node(nodelist[1]) body = self.com_node(nodelist[-1]) if nodelist[2][0] == token.COLON: var = None else: var = self.com_assign(nodelist[2][2], OP_ASSIGN) return With(expr, var, body, lineno=nodelist[0][2])
Example #18
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def com_list_comprehension(self, expr, node): # list_iter: list_for | list_if # list_for: 'for' exprlist 'in' testlist [list_iter] # list_if: 'if' test [list_iter] # XXX should raise SyntaxError for assignment lineno = node[1][2] fors = [] while node: t = node[1][1] if t == 'for': assignNode = self.com_assign(node[2], OP_ASSIGN) listNode = self.com_node(node[4]) newfor = ListCompFor(assignNode, listNode, []) newfor.lineno = node[1][2] fors.append(newfor) if len(node) == 5: node = None else: node = self.com_list_iter(node[5]) elif t == 'if': test = self.com_node(node[2]) newif = ListCompIf(test, lineno=node[1][2]) newfor.ifs.append(newif) if len(node) == 3: node = None else: node = self.com_list_iter(node[3]) else: raise SyntaxError, \ ("unexpected list comprehension element: %s %d" % (node, lineno)) return ListComp(expr, fors, lineno=lineno)
Example #19
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def com_with_var(self, nodelist): # with_var: 'as' expr return self.com_node(nodelist[1])
Example #20
Source File: transformer.py From ironpython2 with Apache License 2.0 | 5 votes |
def parseexpr(self, text): """Return a modified parse tree for the given expression text.""" return self.transform(parser.expr(text))
Example #21
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def parseexpr(self, text): """Return a modified parse tree for the given expression text.""" return self.transform(parser.expr(text))
Example #22
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
def com_list_comprehension(self, expr, node): # list_iter: list_for | list_if # list_for: 'for' exprlist 'in' testlist [list_iter] # list_if: 'if' test [list_iter] # XXX should raise SyntaxError for assignment lineno = node[1][2] fors = [] while node: t = node[1][1] if t == 'for': assignNode = self.com_assign(node[2], OP_ASSIGN) listNode = self.com_node(node[4]) newfor = ListCompFor(assignNode, listNode, []) newfor.lineno = node[1][2] fors.append(newfor) if len(node) == 5: node = None else: node = self.com_list_iter(node[5]) elif t == 'if': test = self.com_node(node[2]) newif = ListCompIf(test, lineno=node[1][2]) newfor.ifs.append(newif) if len(node) == 3: node = None else: node = self.com_list_iter(node[3]) else: raise SyntaxError, \ ("unexpected list comprehension element: %s %d" % (node, lineno)) return ListComp(expr, fors, lineno=lineno)
Example #23
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
def com_with_var(self, nodelist): # with_var: 'as' expr return self.com_node(nodelist[1])
Example #24
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
def com_with(self, nodelist): # with_stmt: 'with' expr [with_var] ':' suite expr = self.com_node(nodelist[1]) body = self.com_node(nodelist[-1]) if nodelist[2][0] == token.COLON: var = None else: var = self.com_assign(nodelist[2][2], OP_ASSIGN) return With(expr, var, body, lineno=nodelist[0][2])
Example #25
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
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 [',' 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
Example #26
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
def expr(self, nodelist): # xor_expr ('|' xor_expr)* return self.com_binary(Bitor, nodelist)
Example #27
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
def testlist(self, nodelist): # testlist: expr (',' expr)* [','] # testlist_safe: test [(',' test)+ [',']] # exprlist: expr (',' expr)* [','] return self.com_binary(Tuple, nodelist)
Example #28
Source File: transformer.py From PokemonGo-DesktopMap with MIT License | 5 votes |
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)
Example #29
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
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])
Example #30
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def com_with_var(self, nodelist): # with_var: 'as' expr return self.com_node(nodelist[1])