Skip to content

Commit

Permalink
chore: update escaping rules
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Sep 17, 2024
1 parent 3ccacc4 commit b2451d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion parser/tests/escaping_character_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions parser/tokenizer/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
Pipe TokenType = "|"
Colon TokenType = ":"
Caret TokenType = "^"
Apostrophe TokenType = "'"
Backslash TokenType = "\\"
Slash TokenType = "/"
NewLine TokenType = "\n"
Expand Down Expand Up @@ -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 '/':
Expand Down

0 comments on commit b2451d1

Please sign in to comment.