Skip to content

Commit fcbae1c

Browse files
Fix Docker line continuation with CRLF line endings (#7309)
LINE_CONTINUATION only consumed one newline character, so with \r\n endings it consumed \r and left \n as a standalone NEWLINE token that reset internal lexer state. Change both LINE_CONTINUATION and HP_LINE_CONTINUATION to explicitly match the optional \r before \n.
1 parent 9ed831d commit fcbae1c

4 files changed

Lines changed: 448 additions & 429 deletions

File tree

rewrite-docker/src/main/antlr/DockerLexer.g4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ HEREDOC_START : '<<' '-'? [A-Z_][A-Z0-9_]* {
7575

7676
// Line continuation - HIDDEN in main mode
7777
// Supports both backslash (Linux) and backtick (Windows with # escape=`)
78-
LINE_CONTINUATION : ('\\' | '`') [ \t]* NEWLINE_CHAR -> channel(HIDDEN);
78+
LINE_CONTINUATION : ('\\' | '`') [ \t]* '\r'? '\n' -> channel(HIDDEN);
7979

8080
// JSON array delimiters (for exec form) - no mode switching, handled in parser
8181
LBRACKET : '[' { atLineStart = false; };
@@ -178,7 +178,7 @@ fragment NEWLINE_CHAR : [\r\n];
178178
mode HEREDOC_PREAMBLE;
179179

180180
// Line continuation in preamble - stay in HEREDOC_PREAMBLE mode
181-
HP_LINE_CONTINUATION : ('\\' | '`') [ \t]* '\n' -> channel(HIDDEN);
181+
HP_LINE_CONTINUATION : ('\\' | '`') [ \t]* '\r'? '\n' -> channel(HIDDEN);
182182

183183
// Newline without continuation - transition to HEREDOC mode for body content
184184
HP_NEWLINE : '\n' -> type(NEWLINE), mode(HEREDOC);

0 commit comments

Comments
 (0)