Support question mark in symbol.

This commit is contained in:
bakpakin 2018-01-14 10:17:18 -05:00
parent 53c0d5757c
commit f5b29b85ba
3 changed files with 34 additions and 1 deletions

View File

@ -159,6 +159,9 @@ static void runfile(const uint8_t *src, int32_t len) {
case DST_PARSE_ERROR:
dst_puts(dst_formatc("syntax error at %d: %S\n",
s - src + res.bytes_read + 1, res.error));
if (res.bytes_read == 0) {
s++;
}
break;
case DST_PARSE_OK:
{

View File

@ -79,6 +79,7 @@ static int is_symbol_char_gen(uint8_t 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
chars and are then checked for utf-8 compliance. */
static uint32_t symchars[8] = {
0x00000000, 0x77ffec72, 0xd7ffffff, 0x57fffffe,
0x00000000, 0xF7ffec72, 0xd7ffffff, 0x57fffffe,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
};

View File

@ -178,6 +178,35 @@
(assert (= (string "🐼" 🦊 🐮) "🐼foxcow") "emojis 🙉 :)")
(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
(assert (not= (gensym) (gensym)) "two gensyms not equal")