当前位置: 首页>>代码示例>>Python>>正文


Python visitor.ASTVisitor类代码示例

本文整理汇总了Python中compiler.visitor.ASTVisitor的典型用法代码示例。如果您正苦于以下问题:Python ASTVisitor类的具体用法?Python ASTVisitor怎么用?Python ASTVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ASTVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, stream=sys.stdout, parent=None, debug=False):
        
        self.parent = parent

        self.v = lambda tree, visitor=self: walk(tree, visitor)
        self.stream = stream
        self.strcode = ""
        self.debug = debug
        self.indents = 0

        self.ids = {}
        self.ids['global'] = ['abs', 'str', 'ord', 'True', 'False', 'robot', 
                                'pygame', 'list', 'range', 'RoboException', 
                                'None', 'int', 'float', 'zip', 'arange', 
                                'sin', 'array', 'resize', 'pi']
        self.ids['__fn__'] = []
        self.ids[''] = []

        self.fn_types = {}
        self.fn_type_regex = re.compile(":param \((.*?)\)")

        self.var_types = {}
        self.var_types['global'] = {}

        self.fn = ""
        ASTVisitor.__init__(self)
开发者ID:manuken,项目名称:nxtIDE,代码行数:26,代码来源:pycheck.py

示例2: __init__

 def __init__(self, stream=sys.stdout, debug=False):
     self.v = lambda tree, visitor=self: walk(tree, visitor)
     self.stream = stream
     self.strcode = ""
     self.debug = debug
     self.indents = 0
     ASTVisitor.__init__(self)
开发者ID:Adman,项目名称:pynxc,代码行数:7,代码来源:ast_template.py

示例3: __init__

 def __init__(self, stream=None):
     if stream is None:
         self.stream = sys.stdout
     else:
         self.stream = stream
     self.indents = 0
     self.v = lambda tree, visitor=self: walk(tree, visitor)
     ASTVisitor.__init__(self)
开发者ID:mickg10,项目名称:DARLAB,代码行数:8,代码来源:pyunparse.py

示例4: __init__

    def __init__(self, ast, stats=None, description=None):
        ASTVisitor.__init__(self)
        if isinstance(ast, basestring):
            ast = compiler.parse(ast)

        self.stats = stats or Stats(description or '<module>')
        for child in ast.getChildNodes():
            compiler.walk(child, self, walker=self)
开发者ID:bartosh,项目名称:pygenie,代码行数:8,代码来源:cc.py

示例5: __init__

 def __init__(self, stream=None, comments={}):
     if stream is None:
         self.stream = sys.stdout
     else:
         self.stream = stream
     self.indents = 0
     self.comments = comments
     #self.v = lambda tree, visitor=self: walk(tree, visitor)
     self.v = self._visit
     ASTVisitor.__init__(self)
开发者ID:ryanlowe0,项目名称:misc-python,代码行数:10,代码来源:myvisitor.py

示例6: __init__

	def __init__( self, ast, stats=None, title=None ):
		ASTVisitor.__init__(self)
		
		if isinstance( ast, basestring ):
			ast = compiler.parse( ast )
		
		self.stats = stats or Stats( title or '<unnamed>' )
		
		for child in ast.getChildNodes():
			compiler.walk( child, self, walker=self )
开发者ID:SATToSE,项目名称:SoTeSoLa2012,代码行数:10,代码来源:cc.py

示例7: __init__

 def __init__(self, code, stats=None, description=None):
     ASTVisitor.__init__(self)
     ast = compiler.parse(code)
     self.node_types = set()
     self.visit_node(ast.node)
     #for child in ast.getChildNodes():
         #compiler.walk(child, self, walker=self)
     all_types = set(line.strip()
                     for line
                     in file('python_ast_node_types.txt').readlines())
     self.untouched_nodes = sorted(all_types - self.node_types)
开发者ID:AndreaCrotti,项目名称:pycomplexity,代码行数:11,代码来源:count_nodes.py

示例8: __init__

 def __init__(self, stream=None):
     if stream is None:
         self.stream = sys.stdout
     else:
         self.stream = stream
     self.indents = 0
     # self.v = lambda tree, visitor=self: print tree.lineno; walk(tree, visitor)
     ASTVisitor.__init__(self)
     self.line_map = {}
     self.line = 1
     self.to_write = ""
开发者ID:lebauce,项目名称:artub,代码行数:11,代码来源:pyunparse.py

示例9: __init__

    def __init__(self, package, types, docformat):
        """Create an ASGTranslator.

        package: enclosing package the generated modules are to be part of."""

        ASTVisitor.__init__(self)
        self.scope = package and [package] or []
        self.file = None
        self.types = types
        self.attributes = []
        self.any_type = ASG.BuiltinTypeId('Python',QName('',))
        self.docformat = docformat
        self.documentable = None
        self.name = QName()
        self.imports = []
开发者ID:stefanseefeld,项目名称:synopsis,代码行数:15,代码来源:ASGTranslator.py

示例10: __init__

    def __init__(self, stream=sys.stdout, parent=None, debug=False):

        self.parent = parent

        self.v = lambda tree, visitor=self: walk(tree, visitor)
        self.stream = stream
        self.strcode = ""
        self.debug = debug
        self.indents = 0

        self.ids = {}
        self.ids["global"] = [
            "abs",
            "str",
            "ord",
            "True",
            "False",
            "robot",
            "pygame",
            "list",
            "range",
            "RoboException",
            "None",
            "int",
            "float",
            "zip",
            "arange",
            "sin",
            "array",
            "resize",
            "pi",
            "RoboThread",
            "__clock__",
        ]
        self.ids["__fn__"] = []
        self.ids[""] = []

        self.fn_types = {}
        self.fn_type_regex = re.compile(":param \((.*?)\)")

        self.var_types = {}
        self.var_types["global"] = {}

        self.fn = ""
        ASTVisitor.__init__(self)
开发者ID:jasonbogovich,项目名称:nxtIDE,代码行数:45,代码来源:pycheck.py

示例11: __init__

    def __init__(self, stream=sys.stdout, parent=None, debug=False):
        
        self.parent = parent

        self.v = lambda tree, visitor=self: walk(tree, visitor)
        self.stream = stream
        self.strcode = ""
        self.debug=debug
        self.indents = 0

        self.ids = {}
        self.ids['global'] = ['abs', 'str', 'ord', 'True', 'False', 'robot', 
                                'pygame', 'list', 'range', 'RoboException', 
                                'None']
        self.ids['__fn__'] = []
        self.ids[''] = []

        self.fn = ""
        ASTVisitor.__init__(self)
开发者ID:Xirus666,项目名称:nxtIDE,代码行数:19,代码来源:pycheck.py

示例12: __init__

	def __init__(self, modulename, outstream):
		ASTVisitor.__init__(self)
		self.module = modulename.split('.')[-1]
		self.out = outstream
		self.opdict = {	'<' : '__lt__', '<=':'__le__', '==':'__eq__', 
					'!=':'__ne__', '>':'__gt__', '>=':'__ge__', 
					'is':'is_', 'is not':'is_not', 'in':'__contains__',
					'+=':'__add__', '&=':'__and__', '/=':'__div__', '//=':'__floordiv__',
					'<<=':'__lshift__', '%=':'__mod__', '*=':'__mul__',
					'|=':'__or__','**=':'__pow__', '>>=':'__rshift__','-=':'__sub__',
					'^=':'__xor__'}
		self.funcVargs = 4
		self.funcKargs = 8
		self.freeVarName = "lambda" #Python keyword so won't be in use
		self.freeVar = 1 #Free var index
		self.freeUsedVars = []
		self.classes = [] #classes defined in this module
		self.functions = [] #functions defined in this module
		self.vars = [] #top level vars in this module
		self.modules = [] #imported modules
		self.imports = {} #imported functions/modules
		self.deps = []
		self.toplevel = True
开发者ID:fredvdd,项目名称:Swan,代码行数:23,代码来源:visitor.py

示例13: __init__

 def __init__(self, node):
     ASTVisitor.__init__(self)
     self.score = 1
     self._in_conditional = False
     self.results = ComplexityResults()
     self.process_root_node(node)
开发者ID:aroscoe,项目名称:emacs-starter-kit,代码行数:6,代码来源:complexity.py

示例14: default_visit

 def default_visit(self, node, *args):
     ASTVisitor.default(self, node, *args)
开发者ID:stefanseefeld,项目名称:synopsis,代码行数:2,代码来源:ASGTranslator.py

示例15: __init__

 def __init__(self):
     # no super, ASTVisitor is old style class
     ASTVisitor.__init__(self)
     self.functions = []
     self.exports = []
开发者ID:chinnurtb,项目名称:py2erl,代码行数:5,代码来源:visitors.py


注:本文中的compiler.visitor.ASTVisitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。