diff options
-rw-r--r-- | yapymake/makefile/__init__.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index e46179e..23cd144 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -145,10 +145,19 @@ class Makefile: else: prerequisite_tokens, command_tokens = semicolon_split prerequisites = self.expand_macros(prerequisite_tokens).split() + # TODO handle escaped newline in this case command_token_strings = [command_tokens] 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'))) + next_line = next(lines_iter) + # > When an escaped <newline> is found in a command line in a makefile, the command line shall + # > contain the <backslash>, the <newline>, and the next line, except that the first character of + # > the next line shall not be included if it is a <tab>. + while next_line.endswith('\\\n'): + line_after = next(lines_iter) + if line_after.startswith('\t'): + line_after = line_after[1:] + next_line += line_after + command_token_strings.append(tokenize(next_line.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 |