From 15ea142b25927d6f103ee6ddde4fe8a5e2324831 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Fri, 13 May 2022 22:40:50 +0900 Subject: Prohibit using escape sequences in string literals --- spec/lexer_test.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'spec/lexer_test.go') diff --git a/spec/lexer_test.go b/spec/lexer_test.go index 5f555ec..d822de2 100644 --- a/spec/lexer_test.go +++ b/spec/lexer_test.go @@ -70,10 +70,10 @@ func TestLexer_Run(t *testing.T) { }, }, { - caption: "the lexer can recognize character sequences and escape sequences in a string literal", - src: `'.*+?|()[\'\\'`, + caption: "backslashes are recognized as they are because escape sequences are not allowed in strings", + src: `'\\\'`, tokens: []*token{ - strTok(`.*+?|()['\`), + strTok(`\\\`), newEOFToken(), }, }, @@ -160,7 +160,7 @@ bar // This is the fourth comment. err: synErrUnclosedTerminal, }, { - caption: "an incompleted terminal in a pattern is not a valid token", + caption: "an incompleted escape sequence in a pattern is not a valid token", src: `"\`, err: synErrIncompletedEscSeq, }, @@ -169,11 +169,6 @@ bar // This is the fourth comment. src: `'abc`, err: synErrUnclosedString, }, - { - caption: "an incompleted terminal in a string is not a valid token", - src: `'\`, - err: synErrIncompletedEscSeq, - }, { caption: "the lexer can recognize valid tokens following an invalid token", src: `abc!!!def`, -- cgit v1.2.3