remove json test
This commit is contained in:
parent
d11d2d8309
commit
a17950bebe
@ -1,25 +0,0 @@
|
||||
{
|
||||
"glossary": {
|
||||
"title": "example glossary",
|
||||
"GlossDiv": {
|
||||
"title": "S",
|
||||
"GlossList": {
|
||||
"GlossEntry": {
|
||||
"ID": "SGML",
|
||||
"SortAs": "SGML",
|
||||
"GlossTerm": "Standard Generalized Markup Language",
|
||||
"Acronym": "SGML",
|
||||
"Abbrev": "ISO 8879:1986",
|
||||
"GlossDef": {
|
||||
"para": "A meta-markup language, used to create markup languages such as DocBook.",
|
||||
"GlossSeeAlso": [
|
||||
"GML",
|
||||
"XML"
|
||||
]
|
||||
},
|
||||
"GlossSee": "markup"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
63
src/app.c
63
src/app.c
@ -89,29 +89,10 @@ INTERNAL struct sys_window_settings default_window_settings(struct sys_window *w
|
||||
* Entry point
|
||||
* ========================== */
|
||||
|
||||
|
||||
|
||||
|
||||
/* TODO: remove this (testing) */
|
||||
#include "json.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void app_entry_point(void)
|
||||
{
|
||||
L.quit_sf = sync_flag_alloc();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
u32 worker_count = 4;
|
||||
{
|
||||
/* FIXME: Switch this on to utilize all cores. Only decreasing worker count for testing purposes. */
|
||||
@ -202,50 +183,6 @@ void app_entry_point(void)
|
||||
struct user_startup_receipt user_sr = user_startup(&work_sr, &renderer_sr, &font_sr, &texture_sr, &draw_sr, &game_sr, &asset_cache_sr, &mixer_sr, &window);
|
||||
struct playback_startup_receipt playback_sr = playback_startup(&mixer_sr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
struct temp_arena scratch = scratch_begin_no_conflict();
|
||||
|
||||
struct resource resource = resource_open(STR("res/test.json"));
|
||||
struct json_parse_result res = json_from_string(scratch.arena, STRING_FROM_BUFFER(resource.bytes));
|
||||
resource_close(resource);
|
||||
|
||||
struct json *root = res.root;
|
||||
struct json_error_list errors = res.errors;
|
||||
(UNUSED)root;
|
||||
(UNUSED)errors;
|
||||
|
||||
if (errors.first) {
|
||||
struct string err = string_format(scratch.arena,
|
||||
STR("Error from offset %F to %F:\n%F"),
|
||||
FMT_UINT(errors.first->start),
|
||||
FMT_UINT(errors.first->end),
|
||||
FMT_STR(errors.first->msg));
|
||||
sys_panic(err);
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(UNUSED)user_sr;
|
||||
(UNUSED)playback_sr;
|
||||
|
||||
|
||||
81
src/json.c
81
src/json.c
@ -4,7 +4,7 @@
|
||||
#include "scratch.h"
|
||||
#include "math.h"
|
||||
|
||||
/* TODO:
|
||||
/* TODO (if we want to be JSON standard compliant):
|
||||
* - Support unicode escape sequences in strings (\u)
|
||||
* - Don't allow leading 0s in numbers
|
||||
*/
|
||||
@ -53,17 +53,8 @@ enum token_type {
|
||||
|
||||
struct token {
|
||||
enum token_type type;
|
||||
|
||||
u64 start;
|
||||
u64 end;
|
||||
|
||||
#if 0
|
||||
union {
|
||||
f64 number_value;
|
||||
struct string string_value;
|
||||
} value;
|
||||
#endif
|
||||
|
||||
struct token *next;
|
||||
};
|
||||
|
||||
@ -102,18 +93,6 @@ INTERNAL struct token *push_token(struct arena *arena, struct token_list *list)
|
||||
return t;
|
||||
}
|
||||
|
||||
#if 0
|
||||
INTERNAL u8 peek_char_offset(struct string src, u64 pos, i64 offset)
|
||||
{
|
||||
u8 c = 0;
|
||||
i64 peek_pos = pos + offset;
|
||||
if (0 <= peek_pos && peek_pos < (i64)src.len) {
|
||||
c = src.text[peek_pos];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
INTERNAL struct token_list lex(struct arena *arena, struct string src)
|
||||
{
|
||||
struct token_list res = { 0 };
|
||||
@ -181,63 +160,6 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src)
|
||||
++pos;
|
||||
} break;
|
||||
|
||||
#if 0
|
||||
case '-': {
|
||||
|
||||
b32 is_whole_sign = false;
|
||||
switch (peek_char_offset(src, pos, 1)) {
|
||||
case '0': {
|
||||
switch (peek_char_offset(src, pos, 2)) {
|
||||
case '.': {
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
if (peek_char_offset(src, pos, 1))
|
||||
|
||||
b32 is_whole_sign = false;
|
||||
if ((pos + 1) < src.len) {
|
||||
switch (src.text[pos + 1]) {
|
||||
case '0': {
|
||||
if ((pos + 2) < src.len) {
|
||||
|
||||
}
|
||||
} break;
|
||||
|
||||
CASE_DIGIT_1_TO_9: {
|
||||
is_whole_sign = true;
|
||||
} break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_whole_sign) {
|
||||
struct token *part = push_token(arena, &res);
|
||||
part->type = TOKEN_TYPE_PART_WHOLE_SIGN_NEGATIVE;
|
||||
part->start = pos;
|
||||
part->end = pos + 1;
|
||||
++pos;
|
||||
} else {
|
||||
++pos;
|
||||
break;
|
||||
}
|
||||
};
|
||||
CASE_DIGIT_0_TO_9: {
|
||||
t->type = TOKEN_TYPE_NUMBER;
|
||||
|
||||
enum lex_number_state state = LEX_NUMBER_STATE_WHOLE;
|
||||
b32 number_done = false;
|
||||
while (!number_done && pos < src.len) {
|
||||
switch (src.text[pos]) {
|
||||
CASE_DIGIT
|
||||
}
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
#else
|
||||
/* Number */
|
||||
case '-': {
|
||||
/* Verify '-' precedes digit */
|
||||
@ -328,7 +250,6 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src)
|
||||
}
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
|
||||
/* String */
|
||||
case '"': {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user