Merge branch 'pr-1803'

This commit is contained in:
Juan Martín Sotuyo Dodero
2019-04-30 10:40:33 -03:00
5 changed files with 12 additions and 2 deletions

View File

@ -20,5 +20,7 @@ This is a {{ site.pmd.release_type }} release.
### External Contributions
* [#1803](https://github.com/pmd/pmd/pull/1803): \[dart] \[cpd] Dart escape sequences - [Maikel Steneker](https://github.com/maikelsteneker)
{% endtocmaker %}

View File

@ -344,8 +344,8 @@ booleanLiteral
stringLiteral: SingleLineString;
//stringLiteral: SingleLineString;
SingleLineString
: '"' (~["] | '\\"')* '"'
| '\'' (~['] | '\\\'')* '\''
: '"' (~[\\"] | '\\\\' | ESCAPE_SEQUENCE | '\\"')* '"'
| '\'' (~[\\'] | '\\\\' | ESCAPE_SEQUENCE | '\\\'')* '\''
// | 'r\'' (~('\'' | NEWLINE))* '\'' // TODO
// | 'r"' (~('\'' | NEWLINE))* '"'
;
@ -369,6 +369,7 @@ ESCAPE_SEQUENCE
| '\\x' HEX_DIGIT HEX_DIGIT
| '\\u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
| '\\u{' HEX_DIGIT_SEQUENCE '}'
| '\\$'
;
fragment
HEX_DIGIT_SEQUENCE

View File

@ -31,6 +31,8 @@ public class DartTokenizerTest extends AbstractTokenizerTest {
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[] { "comment.dart", 5 },
new Object[] { "escape_sequences.dart", 13 },
new Object[] { "escaped_backslash.dart", 14 },
new Object[] { "escaped_string.dart", 17 },
new Object[] { "increment.dart", 185 },
new Object[] { "imports.dart", 1 }

View File

@ -0,0 +1,3 @@
var newline = '\n';
var dollar = '$';
var escaped_dollar = "\$";

View File

@ -0,0 +1,2 @@
var separator = '\\';
var separators = const ['/', '\\'];