@@ -32,7 +32,7 @@ def run_pipeline(self, config_file, name, lines):
32
32
# "def\\s+\w+" matches preprocessor directives "#ifdef" and "#ifndef" so
33
33
# their contents aren't used as a return type.
34
34
extern_str = "(?P<ext_decl>extern \" C(\+\+)?\" )\s+(?P<ext_brace>\{)?|"
35
- braces_str = "\{|\}|def\s+\w+|\w+\s+\w+\s*(?P<paren>\(\))"
35
+ braces_str = "\{|\}|;| def\s+\w+|\w+\s+\w+\s*(?P<paren>\(\))"
36
36
postfix_str = "(?=\s*(;|\{))"
37
37
token_regex = re .compile (extern_str + braces_str + postfix_str )
38
38
@@ -54,6 +54,12 @@ def run_pipeline(self, config_file, name, lines):
54
54
elif token == "}" :
55
55
is_c = extern_brace_indices .pop ()
56
56
57
+ # If the next stack frame is from an extern without braces, pop
58
+ # it.
59
+ if extern_brace_indices [- 1 ] >= EXTRA_POP_OFFSET :
60
+ is_c = extern_brace_indices [- 1 ] - EXTRA_POP_OFFSET
61
+ extern_brace_indices .pop ()
62
+ elif token == ";" :
57
63
# If the next stack frame is from an extern without braces, pop
58
64
# it.
59
65
if extern_brace_indices [- 1 ] >= EXTRA_POP_OFFSET :
@@ -66,7 +72,7 @@ def run_pipeline(self, config_file, name, lines):
66
72
else :
67
73
# Handling an extern without braces changing the language
68
74
# type is done by treating it as a pseudo-brace that gets
69
- # popped as well when the next "}" is encountered.
75
+ # popped as well when the next "}" or ";" is encountered.
70
76
# The "extra pop" offset is used as a flag on the top stack
71
77
# value that is checked whenever a pop is performed.
72
78
extern_brace_indices .append (is_c + EXTRA_POP_OFFSET )
0 commit comments