mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-02 04:38:14 +00:00
big naming pass for main API
This commit is contained in:
@@ -22,7 +22,7 @@ int main(int argument_count, char **arguments)
|
||||
MD_Node *code = MD_ParseWholeString(MD_S8Lit("Generated Test Code"), example_code).node;
|
||||
|
||||
printf("Source Metadesk Code:\n");
|
||||
printf("%.*s\n\n", MD_StringExpand(example_code));
|
||||
printf("%.*s\n\n", MD_S8VArg(example_code));
|
||||
|
||||
printf("Generated C Code:\n");
|
||||
for(MD_EachNode(node, code->first_child))
|
||||
|
||||
@@ -10,16 +10,16 @@ int main(int argument_count, char **arguments)
|
||||
for(int i = 1; i < argument_count; i += 1)
|
||||
{
|
||||
MD_Node *root = MD_ParseWholeFile(MD_S8CString(arguments[i])).node;
|
||||
MD_PushReference(list, root);
|
||||
MD_PushNewReference(list, root);
|
||||
}
|
||||
|
||||
// NOTE(rjf): Print errors on every single node.
|
||||
for(MD_EachNode(ref, list->first_child))
|
||||
{
|
||||
MD_Node *root = MD_Deref(ref);
|
||||
MD_Node *root = MD_NodeFromReference(ref);
|
||||
for(MD_EachNode(node, root->first_child))
|
||||
{
|
||||
MD_NodeMessageF(stderr, node, MD_MessageKind_Error, "This node has an error!");
|
||||
MD_PrintNodeMessageFmt(stderr, node, MD_MessageKind_Error, "This node has an error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ int main(int argument_count, char **arguments)
|
||||
for(int i = 1; i < argument_count; i += 1)
|
||||
{
|
||||
MD_Node *root = MD_ParseWholeFile(MD_S8CString(arguments[i])).node;
|
||||
MD_PushReference(list, root);
|
||||
MD_PushNewReference(list, root);
|
||||
}
|
||||
|
||||
// NOTE(rjf): Call "custom layer" back.
|
||||
Initialize();
|
||||
for(MD_EachNode(ref, list->first_child))
|
||||
{
|
||||
MD_Node *root = MD_Deref(ref);
|
||||
MD_Node *root = MD_NodeFromReference(ref);
|
||||
for(MD_EachNode(node, root->first_child))
|
||||
{
|
||||
TopLevel(node);
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, Identifier,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, Identifier,
|
||||
String: foo,
|
||||
Whole String: foo,
|
||||
Tag: @struct
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 1100000010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: ParenLeft, ParenRight, BeforeComma, Identifier,
|
||||
Flag Names: HasParenLeft, HasParenRight, IsBeforeComma, Identifier,
|
||||
String: x,
|
||||
Whole String: x,
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0011000000000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BracketLeft, BracketRight,
|
||||
Flag Names: HasBracketLeft, HasBracketRight,
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: MAX_PATH,
|
||||
@@ -24,7 +24,7 @@ Node {
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: char,
|
||||
@@ -34,21 +34,21 @@ Node {
|
||||
}
|
||||
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, Identifier,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, Identifier,
|
||||
String: bar,
|
||||
Whole String: bar,
|
||||
Tag: @struct
|
||||
Tag: @test_tag
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: y,
|
||||
Whole String: y,
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: float,
|
||||
@@ -56,13 +56,13 @@ Node {
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: z,
|
||||
Whole String: z,
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: i32,
|
||||
|
||||
@@ -1,138 +1,138 @@
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, Identifier,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, Identifier,
|
||||
String: a_set,
|
||||
Whole String: a_set,
|
||||
Tag: @sets
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, BeforeComma, Identifier,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, IsBeforeComma, Identifier,
|
||||
String: named_set,
|
||||
Whole String: named_set,
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000010000010000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, Numeric,
|
||||
Flag Names: IsBeforeComma, Numeric,
|
||||
String: 1,
|
||||
Whole String: 1,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000011000010000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, AfterComma, Numeric,
|
||||
Flag Names: IsBeforeComma, IsAfterComma, Numeric,
|
||||
String: 3,
|
||||
Whole String: 3,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000001000010000000000000000000000000000000000000000000000000,
|
||||
Flag Names: AfterComma, Numeric,
|
||||
Flag Names: IsAfterComma, Numeric,
|
||||
String: 7,
|
||||
Whole String: 7,
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110011000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, BeforeComma, AfterComma,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, IsBeforeComma, IsAfterComma,
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, Identifier,
|
||||
Flag Names: IsBeforeComma, Identifier,
|
||||
String: not,
|
||||
Whole String: not,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000011000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, AfterComma, Identifier,
|
||||
Flag Names: IsBeforeComma, IsAfterComma, Identifier,
|
||||
String: named,
|
||||
Whole String: named,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000001000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: AfterComma, Identifier,
|
||||
Flag Names: IsAfterComma, Identifier,
|
||||
String: set,
|
||||
Whole String: set,
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110011000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, BeforeComma, AfterComma,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, IsBeforeComma, IsAfterComma,
|
||||
Tag: @tag_with_params
|
||||
Tag Children{
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, Identifier,
|
||||
Flag Names: IsBeforeComma, Identifier,
|
||||
String: p1,
|
||||
Whole String: p1,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000011000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, AfterComma, Identifier,
|
||||
Flag Names: IsBeforeComma, IsAfterComma, Identifier,
|
||||
String: p2,
|
||||
Whole String: p2,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000001000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: AfterComma, Identifier,
|
||||
Flag Names: IsAfterComma, Identifier,
|
||||
String: p3,
|
||||
Whole String: p3,
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, Identifier,
|
||||
Flag Names: IsBeforeComma, Identifier,
|
||||
String: e1,
|
||||
Whole String: e1,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000011000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, AfterComma, Identifier,
|
||||
Flag Names: IsBeforeComma, IsAfterComma, Identifier,
|
||||
String: e2,
|
||||
Whole String: e2,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000001000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: AfterComma, Identifier,
|
||||
Flag Names: IsAfterComma, Identifier,
|
||||
String: e3,
|
||||
Whole String: e3,
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110011000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, BeforeComma, AfterComma,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, IsBeforeComma, IsAfterComma,
|
||||
Tag: @tag_with_params
|
||||
Tag Children{
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, Identifier,
|
||||
Flag Names: IsBeforeComma, Identifier,
|
||||
String: p1,
|
||||
Whole String: p1,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000011000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, AfterComma, Identifier,
|
||||
Flag Names: IsBeforeComma, IsAfterComma, Identifier,
|
||||
String: p2,
|
||||
Whole String: p2,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000001000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: AfterComma, Identifier,
|
||||
Flag Names: IsAfterComma, Identifier,
|
||||
String: p3,
|
||||
Whole String: p3,
|
||||
}
|
||||
@@ -140,45 +140,45 @@ Node {
|
||||
Tag: @tag2_with_params
|
||||
Tag Children{
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, Identifier,
|
||||
Flag Names: IsBeforeComma, Identifier,
|
||||
String: p,
|
||||
Whole String: p,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000011000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, AfterComma, Identifier,
|
||||
Flag Names: IsBeforeComma, IsAfterComma, Identifier,
|
||||
String: pp,
|
||||
Whole String: pp,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000001000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: AfterComma, Identifier,
|
||||
Flag Names: IsAfterComma, Identifier,
|
||||
String: ppp,
|
||||
Whole String: ppp,
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000010000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, Identifier,
|
||||
Flag Names: IsBeforeComma, Identifier,
|
||||
String: e1,
|
||||
Whole String: e1,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000011000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BeforeComma, AfterComma, Identifier,
|
||||
Flag Names: IsBeforeComma, IsAfterComma, Identifier,
|
||||
String: e2,
|
||||
Whole String: e2,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000001000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: AfterComma, Identifier,
|
||||
Flag Names: IsAfterComma, Identifier,
|
||||
String: e3,
|
||||
Whole String: e3,
|
||||
}
|
||||
@@ -186,27 +186,27 @@ Node {
|
||||
}
|
||||
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, Identifier,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, Identifier,
|
||||
String: empty,
|
||||
Whole String: empty,
|
||||
Tag: @empty_set
|
||||
}
|
||||
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110000000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight,
|
||||
Flag Names: HasBraceLeft, HasBraceRight,
|
||||
Tag: @tagged_unnamed_set
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight, Identifier,
|
||||
Flag Names: HasBraceLeft, HasBraceRight, Identifier,
|
||||
String: a_label,
|
||||
Whole String: a_label,
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: unnamed_set_element,
|
||||
@@ -216,33 +216,33 @@ Node {
|
||||
}
|
||||
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000110000000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: BraceLeft, BraceRight,
|
||||
Flag Names: HasBraceLeft, HasBraceRight,
|
||||
Tag: @showcase_mixed_set_scoping
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 1001000010000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: ParenLeft, BracketRight, BeforeComma,
|
||||
Flag Names: HasParenLeft, HasBracketRight, IsBeforeComma,
|
||||
String: +,
|
||||
Whole String: +,
|
||||
Tag: @symbol_label
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000010000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Numeric,
|
||||
String: 1,
|
||||
Whole String: 1,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000010000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Numeric,
|
||||
String: 2,
|
||||
Whole String: 2,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000010000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Numeric,
|
||||
String: 3,
|
||||
@@ -250,28 +250,28 @@ Node {
|
||||
}
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0110000011000000000000000000000000000000000000000000000000000000,
|
||||
Flag Names: ParenRight, BracketLeft, BeforeComma, AfterComma,
|
||||
Flag Names: HasParenRight, HasBracketLeft, IsBeforeComma, IsAfterComma,
|
||||
String: *,
|
||||
Whole String: *,
|
||||
Tag: @symbol_label
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: x,
|
||||
Whole String: x,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: y,
|
||||
Whole String: y,
|
||||
}
|
||||
Node {
|
||||
Kind: Label,
|
||||
Kind: Main,
|
||||
Flags: 0000000000000001000000000000000000000000000000000000000000000000,
|
||||
Flag Names: Identifier,
|
||||
String: z,
|
||||
|
||||
@@ -16,7 +16,7 @@ static void Print(FILE* file, int indent_count, char* fmt, ...) {
|
||||
|
||||
static void PrintNode(MD_Node* node, FILE* file, int indent_count) {
|
||||
Print(file, indent_count, "Node {\n");
|
||||
Print(file, indent_count+1, "Kind: %.*s,\n", MD_StringExpand(MD_StringFromNodeKind(node->kind)));
|
||||
Print(file, indent_count+1, "Kind: %.*s,\n", MD_S8VArg(MD_StringFromNodeKind(node->kind)));
|
||||
|
||||
int flags_bits = sizeof(node->flags)*8;
|
||||
char binary_flags[sizeof(node->flags)*8+1];
|
||||
@@ -32,14 +32,14 @@ static void PrintNode(MD_Node* node, FILE* file, int indent_count) {
|
||||
Print(file, indent_count+1, "Flags: %s,\n", binary_flags);
|
||||
Print(file, indent_count+1, "Flag Names: ", binary_flags);
|
||||
MD_String8List flags_list = MD_StringListFromNodeFlags(node->flags);
|
||||
MD_String8 flag_names = MD_JoinStringList(flags_list, MD_S8CString(", "));
|
||||
fprintf(file, "%.*s,\n", MD_StringExpand(flag_names));
|
||||
MD_String8 flag_names = MD_S8ListJoin(flags_list, MD_S8CString(", "));
|
||||
fprintf(file, "%.*s,\n", MD_S8VArg(flag_names));
|
||||
|
||||
if(node->string.size > 0) Print(file, indent_count+1, "String: %.*s,\n", MD_StringExpand(node->string));
|
||||
if(node->whole_string.size > 0) Print(file, indent_count+1, "Whole String: %.*s,\n", MD_StringExpand(node->whole_string));
|
||||
if(node->string.size > 0) Print(file, indent_count+1, "String: %.*s,\n", MD_S8VArg(node->string));
|
||||
if(node->raw_string.size > 0) Print(file, indent_count+1, "Whole String: %.*s,\n", MD_S8VArg(node->raw_string));
|
||||
if (node->first_tag->kind != MD_NodeKind_Nil) {
|
||||
for (MD_EachNode(tag, node->first_tag)) {
|
||||
Print(file, indent_count+1, "Tag: @%.*s\n", MD_StringExpand(tag->string));
|
||||
Print(file, indent_count+1, "Tag: @%.*s\n", MD_S8VArg(tag->string));
|
||||
if (tag->first_child->kind != MD_NodeKind_Nil) {
|
||||
Print(file, indent_count+2, "Tag Children{\n");
|
||||
for (MD_EachNode(arg, tag->first_child)) {
|
||||
@@ -63,15 +63,15 @@ int main(int argument_count, char **arguments)
|
||||
for(int i = 1; i < argument_count; i += 1)
|
||||
{
|
||||
MD_Node *root = MD_ParseWholeFile(MD_S8CString(arguments[i])).node;
|
||||
MD_PushReference(list, root);
|
||||
MD_PushNewReference(list, root);
|
||||
}
|
||||
|
||||
for(MD_EachNode(ref, list->first_child))
|
||||
{
|
||||
MD_Node *root = MD_Deref(ref);
|
||||
MD_String8 code_filename = MD_ChopExtension(MD_SkipFolder(root->string));
|
||||
MD_String8 info_filename = MD_PushStringF("parsed_%.*s.txt", MD_StringExpand(code_filename));
|
||||
printf("Parse Input -> Output: %.*s -> %.*s\n", MD_StringExpand(code_filename), MD_StringExpand(info_filename));
|
||||
MD_Node *root = MD_NodeFromReference(ref);
|
||||
MD_String8 code_filename = MD_PathChopLastPeriod(MD_PathSkipLastSlash(root->string));
|
||||
MD_String8 info_filename = MD_S8Fmt("parsed_%.*s.txt", MD_S8VArg(code_filename));
|
||||
printf("Parse Input -> Output: %.*s -> %.*s\n", MD_S8VArg(code_filename), MD_S8VArg(info_filename));
|
||||
|
||||
FILE* file = fopen((char *)info_filename.str, "wb");
|
||||
for(MD_EachNode(node, root->first_child))
|
||||
|
||||
@@ -7,14 +7,14 @@ int main(int argument_count, char **arguments)
|
||||
for(int i = 1; i < argument_count; i += 1)
|
||||
{
|
||||
MD_Node *root = MD_ParseWholeFile(MD_S8CString(arguments[i])).node;
|
||||
MD_PushReference(list, root);
|
||||
MD_PushNewReference(list, root);
|
||||
}
|
||||
|
||||
for(MD_EachNodeRef(root, list->first_child))
|
||||
{
|
||||
for(MD_EachNode(node, root->first_child))
|
||||
{
|
||||
MD_OutputTree(stdout, node, 0);
|
||||
MD_DebugOutputTree(stdout, node, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,18 +26,15 @@
|
||||
<div class="page_content">
|
||||
<div class="standalone_link_container"><a class="link" href="blog_main.html">← Back</a></div><h1 class="title">Test Blog #1</h1><h2 class="subtitle">This is my test blog.</h2><h3 class="date">30 November 2020</h3><h2 class="subtitle">Section 1</h2>
|
||||
<p class="paragraph">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut ornare neque, vitae finibus leo. Praesent pulvinar, urna id lobortis iaculis, velit turpis luctus tortor, quis malesuada neque neque vitae turpis. Phasellus id molestie elit. Sed elementum ipsum a ligula semper, at varius augue rutrum. Pellentesque fringilla, orci nec fringilla finibus, turpis lacus vehicula elit, nec bibendum magna est quis massa. Aliquam efficitur facilisis nibh, ut sodales sapien scelerisque nec. Integer justo sem, pellentesque et ante imperdiet, interdum placerat sem.
|
||||
|
||||
Nunc hendrerit lobortis commodo. Morbi felis quam, fermentum vitae libero vitae, fermentum sodales quam. Nulla bibendum tellus quis lorem sollicitudin pretium. Etiam commodo ex eget aliquet porta. In sit amet dui eleifend, mattis sem nec, tristique erat. Morbi malesuada fringilla bibendum. Integer odio ex, cursus a sodales quis, vehicula non dolor.
|
||||
|
||||
Praesent vitae pharetra felis. Curabitur non ex non nunc pretium feugiat eu sit amet turpis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean blandit ante leo. Vivamus iaculis mi vel sem tincidunt maximus. Aenean elementum ipsum non laoreet semper. Morbi non felis interdum lectus pulvinar mollis id non purus. Nullam eu ipsum ut turpis aliquam feugiat at non tellus. Suspendisse ornare erat quis enim ullamcorper, at rhoncus nulla suscipit.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut ornare neque, vitae finibus leo. Praesent pulvinar, urna id lobortis iaculis, velit turpis luctus tortor, quis malesuada neque neque vitae turpis. Phasellus id molestie elit. Sed elementum ipsum a ligula semper, at varius augue rutrum. Pellentesque fringilla, orci nec fringilla finibus, turpis lacus vehicula elit, nec bibendum magna est quis massa. Aliquam efficitur facilisis nibh, ut sodales sapien scelerisque nec. Integer justo sem, pellentesque et ante imperdiet, interdum placerat sem.</p>
|
||||
<p class="paragraph">Nunc hendrerit lobortis commodo. Morbi felis quam, fermentum vitae libero vitae, fermentum sodales quam. Nulla bibendum tellus quis lorem sollicitudin pretium. Etiam commodo ex eget aliquet porta. In sit amet dui eleifend, mattis sem nec, tristique erat. Morbi malesuada fringilla bibendum. Integer odio ex, cursus a sodales quis, vehicula non dolor.</p>
|
||||
<p class="paragraph">Praesent vitae pharetra felis. Curabitur non ex non nunc pretium feugiat eu sit amet turpis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean blandit ante leo. Vivamus iaculis mi vel sem tincidunt maximus. Aenean elementum ipsum non laoreet semper. Morbi non felis interdum lectus pulvinar mollis id non purus. Nullam eu ipsum ut turpis aliquam feugiat at non tellus. Suspendisse ornare erat quis enim ullamcorper, at rhoncus nulla suscipit.
|
||||
</p>
|
||||
<div class="img_container"><img class="img" src="test.png"></img></div>
|
||||
<h2 class="subtitle">Section 2</h2>
|
||||
<p class="paragraph">
|
||||
Aliquam quis diam at sem interdum imperdiet. Nunc imperdiet ligula tempus nibh semper mattis. Suspendisse fringilla molestie semper. Sed felis dolor, vehicula et tempus sed, porttitor finibus lacus. Pellentesque egestas ex finibus, facilisis tellus suscipit, accumsan turpis. Ut imperdiet vitae nisl eget vestibulum. Donec eu bibendum erat, id maximus magna. Vivamus quis rhoncus justo. Morbi eget commodo lorem, vulputate varius ipsum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer accumsan, sem vel rutrum cursus, odio enim sodales leo, sit amet rutrum odio purus at nisi. Fusce iaculis ante id nunc volutpat tincidunt. Duis nec tincidunt ipsum. Fusce vitae odio ac velit sollicitudin maximus. Vestibulum ante dui, varius auctor ante eu, gravida laoreet justo.
|
||||
|
||||
Vivamus dignissim mauris nec turpis convallis, vitae pellentesque sapien faucibus. Phasellus eu euismod elit, sit amet vehicula diam. Curabitur sit amet leo magna. In est erat, congue vel euismod id, venenatis vitae mauris. Vestibulum sit amet leo eget leo ornare feugiat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus at efficitur ex, a mattis lorem. Maecenas blandit tincidunt tortor vel cursus. In in purus a nisi pretium venenatis in ut lacus. Maecenas venenatis rutrum laoreet. Donec aliquam leo vel risus cursus, placerat pretium lacus fringilla. Suspendisse ut porttitor mauris.
|
||||
Aliquam quis diam at sem interdum imperdiet. Nunc imperdiet ligula tempus nibh semper mattis. Suspendisse fringilla molestie semper. Sed felis dolor, vehicula et tempus sed, porttitor finibus lacus. Pellentesque egestas ex finibus, facilisis tellus suscipit, accumsan turpis. Ut imperdiet vitae nisl eget vestibulum. Donec eu bibendum erat, id maximus magna. Vivamus quis rhoncus justo. Morbi eget commodo lorem, vulputate varius ipsum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer accumsan, sem vel rutrum cursus, odio enim sodales leo, sit amet rutrum odio purus at nisi. Fusce iaculis ante id nunc volutpat tincidunt. Duis nec tincidunt ipsum. Fusce vitae odio ac velit sollicitudin maximus. Vestibulum ante dui, varius auctor ante eu, gravida laoreet justo.</p>
|
||||
<p class="paragraph">Vivamus dignissim mauris nec turpis convallis, vitae pellentesque sapien faucibus. Phasellus eu euismod elit, sit amet vehicula diam. Curabitur sit amet leo magna. In est erat, congue vel euismod id, venenatis vitae mauris. Vestibulum sit amet leo eget leo ornare feugiat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus at efficitur ex, a mattis lorem. Maecenas blandit tincidunt tortor vel cursus. In in purus a nisi pretium venenatis in ut lacus. Maecenas venenatis rutrum laoreet. Donec aliquam leo vel risus cursus, placerat pretium lacus fringilla. Suspendisse ut porttitor mauris.
|
||||
</p>
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/BjdY1eXB6cY" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
<h2 class="subtitle">Section 3</h2>
|
||||
|
||||
@@ -26,11 +26,9 @@
|
||||
<div class="page_content">
|
||||
<div class="standalone_link_container"><a class="link" href="blog_main.html">← Back</a></div><h1 class="title">Hello, Again!</h1><h2 class="subtitle">This is another test blog.</h2><h3 class="date">28 November 2020</h3><h2 class="subtitle">Section 1</h2>
|
||||
<p class="paragraph">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut ornare neque, vitae finibus leo. Praesent pulvinar, urna id lobortis iaculis, velit turpis luctus tortor, quis malesuada neque neque vitae turpis. Phasellus id molestie elit. Sed elementum ipsum a ligula semper, at varius augue rutrum. Pellentesque fringilla, orci nec fringilla finibus, turpis lacus vehicula elit, nec bibendum magna est quis massa. Aliquam efficitur facilisis nibh, ut sodales sapien scelerisque nec. Integer justo sem, pellentesque et ante imperdiet, interdum placerat sem.
|
||||
|
||||
Nunc hendrerit lobortis commodo. Morbi felis quam, fermentum vitae libero vitae, fermentum sodales quam. Nulla bibendum tellus quis lorem sollicitudin pretium. Etiam commodo ex eget aliquet porta. In sit amet dui eleifend, mattis sem nec, tristique erat. Morbi malesuada fringilla bibendum. Integer odio ex, cursus a sodales quis, vehicula non dolor.
|
||||
|
||||
Praesent vitae pharetra felis. Curabitur non ex non nunc pretium feugiat eu sit amet turpis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean blandit ante leo. Vivamus iaculis mi vel sem tincidunt maximus. Aenean elementum ipsum non laoreet semper. Morbi non felis interdum lectus pulvinar mollis id non purus. Nullam eu ipsum ut turpis aliquam feugiat at non tellus. Suspendisse ornare erat quis enim ullamcorper, at rhoncus nulla suscipit.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut ornare neque, vitae finibus leo. Praesent pulvinar, urna id lobortis iaculis, velit turpis luctus tortor, quis malesuada neque neque vitae turpis. Phasellus id molestie elit. Sed elementum ipsum a ligula semper, at varius augue rutrum. Pellentesque fringilla, orci nec fringilla finibus, turpis lacus vehicula elit, nec bibendum magna est quis massa. Aliquam efficitur facilisis nibh, ut sodales sapien scelerisque nec. Integer justo sem, pellentesque et ante imperdiet, interdum placerat sem.</p>
|
||||
<p class="paragraph">Nunc hendrerit lobortis commodo. Morbi felis quam, fermentum vitae libero vitae, fermentum sodales quam. Nulla bibendum tellus quis lorem sollicitudin pretium. Etiam commodo ex eget aliquet porta. In sit amet dui eleifend, mattis sem nec, tristique erat. Morbi malesuada fringilla bibendum. Integer odio ex, cursus a sodales quis, vehicula non dolor.</p>
|
||||
<p class="paragraph">Praesent vitae pharetra felis. Curabitur non ex non nunc pretium feugiat eu sit amet turpis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean blandit ante leo. Vivamus iaculis mi vel sem tincidunt maximus. Aenean elementum ipsum non laoreet semper. Morbi non felis interdum lectus pulvinar mollis id non purus. Nullam eu ipsum ut turpis aliquam feugiat at non tellus. Suspendisse ornare erat quis enim ullamcorper, at rhoncus nulla suscipit.
|
||||
</p>
|
||||
<div class="img_container"><img class="img" src="test.png"></img></div>
|
||||
</div>
|
||||
|
||||
@@ -34,23 +34,23 @@ int main(int argument_count, char **arguments)
|
||||
{
|
||||
|
||||
//~ NOTE(rjf): Parse command line arguments.
|
||||
MD_CommandLine cmdln = MD_CommandLineFromOptions(MD_StringListFromArgCV(argument_count, arguments));
|
||||
MD_String8 site_info_path = MD_JoinStringList(MD_CommandLineOptionValues(cmdln, MD_S8Lit("siteinfo")), MD_S8Lit(""));
|
||||
MD_String8 page_dir_path = MD_JoinStringList(MD_CommandLineOptionValues(cmdln, MD_S8Lit("pagedir")), MD_S8Lit(""));
|
||||
if(!MD_CommandLineOptionPassed(cmdln, MD_S8Lit("siteinfo")) ||
|
||||
!MD_CommandLineOptionPassed(cmdln, MD_S8Lit("pagedir")))
|
||||
MD_CmdLine cmdln = MD_MakeCmdLineFromOptions(MD_StringListFromArgCV(argument_count, arguments));
|
||||
MD_String8 site_info_path = MD_S8ListJoin(MD_CmdLineValuesFromString(cmdln, MD_S8Lit("siteinfo")), MD_S8Lit(""));
|
||||
MD_String8 page_dir_path = MD_S8ListJoin(MD_CmdLineValuesFromString(cmdln, MD_S8Lit("pagedir")), MD_S8Lit(""));
|
||||
if(!MD_CmdLineB32FromString(cmdln, MD_S8Lit("siteinfo")) ||
|
||||
!MD_CmdLineB32FromString(cmdln, MD_S8Lit("pagedir")))
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s --siteinfo <path to site info file> --pagedir <path to directory with pages> ...\n", arguments[0]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
//~ NOTE(rjf): Load JS.
|
||||
MD_String8 js_string = MD_LoadEntireFile(MD_PushStringF("%.*s/site.js", MD_StringExpand(page_dir_path)));
|
||||
MD_String8 js_string = MD_LoadEntireFile(MD_S8Fmt("%.*s/site.js", MD_S8VArg(page_dir_path)));
|
||||
|
||||
//~ NOTE(rjf): Parse site info.
|
||||
SiteInfo site_info = {0};
|
||||
{
|
||||
printf("Parsing site metadata at \"%.*s\"...\n", MD_StringExpand(site_info_path));
|
||||
printf("Parsing site metadata at \"%.*s\"...\n", MD_S8VArg(site_info_path));
|
||||
MD_Node *site_info_file = MD_ParseWholeFile(site_info_path).node;
|
||||
site_info = ParseSiteInfo(site_info_file);
|
||||
}
|
||||
@@ -58,23 +58,23 @@ int main(int argument_count, char **arguments)
|
||||
//~ NOTE(rjf): Parse pages.
|
||||
MD_Node *root_list = MD_MakeList();
|
||||
{
|
||||
printf("Searching for site pages at \"%.*s\"...\n", MD_StringExpand(page_dir_path));
|
||||
printf("Searching for site pages at \"%.*s\"...\n", MD_S8VArg(page_dir_path));
|
||||
MD_FileInfo file_info = {0};
|
||||
for(MD_FileIter it = {0}; MD_FileIterIncrement(&it, page_dir_path, &file_info);)
|
||||
{
|
||||
if(MD_StringMatch(MD_ExtensionFromPath(file_info.filename), MD_S8Lit("md"), MD_MatchFlag_CaseInsensitive) &&
|
||||
!MD_StringMatch(MD_SkipFolder(MD_ChopExtension(file_info.filename)),
|
||||
MD_SkipFolder(MD_ChopExtension(site_info_path)),
|
||||
MD_MatchFlag_CaseInsensitive |
|
||||
MD_MatchFlag_SlashInsensitive))
|
||||
if(MD_S8Match(MD_PathSkipLastPeriod(file_info.filename), MD_S8Lit("md"), MD_StringMatchFlag_CaseInsensitive) &&
|
||||
!MD_S8Match(MD_PathSkipLastSlash(MD_PathChopLastPeriod(file_info.filename)),
|
||||
MD_PathSkipLastSlash(MD_PathChopLastPeriod(site_info_path)),
|
||||
MD_StringMatchFlag_CaseInsensitive |
|
||||
MD_StringMatchFlag_SlashInsensitive))
|
||||
{
|
||||
printf("Processing site page at \"%.*s\"...\n", MD_StringExpand(file_info.filename));
|
||||
MD_String8 folder = MD_FolderFromPath(page_dir_path);
|
||||
MD_String8 path = MD_PushStringF("%.*s/%.*s",
|
||||
MD_StringExpand(folder),
|
||||
MD_StringExpand(file_info.filename));
|
||||
printf("Processing site page at \"%.*s\"...\n", MD_S8VArg(file_info.filename));
|
||||
MD_String8 folder = MD_PathChopLastSlash(page_dir_path);
|
||||
MD_String8 path = MD_S8Fmt("%.*s/%.*s",
|
||||
MD_S8VArg(folder),
|
||||
MD_S8VArg(file_info.filename));
|
||||
MD_Node *node = MD_ParseWholeFile(path).node;
|
||||
MD_PushReference(root_list, node);
|
||||
MD_PushNewReference(root_list, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,10 +84,10 @@ int main(int argument_count, char **arguments)
|
||||
{
|
||||
for(MD_EachNode(ref, root_list->first_child))
|
||||
{
|
||||
MD_Node *root = MD_Deref(ref);
|
||||
MD_Node *root = MD_NodeFromReference(ref);
|
||||
for(MD_EachNode(node, root->first_child))
|
||||
{
|
||||
if(!MD_NodeIsNil(node->first_child) && MD_StringMatch(node->string, MD_S8Lit("index"), MD_MatchFlag_CaseInsensitive))
|
||||
if(!MD_NodeIsNil(node->first_child) && MD_S8Match(node->string, MD_S8Lit("index"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
for(MD_EachNode(index_string, node->first_child))
|
||||
{
|
||||
@@ -106,7 +106,7 @@ int main(int argument_count, char **arguments)
|
||||
FILE *file = fopen("style.css", "wb");
|
||||
if(file)
|
||||
{
|
||||
fprintf(file, "%.*s", MD_StringExpand(site_info.style->string));
|
||||
fprintf(file, "%.*s", MD_S8VArg(site_info.style->string));
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ int main(int argument_count, char **arguments)
|
||||
FILE *file = fopen("site.js", "wb");
|
||||
if(file)
|
||||
{
|
||||
fprintf(file, "%.*s", MD_StringExpand(js_string));
|
||||
fprintf(file, "%.*s", MD_S8VArg(js_string));
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
@@ -124,11 +124,11 @@ int main(int argument_count, char **arguments)
|
||||
//~ NOTE(rjf): Generate files for all roots.
|
||||
for(MD_EachNode(ref, root_list->first_child))
|
||||
{
|
||||
MD_Node *root = MD_Deref(ref);
|
||||
MD_Node *root = MD_NodeFromReference(ref);
|
||||
PageInfo page_info = ParsePageInfo(root);
|
||||
|
||||
MD_String8 name_without_extension = MD_SkipFolder(MD_ChopExtension(root->string));
|
||||
FILE *file = fopen(MD_PushStringF("%.*s.html", MD_StringExpand(name_without_extension)).str, "wb");
|
||||
MD_String8 name_without_extension = MD_PathSkipLastSlash(MD_PathChopLastPeriod(root->string));
|
||||
FILE *file = fopen(MD_S8Fmt("%.*s.html", MD_S8VArg(name_without_extension)).str, "wb");
|
||||
if(file)
|
||||
{
|
||||
fprintf(file, "<!DOCTYPE html>\n");
|
||||
@@ -144,31 +144,31 @@ int main(int argument_count, char **arguments)
|
||||
{
|
||||
fprintf(file, "<head>\n");
|
||||
fprintf(file, "<meta charset=\"utf-8\">\n");
|
||||
fprintf(file, "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"author\" content=\"%.*s\">\n", MD_StringExpand(author));
|
||||
fprintf(file, "<meta property=\"og:title\" content=\"%.*s\">\n", MD_StringExpand(title));
|
||||
fprintf(file, "<meta name=\"twitter:title\" content=\"%.*s\">\n", MD_StringExpand(title));
|
||||
fprintf(file, "<link rel=\"canonical\" href=\"%.*s\">\n", MD_StringExpand(url));
|
||||
fprintf(file, "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"author\" content=\"%.*s\">\n", MD_S8VArg(author));
|
||||
fprintf(file, "<meta property=\"og:title\" content=\"%.*s\">\n", MD_S8VArg(title));
|
||||
fprintf(file, "<meta name=\"twitter:title\" content=\"%.*s\">\n", MD_S8VArg(title));
|
||||
fprintf(file, "<link rel=\"canonical\" href=\"%.*s\">\n", MD_S8VArg(url));
|
||||
fprintf(file, "<meta property=\"og:type\" content=\"website\">\n");
|
||||
fprintf(file, "<meta property=\"og:url\" content=\"%.*s\">\n", MD_StringExpand(url));
|
||||
fprintf(file, "<meta property=\"og:site_name\" content=\"%.*s\">\n", MD_StringExpand(site_title));
|
||||
fprintf(file, "<meta property=\"og:url\" content=\"%.*s\">\n", MD_S8VArg(url));
|
||||
fprintf(file, "<meta property=\"og:site_name\" content=\"%.*s\">\n", MD_S8VArg(site_title));
|
||||
fprintf(file, "<meta name=\"twitter:card\" content=\"summary\">\n");
|
||||
fprintf(file, "<meta name=\"twitter:site\" content=\"%.*s\">\n", MD_StringExpand(twitter_handle));
|
||||
fprintf(file, "<meta name=\"twitter:site\" content=\"%.*s\">\n", MD_S8VArg(twitter_handle));
|
||||
fprintf(file, "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n");
|
||||
fprintf(file, "<script src=\"site.js\"></script>\n");
|
||||
if(title.size > 0)
|
||||
{
|
||||
if(site_title.size > 0)
|
||||
{
|
||||
fprintf(file, "<title>%.*s | %.*s</title>\n", MD_StringExpand(title), MD_StringExpand(site_title));
|
||||
fprintf(file, "<title>%.*s | %.*s</title>\n", MD_S8VArg(title), MD_S8VArg(site_title));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(file, "<title>%.*s</title>\n", MD_StringExpand(title));
|
||||
fprintf(file, "<title>%.*s</title>\n", MD_S8VArg(title));
|
||||
}
|
||||
}
|
||||
else if(site_title.size > 0)
|
||||
{
|
||||
fprintf(file, "<title>%.*s</title>\n", MD_StringExpand(site_title));
|
||||
fprintf(file, "<title>%.*s</title>\n", MD_S8VArg(site_title));
|
||||
}
|
||||
fprintf(file, "</head>\n");
|
||||
}
|
||||
@@ -180,7 +180,7 @@ int main(int argument_count, char **arguments)
|
||||
// NOTE(rjf): Generate header.
|
||||
if(site_info.header)
|
||||
{
|
||||
fprintf(file, "%.*s", MD_StringExpand(site_info.header->string));
|
||||
fprintf(file, "%.*s", MD_S8VArg(site_info.header->string));
|
||||
}
|
||||
|
||||
fprintf(file, "<div class=\"page_content\">\n");
|
||||
@@ -188,26 +188,26 @@ int main(int argument_count, char **arguments)
|
||||
// NOTE(rjf): Parent page back button.
|
||||
if(page_info.parent)
|
||||
{
|
||||
fprintf(file, "<div class=\"standalone_link_container\"><a class=\"link\" href=\"%.*s.html\">← Back</a></div>", MD_StringExpand(page_info.parent->string));
|
||||
fprintf(file, "<div class=\"standalone_link_container\"><a class=\"link\" href=\"%.*s.html\">← Back</a></div>", MD_S8VArg(page_info.parent->string));
|
||||
}
|
||||
|
||||
// NOTE(rjf): Banner.
|
||||
if(page_info.header_image)
|
||||
{
|
||||
fprintf(file, "<div class=\"page_banner\" style=\"background-image: url('%.*s');\"></div>",
|
||||
MD_StringExpand(page_info.header_image->string));
|
||||
MD_S8VArg(page_info.header_image->string));
|
||||
}
|
||||
|
||||
// NOTE(rjf): Title.
|
||||
if(title.size > 0)
|
||||
{
|
||||
fprintf(file, "<h1 class=\"title\">%.*s</h1>", MD_StringExpand(title));
|
||||
fprintf(file, "<h1 class=\"title\">%.*s</h1>", MD_S8VArg(title));
|
||||
}
|
||||
|
||||
// NOTE(rjf): Main description/subtitle.
|
||||
if(page_info.desc)
|
||||
{
|
||||
fprintf(file, "<h2 class=\"subtitle\">%.*s</h2>", MD_StringExpand(page_info.desc->string));
|
||||
fprintf(file, "<h2 class=\"subtitle\">%.*s</h2>", MD_S8VArg(page_info.desc->string));
|
||||
}
|
||||
|
||||
// NOTE(rjf): Date.
|
||||
@@ -216,7 +216,7 @@ int main(int argument_count, char **arguments)
|
||||
MD_String8 date_string = MakeDateString(page_info.date);
|
||||
if(date_string.size > 0)
|
||||
{
|
||||
fprintf(file, "<h3 class=\"date\">%.*s</h3>", MD_StringExpand(date_string));
|
||||
fprintf(file, "<h3 class=\"date\">%.*s</h3>", MD_S8VArg(date_string));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ int main(int argument_count, char **arguments)
|
||||
// NOTE(rjf): Generate footer.
|
||||
if(site_info.footer)
|
||||
{
|
||||
fprintf(file, "%.*s", MD_StringExpand(site_info.footer->string));
|
||||
fprintf(file, "%.*s", MD_S8VArg(site_info.footer->string));
|
||||
}
|
||||
|
||||
fprintf(file, "</body>\n");
|
||||
@@ -254,23 +254,23 @@ ParsePageInfo(MD_Node *page)
|
||||
{
|
||||
if(!MD_NodeIsNil(node->first_child))
|
||||
{
|
||||
if(MD_StringMatch(node->string, MD_S8Lit("title"), MD_MatchFlag_CaseInsensitive))
|
||||
if(MD_S8Match(node->string, MD_S8Lit("title"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.title = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("desc"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("desc"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.desc = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("date"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("date"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.date = node;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("parent"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("parent"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.parent = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("header_image"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("header_image"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.header_image = node->first_child;
|
||||
}
|
||||
@@ -287,39 +287,39 @@ ParseSiteInfo(MD_Node *site)
|
||||
{
|
||||
if(!MD_NodeIsNil(node->first_child))
|
||||
{
|
||||
if(MD_StringMatch(node->string, MD_S8Lit("title"), MD_MatchFlag_CaseInsensitive))
|
||||
if(MD_S8Match(node->string, MD_S8Lit("title"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.title = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("desc"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("desc"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.desc = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("canonical_url"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("canonical_url"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.canonical_url = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("author"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("author"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.author = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("twitter_handle"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("twitter_handle"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.twitter_handle = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("link_dictionary"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("link_dictionary"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.link_dictionary = node;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("header"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("header"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.header = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("footer"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("footer"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.footer = node->first_child;
|
||||
}
|
||||
else if(MD_StringMatch(node->string, MD_S8Lit("style"), MD_MatchFlag_CaseInsensitive))
|
||||
else if(MD_S8Match(node->string, MD_S8Lit("style"), MD_StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
info.style = node->first_child;
|
||||
}
|
||||
@@ -362,10 +362,10 @@ MakeDateString(MD_Node *date)
|
||||
MD_u64 month_idx = MD_U64FromString(month->string, 10) - 1;
|
||||
if(month_idx >= 0 && month_idx < sizeof(month_names)/sizeof(month_names[0]))
|
||||
{
|
||||
result = MD_PushStringF("%.*s %s %.*s",
|
||||
MD_StringExpand(day->string),
|
||||
month_names[month_idx],
|
||||
MD_StringExpand(year->string));
|
||||
result = MD_S8Fmt("%.*s %s %.*s",
|
||||
MD_S8VArg(day->string),
|
||||
month_names[month_idx],
|
||||
MD_S8VArg(year->string));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -402,7 +402,7 @@ GeneratePageContent(MD_Map *index_table, SiteInfo *site_info, PageInfo *page_inf
|
||||
{
|
||||
MD_S8Lit("\n\n"),
|
||||
};
|
||||
MD_String8List strlist = MD_SplitString(node->string, sizeof(splits)/sizeof(splits[0]), splits);
|
||||
MD_String8List strlist = MD_S8Split(node->string, sizeof(splits)/sizeof(splits[0]), splits);
|
||||
|
||||
for(MD_String8Node *strnode = strlist.first; strnode; strnode = strnode->next)
|
||||
{
|
||||
@@ -411,31 +411,31 @@ GeneratePageContent(MD_Map *index_table, SiteInfo *site_info, PageInfo *page_inf
|
||||
{
|
||||
if(strnode->string.str[i] == '@')
|
||||
{
|
||||
MD_ParseResult parse = MD_ParseOneNode(MD_StringSubstring(strnode->string, i, strnode->string.size), 0);
|
||||
MD_ParseResult parse = MD_ParseOneNode(MD_S8Substring(strnode->string, i, strnode->string.size), 0);
|
||||
if(!MD_NodeIsNil(parse.node))
|
||||
{
|
||||
if(MD_NodeHasTag(node, MD_S8Lit("i"), 0))
|
||||
{
|
||||
fprintf(file, "<i>%.*s</i>", MD_StringExpand(parse.node->string));
|
||||
fprintf(file, "<i>%.*s</i>", MD_S8VArg(parse.node->string));
|
||||
}
|
||||
else if(MD_NodeHasTag(node, MD_S8Lit("b"), 0))
|
||||
{
|
||||
fprintf(file, "<strong>%.*s</strong>", MD_StringExpand(parse.node->string));
|
||||
fprintf(file, "<strong>%.*s</strong>", MD_S8VArg(parse.node->string));
|
||||
}
|
||||
else if(MD_NodeHasTag(node, MD_S8Lit("code"), 0))
|
||||
{
|
||||
fprintf(file, "<span class=\"inline_code\">%.*s</span>", MD_StringExpand(parse.node->string));
|
||||
fprintf(file, "<span class=\"inline_code\">%.*s</span>", MD_S8VArg(parse.node->string));
|
||||
}
|
||||
else if(MD_NodeHasTag(node, MD_S8Lit("link"), 0))
|
||||
{
|
||||
MD_Node *text = MD_ChildFromIndex(parse.node, 0);
|
||||
MD_Node *link = MD_ChildFromIndex(parse.node, 1);
|
||||
fprintf(file, "<a class=\"link\" href=\"%.*s\">%.*s</a>",
|
||||
MD_StringExpand(link->string),
|
||||
MD_StringExpand(text->string));
|
||||
MD_S8VArg(link->string),
|
||||
MD_S8VArg(text->string));
|
||||
}
|
||||
}
|
||||
i += parse.bytes_parsed - 1;
|
||||
i += parse.string_advance - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -449,12 +449,12 @@ GeneratePageContent(MD_Map *index_table, SiteInfo *site_info, PageInfo *page_inf
|
||||
{
|
||||
text = MD_ChildFromIndex(dict_link, 0);
|
||||
link = MD_ChildFromIndex(dict_link, 1);
|
||||
MD_String8 substring = MD_StringSubstring(strnode->string, i, i+text->string.size);
|
||||
if(MD_StringMatch(substring, text->string, 0))
|
||||
MD_String8 substring = MD_S8Substring(strnode->string, i, i+text->string.size);
|
||||
if(MD_S8Match(substring, text->string, 0))
|
||||
{
|
||||
fprintf(file, "<a class=\"link\" href=\"%.*s\">%.*s</a>",
|
||||
MD_StringExpand(link->string),
|
||||
MD_StringExpand(text->string));
|
||||
MD_S8VArg(link->string),
|
||||
MD_S8VArg(text->string));
|
||||
dict_word = 1;
|
||||
i += text->string.size-1;
|
||||
break;
|
||||
@@ -495,13 +495,13 @@ GeneratePageContent(MD_Map *index_table, SiteInfo *site_info, PageInfo *page_inf
|
||||
{
|
||||
MD_Node *src = MD_ChildFromIndex(node, 0);
|
||||
MD_Node *alt = MD_ChildFromIndex(node, 1);
|
||||
fprintf(file, "<div class=\"img_container\"><img class=\"img\" src=\"%.*s\"></img></div>\n", MD_StringExpand(src->string));
|
||||
fprintf(file, "<div class=\"img_container\"><img class=\"img\" src=\"%.*s\"></img></div>\n", MD_S8VArg(src->string));
|
||||
}
|
||||
else if(MD_NodeHasTag(node, MD_S8Lit("youtube"), 0))
|
||||
{
|
||||
MD_Node *id = MD_ChildFromIndex(node, 0);
|
||||
fprintf(file, "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/%.*s\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n",
|
||||
MD_StringExpand(id->string));
|
||||
MD_S8VArg(id->string));
|
||||
}
|
||||
else if(MD_NodeHasTag(node, MD_S8Lit("lister"), 0))
|
||||
{
|
||||
@@ -523,36 +523,36 @@ GeneratePageContent(MD_Map *index_table, SiteInfo *site_info, PageInfo *page_inf
|
||||
PageInfo info = ParsePageInfo(node);
|
||||
|
||||
MD_String8 filename = root->string;
|
||||
MD_String8 filename_no_ext = MD_ChopExtension(MD_SkipFolder(filename));
|
||||
MD_String8 link = MD_PushStringF("%.*s.html", MD_StringExpand(filename_no_ext));
|
||||
MD_String8 filename_no_ext = MD_PathChopLastPeriod(MD_PathSkipLastSlash(filename));
|
||||
MD_String8 link = MD_S8Fmt("%.*s.html", MD_S8VArg(filename_no_ext));
|
||||
MD_String8 name = info.title->string;
|
||||
MD_String8 date = MakeDateString(info.date);
|
||||
|
||||
fprintf(file, "<a class=\"lister_item_link\" href=\"%.*s\">\n", MD_StringExpand(link));
|
||||
fprintf(file, "<a class=\"lister_item_link\" href=\"%.*s\">\n", MD_S8VArg(link));
|
||||
fprintf(file, "<li class=\"lister_item\">\n");
|
||||
|
||||
if(info.header_image)
|
||||
{
|
||||
fprintf(file, "<div class=\"lister_item_img\" style=\"background-image:url('%.*s');\">",
|
||||
MD_StringExpand(info.header_image->string));
|
||||
MD_S8VArg(info.header_image->string));
|
||||
}
|
||||
|
||||
fprintf(file, "<div class=\"lister_item_text\">\n");
|
||||
fprintf(file, "<div class=\"lister_item_title\">\n");
|
||||
fprintf(file, "%.*s\n", MD_StringExpand(name));
|
||||
fprintf(file, "%.*s\n", MD_S8VArg(name));
|
||||
fprintf(file, "</div>\n");
|
||||
|
||||
if(date.size > 0)
|
||||
{
|
||||
fprintf(file, "<div class=\"lister_item_date\">\n");
|
||||
fprintf(file, "%.*s\n", MD_StringExpand(date));
|
||||
fprintf(file, "%.*s\n", MD_S8VArg(date));
|
||||
fprintf(file, "</div>\n");
|
||||
}
|
||||
|
||||
if(info.desc)
|
||||
{
|
||||
fprintf(file, "<div class=\"lister_item_desc\">\n");
|
||||
fprintf(file, "%.*s\n", MD_StringExpand(info.desc->string));
|
||||
fprintf(file, "%.*s\n", MD_S8VArg(info.desc->string));
|
||||
fprintf(file, "</div>\n");
|
||||
}
|
||||
if(info.header_image)
|
||||
|
||||
@@ -111,10 +111,12 @@ result = MakeValue_Number(left.number op right.number);\
|
||||
MD_Node *param = callee.node->first_child;
|
||||
for(MD_Node *arg_first = call->first_child; !MD_NodeIsNil(arg_first); param = param->next)
|
||||
{
|
||||
MD_Node *arg_last = MD_SeekNodeWithFlags(arg_first, MD_NodeFlag_AfterComma|MD_NodeFlag_AfterSemicolon);
|
||||
#if 0
|
||||
MD_Node *arg_last = MD_SeekNodeWithFlags(arg_first, MD_NodeFlag_IsAfterComma|MD_NodeFlag_IsAfterSemicolon);
|
||||
MD_C_Expr *expr = MD_C_ParseAsExpr(arg_first, arg_last);
|
||||
InsertValueToNamespace(&args_ns, param->string, EvaluateExpr(ns, expr));
|
||||
arg_first = arg_last->next;
|
||||
#endif
|
||||
}
|
||||
|
||||
args_ns.parent = top_level_ns;
|
||||
@@ -147,9 +149,11 @@ EvaluateScope(NamespaceNode *ns, MD_Node *code)
|
||||
NamespaceNode local_namespace = {0};
|
||||
local_namespace.parent = ns;
|
||||
|
||||
// TODO(rjf): fix this, using last instead of opl
|
||||
|
||||
for(MD_Node *first = code->first_child; !MD_NodeIsNil(first);)
|
||||
{
|
||||
MD_Node *last = MD_SeekNodeWithFlags(first, MD_NodeFlag_AfterSemicolon|MD_NodeFlag_AfterComma);
|
||||
MD_Node *opl = MD_NodeFromFlags(first->next, MD_NilNode(), MD_NodeFlag_IsAfterSemicolon|MD_NodeFlag_IsAfterComma);
|
||||
|
||||
//- rjf: declaration
|
||||
if(first == last && first->string.size != 0 && !MD_NodeIsNil(first->first_child))
|
||||
@@ -177,21 +181,21 @@ EvaluateScope(NamespaceNode *ns, MD_Node *code)
|
||||
int main(int argument_count, char **arguments)
|
||||
{
|
||||
//- rjf: parse command line
|
||||
MD_CommandLine cmdln = MD_CommandLineFromOptions(MD_StringListFromArgCV(argument_count, arguments));
|
||||
MD_CmdLine cmdln = MD_MakeCmdLineFromOptions(MD_StringListFromArgCV(argument_count, arguments));
|
||||
|
||||
//- rjf: parse all input files
|
||||
MD_Node *file_list = MD_MakeList();
|
||||
for(MD_String8Node *n = cmdln.inputs.first; n; n = n->next)
|
||||
{
|
||||
MD_ParseResult parse = MD_ParseWholeFile(n->string);
|
||||
MD_PushReference(file_list, parse.node);
|
||||
MD_PushNewReference(file_list, parse.node);
|
||||
}
|
||||
|
||||
//- rjf: gather top-level symbol map
|
||||
NamespaceNode global_ns_node = {0};
|
||||
for(MD_EachNode(file_ref, file_list->first_child))
|
||||
{
|
||||
MD_Node *file = MD_Deref(file_ref);
|
||||
MD_Node *file = MD_NodeFromReference(file_ref);
|
||||
for(MD_EachNode(top_level, file->first_child))
|
||||
{
|
||||
if(MD_NodeHasTag(top_level, MD_S8Lit("proc"), 0))
|
||||
@@ -234,7 +238,7 @@ int main(int argument_count, char **arguments)
|
||||
|
||||
case ValueKind_Procedure:
|
||||
{
|
||||
printf("[proc] %.*s\n", MD_StringExpand(result.node->string));
|
||||
printf("[proc] %.*s\n", MD_S8VArg(result.node->string));
|
||||
}break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user