1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-17 18:59:56 +00:00

Add "\v" string esca[e sequence.

This commit is contained in:
Calvin Rose 2019-02-24 14:46:16 -05:00
parent 92a5567b4a
commit 602e30a421
3 changed files with 15 additions and 3 deletions

View File

@ -32,6 +32,7 @@ static int is_whitespace(uint8_t c) {
|| c == '\n'
|| c == '\r'
|| c == '\0'
|| c == '\v'
|| c == '\f';
}
@ -207,6 +208,8 @@ static int checkescape(uint8_t c) {
return '\0';
case 'f':
return '\f';
case 'v':
return '\v';
case 'e':
return 27;
case '"':

View File

@ -136,6 +136,15 @@ static void janet_escape_string_impl(JanetBuffer *buffer, const uint8_t *str, in
case '\0':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\0", 2);
break;
case '\f':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\f", 2);
break;
case '\v':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\v", 2);
break;
case 27:
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\e", 2);
break;
case '\\':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\\\", 2);
break;

View File

@ -37,13 +37,13 @@
(def should-color (or (specials sym) (core-env sym)))
(paint (if should-color :coresym :symbol) text))
~{:ws (set " \t\r\f\n\0")
~{:ws (set " \t\r\f\n\v\0")
:readermac (set "';~,")
:symchars (+ (range "09" "AZ" "az" "\x80\xFF") (set "!$%&*+-./:<?=>@^_|"))
:token (some :symchars)
:hex (range "09" "af" "AF")
:escape (* "\\" (+ (set "ntrzf0\"\\e")
(* "x" :hex :hex)
:escape (* "\\" (+ (set "ntrvzf0\"\\e")
(* "x" :hex :hex)
(error (constant "bad hex escape"))))
:comment ,(<-c :comment ~(* "#" (any (if-not (+ "\n" -1) 1))))