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

+26
View File
@@ -0,0 +1,26 @@
/*
* TinyBlocks - tinyblocks-xml / include/ast.h
*
* A AST do XML e a arvore JSON do core (TinyBlocks_JsonValue), usando uma
* convencao explicita e sem perdas:
*
* elemento -> { "tag": "nome",
* "attrs": { "k": "v", ... },
* "children": [ "texto", {elemento}, ... ] }
*
* Assim o XML pode ser convertido de/para JSON e reemitido.
*/
#ifndef TB_XML_AST_H
#define TB_XML_AST_H
#include <stddef.h>
#include <stdbool.h>
#include <tinyblocks/tb_json_block.h>
#include "lexeme.h"
TinyBlocks_JsonValue* xml_parse(const char* text, char* err, size_t errcap);
TinyBlocks_JsonValue* xml_parse_file(const char* path, char* err, size_t errcap);
char* xml_to_string(const TinyBlocks_JsonValue* root, bool pretty);
bool xml_write_file(const TinyBlocks_JsonValue* root, const char* path, bool pretty);
#endif /* TB_XML_AST_H */
+50
View File
@@ -0,0 +1,50 @@
/*
* TinyBlocks - tinyblocks-xml / include/lexeme.h
* Lexer de XML: emit tokens de texto, tags, comentarios, CDATA e PI.
*/
#ifndef TB_XML_LEXEME_H
#define TB_XML_LEXEME_H
#include <stddef.h>
#include <stdbool.h>
typedef enum {
XT_EOF, XT_ERROR,
XT_TEXT, /* texto entre tags (entidades decodificadas) */
XT_START, /* <tag attrs...> */
XT_EMPTY, /* <tag attrs.../> */
XT_END, /* </tag> */
XT_COMMENT, /* <!-- ... --> */
XT_CDATA, /* <![CDATA[ ... ]]> */
XT_PI, /* <? ... ?> */
XT_DOCTYPE /* <! ... > */
} XmlTokKind;
typedef struct {
XmlTokKind kind;
int line, col;
char* name; /* XT_START/XT_EMPTY/XT_END */
char** attr_names; /* XT_START/XT_EMPTY */
char** attr_vals;
int attr_n, attr_cap;
char* text; /* XT_TEXT/XT_COMMENT/XT_CDATA/XT_PI/XT_DOCTYPE */
} XmlToken;
typedef struct {
const char* p;
int line, col;
char* err; size_t errcap;
bool failed;
} XmlLexer;
typedef struct { bool ok; char msg[160]; int line, col; } XmlError;
void xml_lexer_init(XmlLexer* L, const char* src, char* err, size_t errcap);
bool xml_lexer_next(XmlLexer* L, XmlToken* t); /* false = fim/erro */
void xml_token_free(XmlToken* t);
const char* xml_tok_name(XmlTokKind k);
/* Decodifica entidades XML (&lt; &#NN; ...) em 'dst'. */
void xml_decode_entities(const char* src, char* dst, size_t cap);
#endif /* TB_XML_LEXEME_H */
+24
View File
@@ -0,0 +1,24 @@
/*
* TinyBlocks - tb_xml.h
* Library tinyblocks-xml: parser/emissor de XML (AST = JSON do core).
*/
#ifndef TINYBLOCKS_XML_H
#define TINYBLOCKS_XML_H
#include <tinyblocks/tinyblocks.h>
#include "ast.h"
#ifdef __cplusplus
extern "C" {
#endif
TB_API const TinyBlocks_LibraryDescriptor* tb_xml_get_library(void);
/* Consulta um caminho "raiz/filho/@atributo" no texto XML. */
TB_API const char* tb_xml_get_path(const char* text, const char* path, const char* def);
#ifdef __cplusplus
}
#endif
#endif /* TINYBLOCKS_XML_H */