Skip to content

Commit cc657b1

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 c07b1be commit cc657b1

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
@@ -415,6 +415,20 @@ var lexFixtures = []lexFixture{
415415
{"}", 20},
416416
{"}", 21},
417417
}},
418+
{"comments-between-args", []tokenLine{
419+
{"http", 1},
420+
{"{", 1},
421+
{"#comment 1", 1},
422+
{"log_format", 2},
423+
{"#comment 2", 2},
424+
{"\\#arg\\ 1", 3},
425+
{"#comment 3", 3},
426+
{"#arg 2", 4},
427+
{"#comment 4", 4},
428+
{"#comment 5", 5},
429+
{";", 6},
430+
{"}", 7},
431+
}},
418432
}
419433

420434
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)