Changeset 958


Ignore:
Timestamp:
Jun 21, 2012 1:24:24 AM (11 years ago)
Author:
jemian
Message:

minor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • specdomain/src/specdomain/test/parser.py

    r957 r958  
    1313Construct a SPEC macro source code file parser for
    1414use by the specdomain for Sphinx.
     15
     16:copyright: Copyright 2012 by BCDA, Advanced Photon Source, Argonne National Laboratory
     17:license: ANL Open Source License, see LICENSE for details.
    1518"""
    1619
     
    8386    '''
    8487
    85     states = (
    86         'command level',
    87         'extended comment',
    88         'def macro',
    89         'rdef macro',
    90         'cdef macro'
    91              
     88    states = (                  # assume SPEC def macros cannot be nested
     89        'global',               # the level that provides the SPEC command prompt
     90        'extended comment',     # inside a multiline extended comment
     91        'def macro',            # inside a multiline def macro definition
     92        'rdef macro',           # inside a multiline rdef macro definition
     93        'cdef macro',           # inside a multiline cdef macro definition
    9294    )
    9395
     
    126128            line_number += 1
    127129            if state == 'command level':
    128                 # test if local, global, or constant variable declaration
     130
    129131                m = self._match(lgc_variable_sig_re, line)
    130                 if m is not None:
    131                     objtype, vars = lgc_variable_sig_re.match(line).groups()
    132                     pos = vars.find('#')
     132                if m is not None:           # local, global, or constant variable declaration
     133                    objtype, args = lgc_variable_sig_re.match(line).groups()
     134                    pos = args.find('#')
    133135                    if pos > -1:
    134                         vars = vars[:pos]
    135                     if line_number > 220:
    136                         pass        # TODO: test for multiple definitions on one line
     136                        args = args[:pos]
    137137                    m['objtype'] = objtype
    138138                    m['start_line'] = m['end_line'] = line_number
    139139                    del m['start'], m['end'], m['line']
    140140                    if objtype == 'constant':
    141                         var, value = vars.split()
     141                        var, _ = args.split()
    142142                        m['text'] = var
    143143                        self.findings.append(dict(m))
    144144                    else:
    145                         for var in vars.split():
     145                        # TODO: consider not indexing "global" inside a def
     146                        # TODO: consider not indexing "local" at global level
     147                        for var in args.split():
    146148                            m['text'] = var
    147149                            self.findings.append(dict(m))
    148                             # TODO: to what is this local?
     150                            # TODO: to what is this local?  (remember the def it belongs to)
    149151                    continue
    150152
Note: See TracChangeset for help on using the changeset viewer.