Skip to content

Commit

Permalink
Merge pull request #62 from slothy-optimizer/macros
Browse files Browse the repository at this point in the history
Allow spaces instead of commas in macro definitions and invocations
  • Loading branch information
hanno-becker committed Jul 8, 2024
2 parents 5385c76 + 12aa032 commit c6930b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/__pycache__
venv/
4 changes: 2 additions & 2 deletions slothy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def unfold_in(self, source, change_callback=None, inherit_comments=False):
for arg in self.args:
arg_regexps.append(rf"\s*(?P<{arg}>[^,]+)\s*")

macro_regexp_txt += ','.join(arg_regexps)
macro_regexp_txt += '(,|\s)'.join(arg_regexps)
macro_regexp = re.compile(macro_regexp_txt)

output = []
Expand Down Expand Up @@ -875,7 +875,7 @@ def extract(source):
if cur.tags.get("no-unfold", None) is not None:
continue

current_args = [ a.strip() for a in p.group("args").split(',') ]
current_args = [ a.strip() for a in re.split(r'\s|\,', p.group("args")) if a.strip() != ""]
current_macro = p.group("name")
current_body = []

Expand Down

0 comments on commit c6930b8

Please sign in to comment.