diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-25 21:19:28 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-25 21:19:28 -0600 |
commit | 64c8fd597f8259ff6e485fd7baf7ad6e1c30d7bb (patch) | |
tree | 791abd82a32103e4a3e7621fe799d188542bf65b | |
parent | 405a099a467788885ddbdfe3d63bf304e704f988 (diff) | |
download | yapymake-64c8fd597f8259ff6e485fd7baf7ad6e1c30d7bb.tar.gz yapymake-64c8fd597f8259ff6e485fd7baf7ad6e1c30d7bb.zip |
handle (most) escaped newlines in command string
-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 |