Skip to content

Commit

Permalink
Fix parsing of multiline string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
kmichaelk committed Sep 23, 2024
1 parent 8c7932e commit 4d94753
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
1 change: 0 additions & 1 deletion ttcn3/syntax/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ func (s *Scanner) scanString() Kind {
switch ch := s.src[s.pos]; ch {
case '\n', '\v', '\f':
s.lines = append(s.lines, s.pos+1)
s.pos++
case '\\':
s.pos++
case '"':
Expand Down
33 changes: 33 additions & 0 deletions ttcn3/syntax/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,39 @@ func TestTokenize(t *testing.T) {
`COMMENT "//"`,
`EOF`,
}},
{`"str"
`, []string{
`STRING "\"str\""`,
`EOF`,
}},
{`"multiline
str"
`, []string{
`STRING "\"multiline\nstr\""`,
`EOF`,
}},
{`"
multiline
str"
`, []string{
`STRING "\"\nmultiline\nstr\""`,
`EOF`,
}},
{`"multiline
str
"
`, []string{
`STRING "\"multiline\nstr\n\""`,
`EOF`,
}},
{`"
multiline
str
"
`, []string{
`STRING "\"\nmultiline\nstr\n\""`,
`EOF`,
}},
}
for _, test := range tests {
root := Tokenize([]byte(test.input))
Expand Down

0 comments on commit 4d94753

Please sign in to comment.