From a45f2a388efb649e0373a45c6db1d009dc18072d Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 2 Oct 2022 12:57:50 +0200 Subject: lexer: improve regex literal handling - Do not treat slashes within bracket expressions as delimitters - Do not escape slashes when stringifying regex sources - Allow all escape sequence types in regex literals Signed-off-by: Jo-Philipp Wich --- tests/custom/00_syntax/21_regex_literals | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tests/custom/00_syntax/21_regex_literals') diff --git a/tests/custom/00_syntax/21_regex_literals b/tests/custom/00_syntax/21_regex_literals index d7ba7c4..7466a2e 100644 --- a/tests/custom/00_syntax/21_regex_literals +++ b/tests/custom/00_syntax/21_regex_literals @@ -4,7 +4,7 @@ within regular expression literals is subject of the underlying regular expression engine. -- Expect stdout -- -[ "/Hello world/", "/test/gis", "/test/g", "/test1 \\\/ test2/", "/\\x31\n\\.\u0007\b\\c\\u2600\\\\/" ] +[ "/Hello world/", "/test/gis", "/test/g", "/test1 / test2/", "/1\n\\.\u0007\bc☀\\\\/" ] -- End -- -- Testcase -- @@ -93,3 +93,27 @@ In line 7, byte 30: } %} -- End -- + + +Testing that slashes within character classes are not treated as regex +literal delimitters. + +-- Expect stdout -- +[ + "/[/]/", + "/[[./.]/]/", + "/[[:alpha:]/]/", + "/[[=/=]/]/" +] +-- End -- + +-- Testcase -- +{% + printf("%.J\n", [ + /[/]/, + /[[./.]/]/, + /[[:alpha:]/]/, + /[[=/=]/]/ + ]); +%} +-- End -- -- cgit v1.2.3