From b2451d19c815ef4bb071fc891668fb13136d4546 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 17 Sep 2024 20:39:35 +0800 Subject: [PATCH] chore: update escaping rules --- parser/tests/escaping_character_test.go | 8 +++++++- parser/tokenizer/tokenizer.go | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/parser/tests/escaping_character_test.go b/parser/tests/escaping_character_test.go index 24b31a7..80f2abd 100644 --- a/parser/tests/escaping_character_test.go +++ b/parser/tests/escaping_character_test.go @@ -15,11 +15,17 @@ func TestEscapingCharacterParser(t *testing.T) { node ast.Node }{ { - text: `\# 123`, + text: `\#`, node: &ast.EscapingCharacter{ Symbol: "#", }, }, + { + text: `\' test`, + node: &ast.EscapingCharacter{ + Symbol: "'", + }, + }, } for _, test := range tests { diff --git a/parser/tokenizer/tokenizer.go b/parser/tokenizer/tokenizer.go index 8d682f5..e8f0efd 100644 --- a/parser/tokenizer/tokenizer.go +++ b/parser/tokenizer/tokenizer.go @@ -25,6 +25,7 @@ const ( Pipe TokenType = "|" Colon TokenType = ":" Caret TokenType = "^" + Apostrophe TokenType = "'" Backslash TokenType = "\\" Slash TokenType = "/" NewLine TokenType = "\n" @@ -95,6 +96,8 @@ func Tokenize(text string) []*Token { tokens = append(tokens, NewToken(Colon, ":")) case '^': tokens = append(tokens, NewToken(Caret, "^")) + case '\'': + tokens = append(tokens, NewToken(Apostrophe, "'")) case '\\': tokens = append(tokens, NewToken(Backslash, `\`)) case '/':