diff --git a/compile b/compile index 7c7a7fe..28f44ea 100755 --- a/compile +++ b/compile @@ -9,6 +9,10 @@ OUT=main CFLAGS+=" -Iinclude/dstring" SRC+=" src/dstring/*.c" +# JSON_ENTITIES +CFLAGS+=" -Iinclude/json_entities" +SRC+=" src/json_entities/*.c" + # LEXER CFLAGS+=" -Iinclude/lexer" SRC+=" src/lexer/*.c" diff --git a/compile_commands.json b/compile_commands.json index 41bc9ee..78e10ee 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -9,14 +9,15 @@ "-pedantic", "-Iinclude", "-Iinclude/dstring", + "-Iinclude/json_entities", "-Iinclude/lexer", "-o", "main", "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": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main" + "directory": "/Users/abdelrahman/dev/personal/say-it-in-json", + "file": "/Users/abdelrahman/dev/personal/say-it-in-json/src/main.c", + "output": "/Users/abdelrahman/dev/personal/say-it-in-json/main" }, { "arguments": [ @@ -28,14 +29,15 @@ "-pedantic", "-Iinclude", "-Iinclude/dstring", + "-Iinclude/json_entities", "-Iinclude/lexer", "-o", "main", "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": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main" + "directory": "/Users/abdelrahman/dev/personal/say-it-in-json", + "file": "/Users/abdelrahman/dev/personal/say-it-in-json/src/dstring/dstring.c", + "output": "/Users/abdelrahman/dev/personal/say-it-in-json/main" }, { "arguments": [ @@ -47,220 +49,34 @@ "-pedantic", "-Iinclude", "-Iinclude/dstring", + "-Iinclude/json_entities", + "-Iinclude/lexer", + "-o", + "main", + "src/json_entities/json_entities.c" + ], + "directory": "/Users/abdelrahman/dev/personal/say-it-in-json", + "file": "/Users/abdelrahman/dev/personal/say-it-in-json/src/json_entities/json_entities.c", + "output": "/Users/abdelrahman/dev/personal/say-it-in-json/main" + }, + { + "arguments": [ + "/usr/bin/clang", + "-c", + "-g", + "-Wall", + "-Werror", + "-pedantic", + "-Iinclude", + "-Iinclude/dstring", + "-Iinclude/json_entities", "-Iinclude/lexer", "-o", "main", "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": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main" - }, - { - "arguments": [ - "/usr/bin/clang-16", - "-cc1", - "-triple", - "x86_64-redhat-linux-gnu", - "-emit-obj", - "-mrelax-all", - "-disable-free", - "-clear-ast-before-backend", - "-disable-llvm-verifier", - "-discard-value-names", - "-main-file-name", - "-mrelocation-model", - "static", - "-mframe-pointer=all", - "-fmath-errno", - "-ffp-contract=on", - "-fno-rounding-math", - "-mconstructor-aliases", - "-funwind-tables=2", - "-target-cpu", - "x86-64", - "-tune-cpu", - "generic", - "-mllvm", - "-treat-scalable-fixed-error-as-warning", - "-debug-info-kind=constructor", - "-dwarf-version=4", - "-debugger-tuning=gdb", - "-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json", - "-resource-dir", - "/usr/lib64/clang/16", - "-I", - "include", - "-I", - "include/dstring", - "-I", - "include/lexer", - "-internal-isystem", - "/usr/lib64/clang/16/include", - "-internal-isystem", - "/usr/local/include", - "-internal-isystem", - "/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include", - "-internal-externc-isystem", - "/include", - "-internal-externc-isystem", - "/usr/include", - "-Wall", - "-Werror", - "-pedantic", - "-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json", - "-ferror-limit", - "19", - "-fgnuc-version=4.2.1", - "-fcolor-diagnostics", - "-faddrsig", - "-D__GCC_HAVE_DWARF2_CFI_ASM=1", - "-x", - "c", - "-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-fcfd2b.o" - }, - { - "arguments": [ - "/usr/bin/clang-16", - "-cc1", - "-triple", - "x86_64-redhat-linux-gnu", - "-emit-obj", - "-mrelax-all", - "-disable-free", - "-clear-ast-before-backend", - "-disable-llvm-verifier", - "-discard-value-names", - "-main-file-name", - "-mrelocation-model", - "static", - "-mframe-pointer=all", - "-fmath-errno", - "-ffp-contract=on", - "-fno-rounding-math", - "-mconstructor-aliases", - "-funwind-tables=2", - "-target-cpu", - "x86-64", - "-tune-cpu", - "generic", - "-mllvm", - "-treat-scalable-fixed-error-as-warning", - "-debug-info-kind=constructor", - "-dwarf-version=4", - "-debugger-tuning=gdb", - "-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json", - "-resource-dir", - "/usr/lib64/clang/16", - "-I", - "include", - "-I", - "include/dstring", - "-I", - "include/lexer", - "-internal-isystem", - "/usr/lib64/clang/16/include", - "-internal-isystem", - "/usr/local/include", - "-internal-isystem", - "/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include", - "-internal-externc-isystem", - "/include", - "-internal-externc-isystem", - "/usr/include", - "-Wall", - "-Werror", - "-pedantic", - "-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json", - "-ferror-limit", - "19", - "-fgnuc-version=4.2.1", - "-fcolor-diagnostics", - "-faddrsig", - "-D__GCC_HAVE_DWARF2_CFI_ASM=1", - "-x", - "c", - "-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-46186e.o" - }, - { - "arguments": [ - "/usr/bin/clang-16", - "-cc1", - "-triple", - "x86_64-redhat-linux-gnu", - "-emit-obj", - "-mrelax-all", - "-disable-free", - "-clear-ast-before-backend", - "-disable-llvm-verifier", - "-discard-value-names", - "-main-file-name", - "-mrelocation-model", - "static", - "-mframe-pointer=all", - "-fmath-errno", - "-ffp-contract=on", - "-fno-rounding-math", - "-mconstructor-aliases", - "-funwind-tables=2", - "-target-cpu", - "x86-64", - "-tune-cpu", - "generic", - "-mllvm", - "-treat-scalable-fixed-error-as-warning", - "-debug-info-kind=constructor", - "-dwarf-version=4", - "-debugger-tuning=gdb", - "-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json", - "-resource-dir", - "/usr/lib64/clang/16", - "-I", - "include", - "-I", - "include/dstring", - "-I", - "include/lexer", - "-internal-isystem", - "/usr/lib64/clang/16/include", - "-internal-isystem", - "/usr/local/include", - "-internal-isystem", - "/usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include", - "-internal-externc-isystem", - "/include", - "-internal-externc-isystem", - "/usr/include", - "-Wall", - "-Werror", - "-pedantic", - "-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json", - "-ferror-limit", - "19", - "-fgnuc-version=4.2.1", - "-fcolor-diagnostics", - "-faddrsig", - "-D__GCC_HAVE_DWARF2_CFI_ASM=1", - "-x", - "c", - "-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-b37823.o" + "directory": "/Users/abdelrahman/dev/personal/say-it-in-json", + "file": "/Users/abdelrahman/dev/personal/say-it-in-json/src/lexer/lexer.c", + "output": "/Users/abdelrahman/dev/personal/say-it-in-json/main" } ] diff --git a/include/json_entities/json_entities.h b/include/json_entities/json_entities.h new file mode 100644 index 0000000..476ce1f --- /dev/null +++ b/include/json_entities/json_entities.h @@ -0,0 +1,30 @@ +#ifndef JSON_ENTITIES_H +#define JSON_ENTITIES_H + +#include "aliases.h" +#include "dstring.h" +#include + +typedef struct json_value jval_t; + +typedef enum { + JVAL_OBJECT, + JVAL_ARRAY, + JVAL_STRING, + JVAL_INTEGER, + JVAL_DOUBLE, + JVAL_BOOLEAN, + JVAL_NULL, +} jval_type_t; + +struct json_value { + jval_type_t type; + union { + dstr_t *string; + i64 num_int; + f64 num_dbl; + bool boolean; + }; +}; + +#endif // !JSON_ENTITIES_H diff --git a/include/json_test.h b/include/json_test.h index 34e71a5..a28460a 100644 --- a/include/json_test.h +++ b/include/json_test.h @@ -4,6 +4,8 @@ #include "aliases.h" #include +#if 0 + typedef struct json_obj_pair jobj_pair_t; typedef struct json_coll jcoll_t; typedef struct json_val jval_t; @@ -48,4 +50,6 @@ struct json_coll { }; }; +#endif + #endif // !JSON_TEST_H diff --git a/src/json_entities/json_entities.c b/src/json_entities/json_entities.c new file mode 100644 index 0000000..5fcb61d --- /dev/null +++ b/src/json_entities/json_entities.c @@ -0,0 +1 @@ +#include "json_entities.h"