Skip to content

Commit

Permalink
Fix parsing of multiline string literals (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmichaelk authored Sep 25, 2024
1 parent 8c7932e commit cdf964f
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 cdf964f

Please sign in to comment.