MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add CC_GT character class and handle it in print_value_colored

+18 -7
+18 -7
src/modules/io.c
··· 73 73 enum char_class { 74 74 CC_OTHER, CC_NUL, CC_QUOTE, CC_ESCAPE, CC_LBRACE, CC_RBRACE, 75 75 CC_LBRACK, CC_RBRACK, CC_COLON, CC_COMMA, CC_NEWLINE, 76 - CC_DIGIT, CC_MINUS, CC_ALPHA, CC_IDENT, CC_LT 76 + CC_DIGIT, CC_MINUS, CC_ALPHA, CC_IDENT, CC_LT, CC_GT 77 77 }; 78 78 79 79 static const uint8_t char_class_table[256] = { 80 80 [0] = CC_NUL, 81 81 ['\n'] = CC_NEWLINE, ['"'] = CC_QUOTE, ['\''] = CC_QUOTE, ['\\'] = CC_ESCAPE, 82 82 ['{'] = CC_LBRACE, ['}'] = CC_RBRACE, ['['] = CC_LBRACK, [']'] = CC_RBRACK, 83 - [':'] = CC_COLON, [','] = CC_COMMA, ['-'] = CC_MINUS, ['<'] = CC_LT, 83 + [':'] = CC_COLON, [','] = CC_COMMA, ['-'] = CC_MINUS, ['<'] = CC_LT, ['>'] = CC_GT, 84 84 ['_'] = CC_IDENT, ['$'] = CC_IDENT, 85 85 ['0'] = CC_DIGIT, ['1'] = CC_DIGIT, ['2'] = CC_DIGIT, ['3'] = CC_DIGIT, 86 86 ['4'] = CC_DIGIT, ['5'] = CC_DIGIT, ['6'] = CC_DIGIT, ['7'] = CC_DIGIT, ··· 122 122 [CC_LBRACK] = &&lbrack, [CC_RBRACK] = &&rbrack, 123 123 [CC_COLON] = &&colon, [CC_COMMA] = &&separator, [CC_NEWLINE] = &&separator, 124 124 [CC_DIGIT] = &&number, [CC_MINUS] = &&minus, 125 - [CC_ALPHA] = &&alpha, [CC_IDENT] = &&ident, [CC_LT] = &&lt, [CC_OTHER] = &&other 125 + [CC_ALPHA] = &&alpha, [CC_IDENT] = &&ident, [CC_LT] = &&lt, [CC_GT] = &&gt, [CC_OTHER] = &&other 126 126 }; 127 127 128 128 const char *p = str; ··· 159 159 brace_depth--; is_key = false; goto next; 160 160 161 161 lbrack: 162 - if (memcmp(p, "[Function", 9) == 0 || memcmp(p, "[native code]", 13) == 0) { EMIT_UNTIL(']', JSON_FUNC) } 163 - if (memcmp(p, "[Circular", 9) == 0) { EMIT_UNTIL(']', JSON_REF) } 162 + switch (p[1]) { 163 + case 'F': if (memcmp(p + 2, "unction", 7) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 164 + case 'n': if (memcmp(p + 2, "ative code]", 11) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 165 + case 'C': if (memcmp(p + 2, "ircular", 7) == 0) { EMIT_UNTIL(']', JSON_REF) } break; 166 + case 'G': if (memcmp(p + 2, "etter/Setter]", 13) == 0 || memcmp(p + 2, "etter]", 6) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 167 + case 'S': if (memcmp(p + 2, "etter]", 6) == 0) { EMIT_UNTIL(']', JSON_FUNC) } break; 168 + case 'O': if (memcmp(p + 2, "bject: null prototype]", 22) == 0) { EMIT_UNTIL(']', JSON_TAG) } break; 169 + } 164 170 io_puts(JSON_BRACE, stream); io_putc(*p++, stream); io_puts(ANSI_RESET, stream); 165 171 array_depth++; is_key = false; goto next; 166 172 ··· 195 201 196 202 lt: 197 203 if (memcmp(p, "<ref", 4) == 0) { EMIT_UNTIL('>', JSON_REF) } 198 - while (*p && *p != '>') io_putc(*p++, stream); 199 - if (*p == '>') io_putc(*p++, stream); 204 + io_puts(JSON_BRACE, stream); io_putc(*p++, stream); io_puts(ANSI_RESET, stream); 205 + goto next; 206 + 207 + gt: 208 + io_puts(JSON_BRACE, stream); io_putc(*p++, stream); io_puts(ANSI_RESET, stream); 200 209 goto next; 201 210 202 211 alpha: ··· 204 213 io_puts(JSON_TAG, stream); io_puts("Object [", stream); 205 214 p += 8; 206 215 while (*p && *p != ']') io_putc(*p++, stream); 216 + if (*p == ']') io_putc(*p++, stream); 207 217 io_puts(ANSI_RESET, stream); 208 218 goto next; 209 219 } 220 + 210 221 KEYWORD("true", JSON_BOOL) 211 222 KEYWORD("false", JSON_BOOL) 212 223 KEYWORD("null", JSON_NULL)