diff --git a/fast64_internal/sm64/sm64_level_writer.py b/fast64_internal/sm64/sm64_level_writer.py index 5263e62a1..d1016b84f 100644 --- a/fast64_internal/sm64/sm64_level_writer.py +++ b/fast64_internal/sm64/sm64_level_writer.py @@ -498,24 +498,22 @@ def replaceScriptLoads(levelscript, obj): STRING_TO_MACROS_PATTERN = re.compile( r""" - .*? - (?P\w+) - \s* - \((?P - [^()]* + .*? # match as few chars as possible before macro name + (?P\w+) #group macro name matches 1+ word chars + \s* # allows any number of spaces after macro name + \((?P # group is inside first parenthesis + [^()]* # anything but () (?: # Non-capturing group for 1 depth parentheses - \( - .*? - \) + \(.*?\) # captures parenthesis+any chars inside [^()]* - )* + )* # allows any number of inner parenthesis () )\) - (\s*,\s*|\s*) - (?P - //.*$ + (\s*?,)?[^\n]*? # capture a comma, including white space trailing except for new lines following the comma + (?P # comment group + ([^\n]*?|\s*?\\\s*?\n)//.*$ # two // and any number of chars and str or line end | - /\*.*\*/ - )? + ([^\n]*?|\s*?\\\s*?\n)/\*[\s\S]*?\*/ # a /*, any number of chars (including new line) and a */ + )? # 0 or 1 repetition of comments """, re.VERBOSE | re.MULTILINE, )