mirror of
https://github.com/janet-lang/janet
synced 2025-01-26 15:16:51 +00:00
Support question mark in symbol.
This commit is contained in:
parent
53c0d5757c
commit
f5b29b85ba
@ -159,6 +159,9 @@ static void runfile(const uint8_t *src, int32_t len) {
|
|||||||
case DST_PARSE_ERROR:
|
case DST_PARSE_ERROR:
|
||||||
dst_puts(dst_formatc("syntax error at %d: %S\n",
|
dst_puts(dst_formatc("syntax error at %d: %S\n",
|
||||||
s - src + res.bytes_read + 1, res.error));
|
s - src + res.bytes_read + 1, res.error));
|
||||||
|
if (res.bytes_read == 0) {
|
||||||
|
s++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DST_PARSE_OK:
|
case DST_PARSE_OK:
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,7 @@ static int is_symbol_char_gen(uint8_t c) {
|
|||||||
c == '/' ||
|
c == '/' ||
|
||||||
c == ':' ||
|
c == ':' ||
|
||||||
c == '<' ||
|
c == '<' ||
|
||||||
|
c == '?' ||
|
||||||
c == '=' ||
|
c == '=' ||
|
||||||
c == '>' ||
|
c == '>' ||
|
||||||
c == '@' ||
|
c == '@' ||
|
||||||
@ -94,7 +95,7 @@ if the corresponding ascci code is a symbol char, and 0
|
|||||||
if not. The upper characters are also considered symbol
|
if not. The upper characters are also considered symbol
|
||||||
chars and are then checked for utf-8 compliance. */
|
chars and are then checked for utf-8 compliance. */
|
||||||
static uint32_t symchars[8] = {
|
static uint32_t symchars[8] = {
|
||||||
0x00000000, 0x77ffec72, 0xd7ffffff, 0x57fffffe,
|
0x00000000, 0xF7ffec72, 0xd7ffffff, 0x57fffffe,
|
||||||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
|
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,6 +178,35 @@
|
|||||||
(assert (= (string "🐼" 🦊 🐮) "🐼foxcow") "emojis 🙉 :)")
|
(assert (= (string "🐼" 🦊 🐮) "🐼foxcow") "emojis 🙉 :)")
|
||||||
(assert (not= 🦊 :🦊) "utf8 strings are not symbols and vice versa")
|
(assert (not= 🦊 :🦊) "utf8 strings are not symbols and vice versa")
|
||||||
|
|
||||||
|
# Merge sort
|
||||||
|
|
||||||
|
(def empty? (fn [xs] (= 0 (length xs))))
|
||||||
|
|
||||||
|
(def merge (fn [xs ys]
|
||||||
|
(def ret [])
|
||||||
|
(def xlen (length xs))
|
||||||
|
(def ylen (length ys))
|
||||||
|
(var i 0)
|
||||||
|
(var j 0)
|
||||||
|
# Main merge
|
||||||
|
(while (if (< i xlen) (< j ylen))
|
||||||
|
(def xi (get xs i))
|
||||||
|
(def yj (get ys j))
|
||||||
|
(if (< xi yj)
|
||||||
|
(do (push ret xi) (varset! i (+ i 1)))
|
||||||
|
(do (push ret yj) (varset! j (+ j 1)))))
|
||||||
|
# Push rest of xs
|
||||||
|
(while (< i xlen)
|
||||||
|
(def xi (get xs i))
|
||||||
|
(push ret xi)
|
||||||
|
(varset! i (+ i 1)))
|
||||||
|
# Push rest of ys
|
||||||
|
(while (< j ylen)
|
||||||
|
(def yj (get ys j))
|
||||||
|
(push ret yj)
|
||||||
|
(varset! j (+ j 1)))
|
||||||
|
ret))
|
||||||
|
|
||||||
# Gensym tests
|
# Gensym tests
|
||||||
|
|
||||||
(assert (not= (gensym) (gensym)) "two gensyms not equal")
|
(assert (not= (gensym) (gensym)) "two gensyms not equal")
|
||||||
|
Loading…
Reference in New Issue
Block a user