diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-25 19:28:07 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-25 19:28:07 -0600 |
commit | b83e916ec888b38b15a242c673c89da39b52a8e7 (patch) | |
tree | 7620b5c0d8c5ab497230dbe48f5f971021469ba4 /yapymake/makefile/__init__.py | |
parent | fa31fa96b8088e5157cbb9022f3e77664cf7e5d8 (diff) | |
download | yapymake-b83e916ec888b38b15a242c673c89da39b52a8e7.tar.gz yapymake-b83e916ec888b38b15a242c673c89da39b52a8e7.zip |
handle iterator end more gracefully in peek
Diffstat (limited to 'yapymake/makefile/__init__.py')
-rw-r--r-- | yapymake/makefile/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index ddd049d..a5cb19d 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -130,8 +130,9 @@ class Makefile: prerequisite_tokens, command_tokens = semicolon_split prerequisites = self.expand_macros(prerequisite_tokens).split() command_token_strings = [command_tokens] - while lines_iter.peek().startswith('\t'): - command_token_strings.append(tokenize(next(lines_iter).lstrip('\t'))) + while (peeked := lines_iter.peek()) is not None and peeked.startswith('\t'): + # TODO handle escaped newlines + command_token_strings.append(tokenize(next(lines_iter).lstrip('\t').rstrip('\n'))) commands = [CommandLine(c) for c in command_token_strings] # we don't know yet if it's a target rule or an inference rule |