Last change
on this file since 993 was
993,
checked in by jemian, 10 years ago
|
refs #8, find function macros first, improve function macro detection
|
File size:
2.0 KB
|
Line | |
---|
1 | ''' |
---|
2 | Created on Jul 6, 2012 |
---|
3 | |
---|
4 | @author: Pete |
---|
5 | |
---|
6 | Correct the parser's match to macro function declarations |
---|
7 | ''' |
---|
8 | |
---|
9 | import re |
---|
10 | |
---|
11 | |
---|
12 | barrage = ''' |
---|
13 | def uascanFindFactor(start center finish numPts exponent minStep) '{ |
---|
14 | def _usaxs_triangulate (rot,center,dist) '{ |
---|
15 | def uascanStepFunc(x, factor, center, exponent, minStep) '{ |
---|
16 | ''' |
---|
17 | |
---|
18 | spec_function_declaration_match_re = re.compile( |
---|
19 | r'^' # line start |
---|
20 | + r'\s*?' # optional blank space |
---|
21 | + r'(r?def)' # 0: def_type (rdef | def) |
---|
22 | + r'\s*?' # optional blank space |
---|
23 | + r'([a-zA-Z_][\w_]*)' # 1: function_name |
---|
24 | + r'\s*?' # optional blank space |
---|
25 | + r'\(' # opening parenthesis |
---|
26 | + r'(.*?)' # 2: args (anything between the parentheses) |
---|
27 | + r'\)' # closing parenthesis |
---|
28 | + r'\s*?' # optional blank space |
---|
29 | + r'\'' # open macro content |
---|
30 | + r'(.*?)' # 3: content, optional |
---|
31 | + r'(#.*?)?' # 4: optional comment |
---|
32 | + r'$' # line end |
---|
33 | ) |
---|
34 | |
---|
35 | if __name__ == '__main__': |
---|
36 | for line in barrage.split('\n'): |
---|
37 | m = spec_function_declaration_match_re.match(line) |
---|
38 | if m is not None: |
---|
39 | print m.groups() |
---|
Note: See
TracBrowser
for help on using the repository browser.