Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now replacing comments with harmless dummy comments before processing… #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ circle:
circle

empty:
# head
# head $(ignored_expansion)

one:
@make two
Expand Down
4 changes: 4 additions & 0 deletions pymake/_pymake.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
RE_MAKE_CMD = re.compile(r'^\t(@\+?)(make)?')
RE_MACRO_DEF = re.compile(r"^(\S+)\s*\:?\=\s*(.*?)$")
RE_MACRO = re.compile(r"\$\(\s*\S+\s*\)")
RE_COMMENT = re.compile("#.*$")


class PymakeTypeError(TypeError):
Expand Down Expand Up @@ -43,6 +44,9 @@ def parse_makefile_aliases(filepath):
ini_lines = (RE_MAKE_CMD.sub('\t', i) for i in ini_lines.split('\n'))
# fake section to resemble valid *.ini
ini_lines = ['[root]'] + list(ini_lines)
# replace comments with dummy contents so as to remove all reserved exprs
ini_lines = [RE_COMMENT.sub("# removed comment", line)
for line in ini_lines]

# Substitute macros
macros = dict(found for l in ini_lines
Expand Down