Adiciona tinyblocks-blueprint e libraries json/xml/csv; abrir/salvar/exportar projeto

- tinyblocks-blueprint: dona do estado de edicao (abas, pool de blocos,
  vinculos parent/prel/next/sub/args, blocos compostos e variaveis) e da
  serializacao. JSON nativo (to/from) usando a AST JSON do core e export
  JSON/XML/CSV. Testado com round-trip (test-blueprint).
- tinyblocks-json: lexer + parser + emissor JSON independentes.
- tinyblocks-xml: lexer + parser de XML -> AST JSON do core + emissor.
- tinyblocks-csv: divisor de linhas/campos + parser/emissor sobre a AST JSON.
- Editor: botoes Abrir / Salvar / Exportar JSON XML CSV no menu; converte
  Ed <-> TbBlueprint; barra de caminho com modo; .json pode ser arrastado.
- Variaveis: tb_variables_clear e tb_variables_set_text.
- Harness: teste de salvar/abrir projeto; tests/blueprint_test.c.
This commit is contained in:
mguinhos committed 2026-10-20 19:51:48 -03:00
1 parent dc23b92d15
commit 1199d2d7c7
39 files changed
+3462 -24

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
/*
* TinyBlocks - tinyblocks-json / include/ast.h
* Arvore de valores JSON e API de parse/construcao/emissao.
*/
#ifndef TB_JSON_AST_H
#define TB_JSON_AST_H
#include <stddef.h>
#include <stdbool.h>
#include "lexeme.h"
typedef enum {
JSON_NULL, JSON_BOOL, JSON_INT, JSON_REAL, JSON_STR, JSON_ARR, JSON_OBJ
} JsonKind;
typedef struct JsonValue JsonValue;
struct JsonValue {
JsonKind kind;
bool bval;
long long ival;
double fval;
char* str; /* JSON_STR */
JsonValue** items; /* JSON_ARR / JSON_OBJ (valores) */
char** keys; /* JSON_OBJ (chaves, alinhado a items) */
size_t count, cap;
};
/* -- Parse --- */
JsonValue* json_parse(const char* text, JsonLexError* err);
JsonValue* json_parse_file(const char* path, JsonLexError* err);
void json_free(JsonValue* v);
/* -- Construcao (assumem a posse dos filhos) --- */
JsonValue* json_null(void);
JsonValue* json_bool(bool b);
JsonValue* json_int(long long i);
JsonValue* json_real(double d);
JsonValue* json_str(const char* s);
JsonValue* json_arr(void);
JsonValue* json_obj(void);
void json_arr_add(JsonValue* arr, JsonValue* v);
void json_obj_put(JsonValue* obj, const char* key, JsonValue* v); /* ultimo vence */
/* -- Navegacao --- */
JsonValue* json_obj_get(const JsonValue* obj, const char* key);
JsonValue* json_arr_at(const JsonValue* arr, size_t i);
size_t json_size(const JsonValue* v);
const char* json_as_str (const JsonValue* v, const char* def);
long long json_as_int (const JsonValue* v, long long def);
double json_as_real(const JsonValue* v, double def);
bool json_as_bool(const JsonValue* v, bool def);
/* -- Emissao (json_to_string devolve malloc; libere com free) --- */
char* json_to_string(const JsonValue* v, bool pretty);
bool json_write_file(const JsonValue* v, const char* path, bool pretty);
#endif /* TB_JSON_AST_H */