Changeset 958
- Timestamp:
- Jun 21, 2012 1:24:24 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
specdomain/src/specdomain/test/parser.py
r957 r958 13 13 Construct a SPEC macro source code file parser for 14 14 use 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. 15 18 """ 16 19 … … 83 86 ''' 84 87 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 92 94 ) 93 95 … … 126 128 line_number += 1 127 129 if state == 'command level': 128 # test if local, global, or constant variable declaration 130 129 131 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('#') 133 135 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] 137 137 m['objtype'] = objtype 138 138 m['start_line'] = m['end_line'] = line_number 139 139 del m['start'], m['end'], m['line'] 140 140 if objtype == 'constant': 141 var, value = vars.split()141 var, _ = args.split() 142 142 m['text'] = var 143 143 self.findings.append(dict(m)) 144 144 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(): 146 148 m['text'] = var 147 149 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) 149 151 continue 150 152
Note: See TracChangeset
for help on using the changeset viewer.