@@ -46,6 +46,7 @@ def run_pipeline(self, config_file, name, lines):
46
46
comment_str = r"/\*|\*/|//|" + linesep + r"|"
47
47
string_str = r"\\\\|\\\"|\"|"
48
48
char_str = r"\\'|'|"
49
+ digits_str = r"(?P<digits>\d+)|"
49
50
extern_str = r"(?P<ext_decl>extern \"C(\+\+)?\")\s+(?P<ext_brace>\{)?|"
50
51
braces_str = r"\{|\}|;|def\s+\w+|\w+\**\s+\w+\s*(?P<paren>\(\))"
51
52
postfix_str = r"(?=\s*(;|\{))"
@@ -54,6 +55,7 @@ def run_pipeline(self, config_file, name, lines):
54
55
+ comment_str
55
56
+ string_str
56
57
+ char_str
58
+ + digits_str
57
59
+ extern_str
58
60
+ braces_str
59
61
+ postfix_str
@@ -74,6 +76,7 @@ def run_pipeline(self, config_file, name, lines):
74
76
in_singlecomment = False
75
77
in_string = False
76
78
in_char = False
79
+ last_digit_end = - 1
77
80
for match in token_regex .finditer (lines ):
78
81
token = match .group ()
79
82
@@ -114,7 +117,7 @@ def run_pipeline(self, config_file, name, lines):
114
117
elif token == "\\ '" :
115
118
continue
116
119
elif token == "'" :
117
- if not in_string :
120
+ if not in_string and match . start () != last_digit_end :
118
121
in_char = not in_char
119
122
elif in_string or in_char :
120
123
# Tokens processed after this branch are ignored if they are in
@@ -165,6 +168,8 @@ def run_pipeline(self, config_file, name, lines):
165
168
# Replaces () with (void)
166
169
output += lines [pos : match .span ("paren" )[0 ]] + "(void)"
167
170
pos = match .span ("paren" )[0 ] + len ("()" )
171
+ elif match .group ("digits" ):
172
+ last_digit_end = match .end ()
168
173
169
174
# Write rest of file if it wasn't all processed
170
175
if pos < len (lines ):
0 commit comments