mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Add "\v" string esca[e sequence.
This commit is contained in:
parent
92a5567b4a
commit
602e30a421
@ -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 '"':
|
||||
|
@ -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;
|
||||
|
@ -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))))
|
||||
|
Loading…
Reference in New Issue
Block a user