diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java index 23c7fa48bf1646a7e7f5bb910b889dff911c1282..a6a6e6655cf77887ec7526520e3d16b917e592c8 100644 --- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java +++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java @@ -101,5 +101,6 @@ public class ParserGeneration { ":: and ::: do not set argument names", "refactored: use file for interactive single-line source", "create lookups for field accesses where appropriate", + "allow unicode escape literals with {...}", }; } diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g index 61e8a5979459880f5870305cacd415521c1f05a9..3a1d809d79729a74d9104b75de081ed13a2399cc 100644 --- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g +++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g @@ -789,6 +789,8 @@ fragment ESCAPE [StringBuilder buf] | 'x' a = HEX_DIGIT b = HEX_DIGIT { buf.append(hexChar($a.text, $b.text)); } | 'u' a = HEX_DIGIT b = HEX_DIGIT? c = HEX_DIGIT? d = HEX_DIGIT? { buf.append(hexChar($a.text, $b.text, $c.text, $d.text)); } | 'U' a = HEX_DIGIT b = HEX_DIGIT? c = HEX_DIGIT? d = HEX_DIGIT? e = HEX_DIGIT? f = HEX_DIGIT? g = HEX_DIGIT? h = HEX_DIGIT? { buf.append(hexChar($a.text, $b.text, $c.text, $d.text, $e.text, $f.text, $g.text, $h.text)); } + | 'u' '{' a = HEX_DIGIT b = HEX_DIGIT? c = HEX_DIGIT? d = HEX_DIGIT? '}' { buf.append(hexChar($a.text, $b.text, $c.text, $d.text)); } + | 'U' '{' a = HEX_DIGIT b = HEX_DIGIT? c = HEX_DIGIT? d = HEX_DIGIT? '}' { buf.append(hexChar($a.text, $b.text, $c.text, $d.text)); } ) ; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 4a61db00c5abe5a412be53699051d7d8ba0886b9..1729d773c0d972a5734c30d7c20ec423fa81ddfd 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -171254,6 +171254,14 @@ see '?methods' for accessing help and source code "","double","bool","raw" "1",1231231234.5,TRUE,2a +##com.oracle.truffle.r.test.parser.TestParser.testBraceUnicodeLiterals# +#"\u{23}\u{9}\u{723}\u{1234}\U{23}\U{9}\U{723}\U{1234}" +[1] "#\tܣሴ#\tܣሴ" + +##com.oracle.truffle.r.test.parser.TestParser.testBraceUnicodeLiterals# +#'\u{23}\u{9}\u{723}\u{1234}\U{23}\U{9}\U{723}\U{1234}' +[1] "#\tܣሴ#\tܣሴ" + ##com.oracle.truffle.r.test.parser.TestParser.testDotIdentifiers# #{ .. <- 42; cat(..); } 42 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java index 524a536573ef01a382a04cfdaf7dc8113d0472a7..e02819ca63aa3437b6f97bed908e6a58f661b2b1 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java @@ -61,6 +61,12 @@ public class TestParser extends TestBase { assertEval("0xa.bp1i"); } + @Test + public void testBraceUnicodeLiterals() { + assertEval("\"\\u{23}\\u{9}\\u{723}\\u{1234}\\U{23}\\U{9}\\U{723}\\U{1234}\""); + assertEval("'\\u{23}\\u{9}\\u{723}\\u{1234}\\U{23}\\U{9}\\U{723}\\U{1234}'"); + } + private static final String[] HEX_VALUES = new String[]{"0xFFF", "0xFFFFFFFFFFF"}; @Test