diff --git a/compile_commands.json b/compile_commands.json index 7b9ccfe..41bc9ee 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -118,12 +118,12 @@ "-x", "c", "-o", - "/tmp/main-4f432a.o", + "/tmp/main-fcfd2b.o", "src/main.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/main.c", - "output": "/tmp/main-4f432a.o" + "output": "/tmp/main-fcfd2b.o" }, { "arguments": [ @@ -187,12 +187,12 @@ "-x", "c", "-o", - "/tmp/dstring-841d2e.o", + "/tmp/dstring-46186e.o", "src/dstring/dstring.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/dstring/dstring.c", - "output": "/tmp/dstring-841d2e.o" + "output": "/tmp/dstring-46186e.o" }, { "arguments": [ @@ -256,11 +256,11 @@ "-x", "c", "-o", - "/tmp/lexer-5cd579.o", + "/tmp/lexer-b37823.o", "src/lexer/lexer.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/lexer/lexer.c", - "output": "/tmp/lexer-5cd579.o" + "output": "/tmp/lexer-b37823.o" } ] diff --git a/include/json_test.h b/include/json_test.h new file mode 100644 index 0000000..34e71a5 --- /dev/null +++ b/include/json_test.h @@ -0,0 +1,51 @@ +#ifndef JSON_TEST_H +#define JSON_TEST_H + +#include "aliases.h" +#include + +typedef struct json_obj_pair jobj_pair_t; +typedef struct json_coll jcoll_t; +typedef struct json_val jval_t; + +typedef enum { + JSON_OBJECT, + JSON_ARRAY, +} jcoll_type_t; + +typedef enum { + JSON_COLLECTION, + JSON_STRING, + JSON_INTEGER, + JSON_DOUBLE, + JSON_TRUE, + JSON_FALSE, + JSON_NULL, +} jval_type_t; + +struct json_val { + jval_type_t type; + union { + jcoll_t *collection; + const char *string; + i64 num_int; + f64 num_dbl; + bool boolean; + }; +}; + +struct json_obj_pair { + const char *key; + jval_t value; +}; + +struct json_coll { + jcoll_type_t type; + u64 size; + union { + jobj_pair_t pairs[50]; + jval_t items[50]; + }; +}; + +#endif // !JSON_TEST_H diff --git a/src/main.c b/src/main.c index 91d96f5..f73c74c 100644 --- a/src/main.c +++ b/src/main.c @@ -35,17 +35,14 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - token_t token = get_next_token(lexer, json); - while (token.type != TK_NO_TOKEN) { - print_token(token); + token_t token = get_next_token(lexer, json); + while (token.type != TK_NO_TOKEN) { + print_token(token); - token = get_next_token(lexer, NULL); - } + token = get_next_token(lexer, NULL); + } lexer_free(&lexer); - // printf("\n%35s: %s\n", filename, validate_json(json) ? "VALID" : - // "INVALID"); - return EXIT_SUCCESS; }