mirror of https://gerrit.osmocom.org/libosmocore
contrib/fsm-to-dot: don't match on event names in comments
Strip comments from function bodies before matching on event names. In osmo-bsc's gscon FSM, there often are event names in comments. The naive parsing of fsm-to-dot.py mistakes these as events causing state transitions, but the comments are just explaining how states interact. Makes me reconsider parsing the C with clang instead, but I got away with a dirty hack once more. Change-Id: I56d70ae14d363f7ca655dced16d93d795b3f940d
This commit is contained in:
parent
46145e80ec
commit
bb22df3db9
|
@ -566,6 +566,8 @@ re_func = re.compile(r'(\b[a-z_][a-z_0-9]*\b)\([^)]*\)\W*^{', re.MULTILINE)
|
|||
re_state_trigger = re.compile(r'osmo_fsm_inst_state_chg\([^,]+,\W*([A-Z_][A-Z_0-9]*)\W*,', re.M)
|
||||
re_fsm_alloc = re.compile(r'osmo_fsm_inst_alloc[_child]*\(\W*&([a-z_][a-z_0-9]*),', re.M)
|
||||
re_fsm_event_dispatch = re.compile(r'osmo_fsm_inst_dispatch\(\W*[^,]+,\W*([A-Z_][A-Z_0-9]*)\W*,', re.M)
|
||||
re_comment_multiline = re.compile(r'/\*.*?\*/', re.M | re.S)
|
||||
re_comment_single_line = re.compile(r'//.*$', re.M | re.S)
|
||||
|
||||
class CFile():
|
||||
def __init__(c_file, path):
|
||||
|
@ -625,6 +627,8 @@ class CFile():
|
|||
for m in re_func.finditer(c_file.src):
|
||||
name = m.group(1)
|
||||
func_src = c_file.extract_block('{', '}', m.start())
|
||||
func_src = ''.join(re_comment_multiline.split(func_src))
|
||||
func_src = ''.join(re_comment_single_line.split(func_src))
|
||||
funcs[name] = func_src
|
||||
c_file.funcs = funcs
|
||||
c_file.find_fsm_allocators()
|
||||
|
|
Loading…
Reference in New Issue