Skip to content

Commit ae94bcf

Browse files
Mark R. Tuttlemarkrtuttle
authored andcommitted
Simplify symbol table parsing to work for both C and Rust
This commit has the effect of doubling the number of C symbols since the list now includes fully-qualified symbols like function::1::x that denotes local variable x in scope 1 of function. But this doesn't change the html generated by viewer for C code. Proposing this pull request in favor of #42
1 parent 997735f commit ae94bcf

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

cbmc_viewer/symbol_table.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ def parse_symbol(sym):
6161
# Symbol......: tag-struct_name
6262
# Symbol......: tag-union_name
6363

64-
name = sym.strip().split()[-1]
65-
match = re.match('^(tag-)?([a-zA-Z0-9_]+)$', name)
66-
if match:
67-
return match.group(2)
64+
name = sym.split(":", 1)[1].strip()
65+
if name.startswith('tag-'):
66+
return name[len('tag-'):]
67+
if name:
68+
return name
6869
return None
6970

7071
def parse_location(loc, wkdir):
@@ -101,8 +102,12 @@ def parse_pretty_name(sym):
101102
# Pretty name.: struct struct_name
102103
# Pretty name.: union union_name
103104

104-
name = sym.strip().split()[-1]
105-
if re.match('^[a-zA-Z0-9_]+$', name):
105+
name = sym.split(":", 1)[1].strip()
106+
if name.startswith('struct '):
107+
return name[len('struct '):]
108+
if name.startswith('union '):
109+
return name[len('union '):]
110+
if name:
106111
return name
107112
return None
108113

0 commit comments

Comments
 (0)