1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 19:19:53 +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 == '\n'
|| c == '\r' || c == '\r'
|| c == '\0' || c == '\0'
|| c == '\v'
|| c == '\f'; || c == '\f';
} }
@ -207,6 +208,8 @@ static int checkescape(uint8_t c) {
return '\0'; return '\0';
case 'f': case 'f':
return '\f'; return '\f';
case 'v':
return '\v';
case 'e': case 'e':
return 27; return 27;
case '"': case '"':

View File

@ -136,6 +136,15 @@ static void janet_escape_string_impl(JanetBuffer *buffer, const uint8_t *str, in
case '\0': case '\0':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\0", 2); janet_buffer_push_bytes(buffer, (const uint8_t *)"\\0", 2);
break; 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 '\\': case '\\':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\\\", 2); janet_buffer_push_bytes(buffer, (const uint8_t *)"\\\\", 2);
break; break;

View File

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