source: specdomain/trunk/src/specdomain/test/tester3.py @ 978

Last change on this file since 978 was 978, checked in by jemian, 10 years ago
File size: 745 bytes
RevLine 
[920]1'''
2Created on Jun 12, 2012
3
4@author: Pete
5'''
6
7
8import re
9
10# http://www.greenend.org.uk/rjk/tech/regexp.html
11
12spec_func_sig_re = re.compile(
13    r'''^ ([a-zA-Z_]\w*)         # macro name
14          ((\s+\S+)*)            # optional: arguments
15          $                      # and nothing more
16          ''', re.VERBOSE)
17
18test_group = """
19example_runtime_defined_macro content
20test_macro2 arg1   1.0 2     3
21simple_macro
22_do_this    4    5    7
235testmacro
24"""
25
26for phrase in test_group.split("\n"):
27    print "testing:", phrase, "\t --> ",
28    m = spec_func_sig_re.match(phrase)
29    if m is None:
30        print "no match"
31    else:
32        name, args, last = m.groups()
33        print name, args.strip().split()
Note: See TracBrowser for help on using the repository browser.