Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test case for \u and \o characters
Before this commit, reading something like "\u \v \w", would produce two char tokens, one with "\u \v " and another with "\w". Test included exemplifies solution.
  • Loading branch information
volrath committed Nov 24, 2017
commit 388bb2bde2f1985e246d52c3970c8468e03ca69d
4 changes: 2 additions & 2 deletions parseclj-lex.el
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ token is returned."
(right-char 7)
(parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos))

((equal (char-after (point)) ?u)
((string-match-p "^u[0-9a-fA-F]\\{4\\}" (parseclj-lex-lookahead 5))
(right-char 5)
(parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos))

((equal (char-after (point)) ?o)
((string-match-p "^o[0-8]\\{3\\}" (parseclj-lex-lookahead 4))
(right-char 4)
(parseclj-lex-token :character (buffer-substring-no-properties pos (point)) pos))

Expand Down
9 changes: 9 additions & 0 deletions test/parseclj-lex-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\b" 28)))
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\c" 30))))

(with-temp-buffer
(insert "\\u \\v \\w")
(goto-char 1)
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\u" 1)))
(should (equal (parseclj-lex-next) (parseclj-lex-token :whitespace " " 3)))
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\v" 4)))
(should (equal (parseclj-lex-next) (parseclj-lex-token :whitespace " " 6)))
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\w" 7))))

(with-temp-buffer
(insert "\\u0078\\o170")
(goto-char 1)
Expand Down