mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-07 16:18:49 +00:00
misc
This commit is contained in:
@@ -11,3 +11,11 @@ The library will be provided in 3 forms:
|
|||||||
* cpp17: Setup ergonoically for usage as a C++ 17 library (both segregated and as a single-header)
|
* cpp17: Setup ergonoically for usage as a C++ 17 library (both segregated and as a single-header)
|
||||||
|
|
||||||
docs will be updated referencing content procued by Ryan Fleury and content based on studying or resolving this library for this repo.
|
docs will be updated referencing content procued by Ryan Fleury and content based on studying or resolving this library for this repo.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
* [docs](./docs/Readme.md)
|
||||||
|
* [examples](./examples/Readme.md)
|
||||||
|
* [gen_c11](./gen_c11/Readme.md)
|
||||||
|
* [gen_cpp17](./gen_cpp17/Readme.md)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# bin
|
||||||
|
|
||||||
|
|
||||||
+10
-10
@@ -945,8 +945,7 @@ parse_from_text_tokens(Arena* arena, String8 filename, String8 text, TokenArray
|
|||||||
//~ rjf: Bundled Text -> Tree Functions
|
//~ rjf: Bundled Text -> Tree Functions
|
||||||
|
|
||||||
ParseResult
|
ParseResult
|
||||||
parse_from_text(Arena* arena, String8 filename, String8 text)
|
parse_from_text(Arena* arena, String8 filename, String8 text) {
|
||||||
{
|
|
||||||
TempArena scratch = scratch_begin(&arena, 1);
|
TempArena scratch = scratch_begin(&arena, 1);
|
||||||
TokenizeResult tokenize = tokenize_from_text(scratch.arena, text);
|
TokenizeResult tokenize = tokenize_from_text(scratch.arena, text);
|
||||||
ParseResult parse = parse_from_text_tokens(arena, filename, text, tokenize.tokens);
|
ParseResult parse = parse_from_text_tokens(arena, filename, text, tokenize.tokens);
|
||||||
@@ -957,17 +956,19 @@ parse_from_text(Arena* arena, String8 filename, String8 text)
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Tree -> Text Functions
|
//~ rjf: Tree -> Text Functions
|
||||||
|
|
||||||
internal String8List
|
String8List
|
||||||
debug_string_list_from_tree(Arena* arena, Node* root)
|
debug_string_list_from_tree(Arena* arena, Node* root)
|
||||||
{
|
{
|
||||||
String8List strings = {0};
|
String8List strings = {0};
|
||||||
{
|
{
|
||||||
|
// Depth-first traversal of tree.
|
||||||
char* indentation = " ";
|
char* indentation = " ";
|
||||||
S32 depth = 0;
|
S32 depth = 0;
|
||||||
for (Node* node = root, *next = nil_node(); !node_is_nil(node); node = next)
|
for (Node* node = root, *next = nil_node(); !node_is_nil(node); node = next)
|
||||||
{
|
{
|
||||||
// rjf: get next recursion
|
// rjf: get next recursion
|
||||||
NodeRec rec = node_rec_depth_first_pre(node, root);
|
NodeRec
|
||||||
|
rec = node_rec_depth_first_pre(node, root);
|
||||||
next = rec.next;
|
next = rec.next;
|
||||||
|
|
||||||
// rjf: extract node info
|
// rjf: extract node info
|
||||||
@@ -975,6 +976,7 @@ debug_string_list_from_tree(Arena *arena, Node *root)
|
|||||||
switch (node->kind)
|
switch (node->kind)
|
||||||
{
|
{
|
||||||
default: {} break;
|
default: {} break;
|
||||||
|
|
||||||
case NodeKind_File: { kind_string = str8_lit("File" ); } break;
|
case NodeKind_File: { kind_string = str8_lit("File" ); } break;
|
||||||
case NodeKind_ErrorMarker: { kind_string = str8_lit("ErrorMarker"); } break;
|
case NodeKind_ErrorMarker: { kind_string = str8_lit("ErrorMarker"); } break;
|
||||||
case NodeKind_Main: { kind_string = str8_lit("Main" ); } break;
|
case NodeKind_Main: { kind_string = str8_lit("Main" ); } break;
|
||||||
@@ -987,18 +989,16 @@ debug_string_list_from_tree(Arena *arena, Node *root)
|
|||||||
str8_list_pushf(arena, &strings, "%.*s\"%S\" : %S", depth, indentation, node->string, kind_string);
|
str8_list_pushf(arena, &strings, "%.*s\"%S\" : %S", depth, indentation, node->string, kind_string);
|
||||||
|
|
||||||
// rjf: children -> open brace
|
// rjf: children -> open brace
|
||||||
if(rec.push_count != 0)
|
if (rec.push_count != 0) {
|
||||||
{
|
str8_list_pushf(arena, &strings, "%.*s\n{", depth, indentation);
|
||||||
str8_list_pushf(arena, &strings, "%.*s{", depth, indentation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: descend
|
// rjf: descend
|
||||||
depth += rec.push_count;
|
depth += rec.push_count;
|
||||||
|
|
||||||
// rjf: popping -> close braces
|
// rjf: popping -> close braces
|
||||||
for(S32 pop_idx = 0; pop_idx < rec.pop_count; pop_idx += 1)
|
for (S32 pop_idx = 0; pop_idx < rec.pop_count; pop_idx += 1) {
|
||||||
{
|
str8_list_pushf(arena, &strings, "%.*s\n}", depth - 1 - pop_idx, indentation);
|
||||||
str8_list_pushf(arena, &strings, "%.*s}", depth-1-pop_idx, indentation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: ascend
|
// rjf: ascend
|
||||||
|
|||||||
+5
-5
@@ -113,7 +113,8 @@ struct TokenArray
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Node Types
|
//~ rjf: Node Types
|
||||||
|
|
||||||
typedef enum NodeKind
|
typedef enum NodeKind NodeKind;
|
||||||
|
enum NodeKind
|
||||||
{
|
{
|
||||||
NodeKind_Nil,
|
NodeKind_Nil,
|
||||||
NodeKind_File,
|
NodeKind_File,
|
||||||
@@ -123,8 +124,7 @@ typedef enum NodeKind
|
|||||||
NodeKind_List,
|
NodeKind_List,
|
||||||
NodeKind_Reference,
|
NodeKind_Reference,
|
||||||
NodeKind_COUNT
|
NodeKind_COUNT
|
||||||
}
|
};
|
||||||
NodeKind;
|
|
||||||
|
|
||||||
typedef U32 NodeFlags;
|
typedef U32 NodeFlags;
|
||||||
enum
|
enum
|
||||||
@@ -502,10 +502,10 @@ MD_API ParseResult parse_from_text_tokens(Arena* arena, String8 filename, String
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Bundled Text -> Tree Functions
|
//~ rjf: Bundled Text -> Tree Functions
|
||||||
|
|
||||||
ParseResult parse_from_text(Arena* arena, String8 filename, String8 text);
|
MD_API ParseResult parse_from_text(Arena* arena, String8 filename, String8 text);
|
||||||
#define tree_from_string(arena, string) (parse_from_text((arena), str8_zero(), (string)).root)
|
#define tree_from_string(arena, string) (parse_from_text((arena), str8_zero(), (string)).root)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Tree -> Text Functions
|
//~ rjf: Tree -> Text Functions
|
||||||
|
|
||||||
String8List debug_string_list_from_tree(Arena* arena, Node* root);
|
MD_API String8List debug_string_list_from_tree(Arena* arena, Node* root);
|
||||||
|
|||||||
+1
-2
@@ -4,6 +4,5 @@
|
|||||||
|
|
||||||
#include "base/base.h"
|
#include "base/base.h"
|
||||||
#include "os/os.h"
|
#include "os/os.h"
|
||||||
|
#include "mdesk/mdesk.h"
|
||||||
|
|
||||||
// mdesk
|
|
||||||
// metagen
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# docs
|
||||||
|
|
||||||
|
Haven't done yet...
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
# Examples
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# gen_c11
|
||||||
|
|
||||||
|
|
||||||
@@ -1017,9 +1017,9 @@ word Msg, MD_Msg
|
|||||||
word MsgList, MD_MsgList
|
word MsgList, MD_MsgList
|
||||||
|
|
||||||
word TokenFlags, MD_MsgFlags
|
word TokenFlags, MD_MsgFlags
|
||||||
namespace TokenFlag, MD_TokenFlag
|
namespace TokenFlag_, MD_TokenFlag_
|
||||||
word TokenGroups, MD_TokenGroups
|
word TokenGroups, MD_TokenGroups
|
||||||
namespace TokenGroup, MD_TokenGroup
|
namespace TokenGroup_, MD_TokenGroup_
|
||||||
word Token, MD_Token
|
word Token, MD_Token
|
||||||
word TokenChunkNode, MD_TokenChunkNode
|
word TokenChunkNode, MD_TokenChunkNode
|
||||||
word TokenChunkList, MD_TokenChunkList
|
word TokenChunkList, MD_TokenChunkList
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# gen_cpp17
|
||||||
|
|
||||||
|
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
# gencpp_c11
|
||||||
|
|
||||||
|
See: [gencpp](https://github.com/Ed94/gencpp)
|
||||||
|
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
# stb
|
||||||
|
|
||||||
|
See: [stb](https://github.com/nothings/stb)
|
||||||
|
|
||||||
Reference in New Issue
Block a user