Adiciona libraries toml/fs, metadados .toml e build por library
- tinyblocks-toml: lexer + parser TOML (include/lexeme.h, include/ast.h, src/lexer.c, src/parser.c) e bloco Toml.Get. - tinyblocks-fs: categoria "Arquivos" com FS.Open/Read/Write/Append/Tell/Close. - library.toml em cada library com metadados (categoria, cor, descricao) e receita de build, sem precisar embutir isso no .so. - Makefiles proprios por library com build/ local; Makefile raiz delega. - Palco (tb_stage) movido para o core; pen deixa de depender do editor, o que torna os .so arrastaveis. - Editor linka com -rdynamic para resolver simbolos do core em .so via dlopen. - Testes: test-toml (parser) e test-plugin (dlopen de .so standalone).
This commit is contained in:
1 parent
90d47bf8a0
commit
dc23b92d15
48 files changed
+2405
-744
No files matched your search
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* TinyBlocks - tinyblocks-toml
|
||||
* ast.h: arvore sintatica e leitura de documentos TOML.
|
||||
*/
|
||||
#ifndef TB_TOML_AST_H
|
||||
#define TB_TOML_AST_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "lexeme.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TOML_STRING,
|
||||
TOML_INTEGER,
|
||||
TOML_FLOAT,
|
||||
TOML_BOOL,
|
||||
TOML_DATETIME,
|
||||
TOML_ARRAY,
|
||||
TOML_TABLE
|
||||
} TomlValueKind;
|
||||
|
||||
typedef struct TomlValue TomlValue;
|
||||
typedef struct TomlKeyVal TomlKeyVal;
|
||||
|
||||
struct TomlKeyVal {
|
||||
char* key;
|
||||
TomlValue* value;
|
||||
TomlKeyVal* next;
|
||||
};
|
||||
|
||||
struct TomlValue {
|
||||
TomlValueKind kind;
|
||||
int line, col;
|
||||
union {
|
||||
char* string;
|
||||
long long integer;
|
||||
double real;
|
||||
bool boolean;
|
||||
struct { TomlValue** items; size_t count, cap; } array;
|
||||
struct { TomlKeyVal* head, *tail; size_t count; } table;
|
||||
} as;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TomlValue* root; /* tabela raiz */
|
||||
} TomlDoc;
|
||||
|
||||
/* Parser (texto em memoria / arquivo). Em erro preenche err. */
|
||||
TomlDoc* toml_parse(const char* src, TomlLexError* err);
|
||||
TomlDoc* toml_parse_file(const char* path, TomlLexError* err);
|
||||
void toml_free(TomlDoc* doc);
|
||||
|
||||
/* Navegacao */
|
||||
const TomlValue* toml_table_get(const TomlValue* table, const char* key);
|
||||
const TomlValue* toml_path_get(const TomlValue* root, const char* dotted);
|
||||
const TomlValue* toml_array_get(const TomlValue* arr, size_t i);
|
||||
size_t toml_array_count(const TomlValue* arr);
|
||||
size_t toml_table_count(const TomlValue* table);
|
||||
const TomlKeyVal* toml_table_head(const TomlValue* table);
|
||||
|
||||
/* Conversoes com valor padrao */
|
||||
const char* toml_as_string(const TomlValue* v, const char* def);
|
||||
long long toml_as_int(const TomlValue* v, long long def);
|
||||
double toml_as_float(const TomlValue* v, double def);
|
||||
bool toml_as_bool(const TomlValue* v, bool def);
|
||||
|
||||
/* Escreve a arvore em stdout (debug) */
|
||||
void toml_dump(const TomlValue* v, int indent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TB_TOML_AST_H */
|
||||
Reference in new issue
Block a user