File: Processor.py

package info (click to toggle)
synopsis 0.8.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 10,112 kB
  • ctags: 12,996
  • sloc: cpp: 34,254; ansic: 33,620; python: 10,975; sh: 7,261; xml: 6,369; makefile: 773; asm: 445
file content (43 lines) | stat: -rw-r--r-- 1,188 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# Copyright (C) 2005 Stefan Seefeld
# All rights reserved.
# Licensed to the public under the terms of the GNU LGPL (>= 2),
# see the file COPYING for details.
#

import Synopsis.Processor
from Synopsis import AST

class Processor(Synopsis.Processor.Processor, AST.Visitor):
    """Base class for comment processors.

    This is an AST visitor, and by default all declarations call process()
    with the current declaration. Subclasses may override just the process
    method.
    """
    def process(self, ast, **kwds):
      
        self.set_parameters(kwds)
        self.ast = self.merge_input(ast)

        for decl in ast.declarations():
            decl.accept(self)

        self.finalize()
        return self.output_and_return_ast()

    def process_comments(self, decl):
        """Process comments for the given declaration."""
        pass

    def finalize(self):
        """Do any finalization steps that may be necessary."""
        pass

    def visitDeclaration(self, decl):
        self.process_comments(decl)

    def visitBuiltin(self, decl):
        if decl.type() == 'EOS': # treat it if it is an 'end of scope' marker
            self.process_comments(decl)