-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from lgrandco/master
Fix #70
- Loading branch information
Showing
5 changed files
with
25 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# ############################################################################ # | ||
# **************************************************************************** # | ||
# # | ||
# ::: :::::::: # | ||
# hoist.py :+: :+: :+: # | ||
# +:+ +:+ +:+ # | ||
# By: cacharle <[email protected]> +#+ +:+ +#+ # | ||
# By: leo <[email protected]> +#+ +:+ +#+ # | ||
# +#+#+#+#+#+ +#+ # | ||
# Created: 2020/10/04 11:16:28 by cacharle #+# #+# # | ||
# Updated: 2021/02/11 20:13:29 by charles ### ########.fr # | ||
# Updated: 2023/09/22 16:16:01 by leo ### ########.fr # | ||
# # | ||
# ############################################################################ # | ||
# **************************************************************************** # | ||
|
||
import re | ||
|
||
|
@@ -59,7 +59,11 @@ def hoist(content: str) -> str: | |
# If line is a declaration + assignment on the same line, | ||
# create 2 new lines, one for the declaration and one for the assignment | ||
# NOTE: edge case for array declarations which can't be hoisted (See #56) | ||
if m is not None and re.match(r".*\[.*\].*", m.group("name")) is None: | ||
if ( | ||
m is not None | ||
and re.match(r".*\[.*\].*", m.group("name")) is None | ||
and re.match(r"\s*(const|static)\s.*", line) is None | ||
): | ||
lines.append(f"\t{m.group('type')}\t{m.group('name')};") | ||
lines.append( | ||
"{}{} = {};".format( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters