this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue/scanner: expand checkError to scan past interpolations too

So that we can add test cases with interpolations inside multiline
strings in the next commit.

We adjust two existing test cases so that they don't open
an interpolation without closing it correctly.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ic0d65cabe155b247715e5453392e53656df89184
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1235171
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>

+16 -2
+16 -2
cue/scanner/scanner_test.go
··· 647 647 } 648 648 s.Init(token.NewFile("", -1, len(src)), []byte(src), eh, ScanComments|DontInsertCommas) 649 649 _, tok0, lit0 := s.Scan() 650 + // Scan the full input so that errors produced during string 651 + // continuation after interpolation are collected too. 652 + count := 0 653 + for scanTok := tok0; scanTok != token.EOF; { 654 + _, scanTok, _ = s.Scan() 655 + switch scanTok { 656 + case token.LPAREN: 657 + count++ 658 + case token.RPAREN: 659 + if count--; count == 0 { 660 + s.ResumeInterpolation() 661 + } 662 + } 663 + } 650 664 if tok0 != tok { 651 665 t.Errorf("%q: got %s, expected %s", src, tok0, tok) 652 666 } ··· 746 760 {"#'", token.STRING, 0, "#'", "string literal not terminated"}, 747 761 {"''", token.STRING, 0, "''", ""}, 748 762 {"'", token.STRING, 0, "'", "string literal not terminated"}, 749 - {`"\("`, token.INTERPOLATION, 0, `"\(`, ""}, 763 + {`"\(0)"`, token.INTERPOLATION, 0, `"\(`, ""}, 750 764 {`#"\("#`, token.STRING, 0, `#"\("#`, ""}, 751 - {`#"\#("#`, token.INTERPOLATION, 0, `#"\#(`, ""}, 765 + {`#"\#(0)"#`, token.INTERPOLATION, 0, `#"\#(`, ""}, 752 766 {`"\q"`, token.STRING, 2, `"\q"`, "unknown escape sequence"}, 753 767 {`#"\q"#`, token.STRING, 0, `#"\q"#`, ""}, 754 768 {`#"\#q"#`, token.STRING, 4, `#"\#q"#`, "unknown escape sequence"},