Skip to content

Commit

Permalink
lexer: Unbreak support for dot-terminated multiline strings
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp committed Jan 28, 2024
1 parent 94763f4 commit 361efc3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lexer/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ func multilineString(r *bufio.Reader, state *lexerState) (string, error) {
atLFHadDot = true
} else {
data.WriteByte('.')
atLFHadDot = false
}

atLF = false
Expand All @@ -381,6 +382,7 @@ func multilineString(r *bufio.Reader, state *lexerState) (string, error) {
default:
atLF = false
atLFHadDot = false
data.WriteByte(b)
}
}
}
34 changes: 34 additions & 0 deletions lexer/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,38 @@ whatever # aaaa
Number{Value: 123, Quantifier: Kilo, Position: LineCol(7, 20)},
BlockEnd{Position: LineCol(7, 25)},
})
testLexer(t, `set "message" text:
From: [email protected]
To: [email protected]
Subject: Frop!
Frop!
.
`, []Token{
Identifier{Text: "set", Position: LineCol(1, 1)},
String{Text: "message", Position: LineCol(1, 5)},
String{Text: "From: [email protected]\r\n" +
"To: [email protected]\r\n" +
"Subject: Frop!\r\n" +
"\r\n" +
"Frop!\r\n", Position: LineCol(1, 15)},
})
testLexer(t, `set "message" text:
From: [email protected]
To: [email protected]
Subject: Frop!
..
Frop!
.
`, []Token{
Identifier{Text: "set", Position: LineCol(1, 1)},
String{Text: "message", Position: LineCol(1, 5)},
String{Text: "From: [email protected]\r\n" +
"To: [email protected]\r\n" +
"Subject: Frop!\r\n" +
"\r\n" +
".\r\n" +
"Frop!\r\n", Position: LineCol(1, 15)},
})
}

0 comments on commit 361efc3

Please sign in to comment.