Skip to content

Commit

Permalink
Merge pull request #1749 from guwirth/fix-1748
Browse files Browse the repository at this point in the history
fix raw string parsing
  • Loading branch information
guwirth authored Aug 18, 2019
2 parents 7016e3e + d1f847b commit f4f66ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ private boolean readRawString(CodeReader code) {
index++;
}
String delimiter = sb.toString();
sb.setLength(0);
do {
index -= sb.length();
sb.setLength(0);
while ((charAt = code.charAt(index)) != ')') { // raw_character*
if (charAt == EOF) {
Expand Down
10 changes: 9 additions & 1 deletion cxx-squid/src/test/java/org/sonar/cxx/lexer/CxxLexerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,15 @@ public void rawstring_literals() {
.tokenValue("R\"X*X(A C++11 raw string literal can be specified like this: R\"(This is my raw string)\" )X*X\"")
.tokenType(CxxTokenType.STRING).build(), // raw string: complex example
LiteralValuesBuilder.builder("R\"([.^$|()\\[\\]{}*+?\\\\])\"").tokenValue("R\"([.^$|()\\[\\]{}*+?\\\\])\"")
.tokenType(CxxTokenType.STRING).build() // raw string: regex sample
.tokenType(CxxTokenType.STRING).build(), // raw string: regex sample

// fix #1748
LiteralValuesBuilder.builder("R\"(([A-Z\\d]))\"").tokenValue("R\"(([A-Z\\d]))\"")
.tokenType(CxxTokenType.STRING).build(),
LiteralValuesBuilder.builder("R\"regex(([A-Z\\d]))regex\"").tokenValue("R\"regex(([A-Z\\d]))regex\"")
.tokenType(CxxTokenType.STRING).build(),
LiteralValuesBuilder.builder("R\"(())\"").tokenValue("R\"(())\"")
.tokenType(CxxTokenType.STRING).build()
));

values.forEach(value
Expand Down

0 comments on commit f4f66ce

Please sign in to comment.