Skip to content

Commit 5a23f3d

Browse files
committed
Fixes issue parsing comments in args with quote
Fixed bug where the quoted token did not have `IsQuoted` set to `true`. I added an additional lex fixture which shows both the existing lexer and new scanner handle the case correctly.
1 parent f08b872 commit 5a23f3d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lex_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ var lexFixtures = []lexFixture{
226226
{";", 15},
227227
{"}", 16},
228228
}},
229+
{"comments-between-args", []tokenLine{
230+
{"http", 1},
231+
{"{", 1},
232+
{"#comment 1", 1},
233+
{"log_format", 2},
234+
{"#comment 2", 2},
235+
{"\\#arg\\ 1", 3},
236+
{"#comment 3", 3},
237+
{"#arg 2", 4},
238+
{"#comment 4", 4},
239+
{"#comment 5", 5},
240+
{";", 6},
241+
{"}", 7},
242+
}},
229243
}
230244

231245
func TestLex(t *testing.T) {

scanner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (s *Scanner) Scan() (Token, error) { //nolint: funlen, gocognit, gocyclo
241241
lexState = inWord
242242
case inQuote:
243243
if r == quote {
244-
return Token{Text: tok.String(), Line: s.tokenStartLine}, nil
244+
return Token{Text: tok.String(), Line: s.tokenStartLine, IsQuoted: true}, nil
245245
}
246246
if r == "\\"+quote {
247247
r = quote

0 commit comments

Comments
 (0)