Changeset 993


Ignore:
Timestamp:
Jul 6, 2012 12:18:02 PM (11 years ago)
Author:
jemian
Message:

refs #8, find function macros first, improve function macro detection

Location:
specdomain/trunk/src/specdomain
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • specdomain/trunk/src/specdomain/sphinxcontrib/specmacrofileparser.py

    r992 r993  
    113113
    114114            if self.state == 'global':
    115                 for thing in (self._is_def_macro,
     115                for thing in (
     116                              self._is_function_macro,
     117                              self._is_def_macro,
    116118                              self._is_cdef_macro,
    117                               self._is_function_macro,
    118119                              self._is_lgc_variable,
    119120                              self._is_one_line_extended_comment,
     
    168169                print "line_number, args: ", line_number, args
    169170            var, _ = args.split()
    170             m['text'] = var.rstrip(',')
     171            m['name'] = var.rstrip(',')
    171172            self.findings.append(dict(m))
    172173        else:
     
    175176            #      or leave these decisions for later, including some kind of analyzer
    176177            for var in args.split():
    177                 m['text'] = var.rstrip(',')
     178                m['name'] = var.rstrip(',')
    178179                self.findings.append(dict(m))
    179180                # TODO: to what is this local?  (remember the def it belongs to)
     
    307308                            + r'\s*?'                   # optional blank space
    308309                            + r'([a-zA-Z_][\w_]*)'      # 1: function_name
     310                            + r'\s*?'                   # optional blank space
    309311                            + r'\('                     # opening parenthesis
    310312                            + r'(.*?)'                  # 2: args (anything between the parentheses)
     
    418420                s.append( '.. spec:%s:: %s(%s)' % ( r['objtype'], r['name'], r['args']) )
    419421            elif r['objtype'] in ('local', 'global', 'constant'):
     422                del r['text']
    420423                declarations.append(r)
    421424
    422         s += _report_table('Variable Declarations', declarations)
    423         s += _report_table('Macro Declarations', macros, ('start_line', 'name', 'line',))
    424         s += _report_table('Function Macro Declarations', functions)
     425        s += report_table('Variable Declarations', declarations, ('start_line', 'objtype', 'name', 'line',))
     426        s += report_table('Macro Declarations', macros, ('start_line', 'name', 'line',))
     427        s += report_table('Function Macro Declarations', functions)
     428        #s += report_table('Findings from .mac File', self.findings, ('start_line', 'objtype', 'line',))
    425429
    426430        return '\n'.join(s)
    427431
    428432
    429 def _report_table(self, title, itemlist, col_keys = ('start_line', 'line',)):
     433def report_table(title, itemlist, col_keys = ('start_line', 'line',)):
    430434    """
    431435    return the itemlist as a reST table
     
    444448            rows.append( tuple([str(d[key]).strip() for key in col_keys]) )
    445449        last_line = d['start_line']
    446     return _make_table(title, col_keys, rows, '=')
    447 
    448 
    449 def _make_table( title, labels, rows, titlechar = '='):
     450    return make_table(title, col_keys, rows, '=')
     451
     452
     453def make_table(title, labels, rows, titlechar = '='):
    450454    """
    451455    build a reST table (internal routine)
Note: See TracChangeset for help on using the changeset viewer.