Commit 701f1828 authored by William Bundy's avatar William Bundy

rituals build 104

parent 8b24285a
git add --all
git commit -m "rituals build 103"
git commit -m "rituals build 104"
git push
git push github
102
1475270798.931729
103
1475270810.487236
......@@ -174,119 +174,12 @@ int main(int argc, char** argv)
}
head->prev = last;
head = start;
do {
head = parse_dollarsign_instructions(head);
if(head->kind == Token_CompilerDirective && head->start[0] == 'i') {
parse_include_directive(&lex, head);
}
} while(head = head->next);
head = start;
do {
Token* next;
switch(head->kind) {
case Token_DollarSign:
head = parse_dollarsign_instructions(head);
break;
case Token_Ampersand:
next = head->next;
if(next && next->kind == Token_Ampersand) {
head->kind = Operator_LogicalAnd;
head->len++;
head->next = next->next;
}
break;
case Token_Pipe:
next = head->next;
if(next && next->kind == Token_Pipe) {
head->kind = Operator_LogicalOr;
head->len++;
head->next = next->next;
}
break;
case Token_Equals:
next = head->next;
if(next && next->kind == Token_Equals) {
head->kind = Operator_BooleanEquals;
head->len++;
head->next = next->next;
}
break;
case Token_ExclamationMark:
next = head->next;
if(next && next->kind == Token_Equals) {
head->kind = Operator_BooleanNotEquals;
head->len++;
head->next = next->next;
}
break;
case Token_GreaterThan:
next = head->next;
if(next && next->kind == Token_Equals) {
head->kind = Operator_BooleanGreaterEquals;
head->len++;
head->next = next->next;
}
break;
case Token_LessThan:
next = head->next;
if(next && next->kind == Token_Equals) {
head->kind = Operator_BooleanLessEquals;
head->len++;
head->next = next->next;
}
break;
case Token_Number:
parse_number_tokens(head);
break;
case Token_Minus:
next = head->next;
if(next && next->kind == Token_GreaterThan) {
head->kind = Operator_PtrMemberAccess;
head->len++;
head->next = next->next;
} else if(next && next->kind == Token_Minus) {
head->kind = Operator_Decrement;
head->len++;
head->next = next->next;
} else if(next && next->kind == Token_Number) {
Token_Kind prevkind = Token_Unknown;
if(head->prev != NULL) {
prevkind = head->prev->kind;
}
if(prevkind != Token_Number &&
prevkind != Token_Integer &&
prevkind != Token_Float &&
prevkind != Token_Identifier ) {
head->kind = Token_Number;
head->len += next->len;
head->next = next->next;
next = head->next;
parse_number_tokens(head);
}
}
break;
case Token_Plus:
next = head->next;
if(next && next->kind == Token_Plus) {
head->kind = Operator_Increment;
head->len++;
head->next = next->next;
}
default:
break;
}
} while(head = head->next);
parse_tokens(&lex, start);
Proc_Prototype* p = find_proc_prototypes(&lex, start, Work_Arena);
Struct_Def* structdef = find_struct_defs(&lex, start, Work_Arena);
fprintf(stderr, "Found %d procedures, %d structs \n", lex.procedures_count, lex.structs_count);
fprintf(stderr, "Found %d procedures, %d structs \n",
lex.procedures_count, lex.structs_count);
Struct_Def* s_head = structdef;
do {
......@@ -294,7 +187,8 @@ int main(int argc, char** argv)
printf("typedef struct %s %s;\n", s_head->name, s_head->name);
} while(s_head = s_head->next);
Struct_Def** all_structs = arena_push_array(Work_Arena, Struct_Def*, lex.structs_count + 16);
Struct_Def** all_structs = arena_push_array(Work_Arena,
Struct_Def*, lex.structs_count + 16);
s_head = structdef;
printf("enum Meta_Type\n {\n");
......@@ -302,7 +196,10 @@ int main(int argc, char** argv)
do {
if(s_head->name == NULL) continue;
start_temp_arena(Temp_Arena);
print_struct_names(s_head, -1, "Meta_Type", strlen("Meta_Type"), all_structs, &meta_index_counter, Temp_Arena);
print_struct_names(s_head, -1,
"Meta_Type", strlen("Meta_Type"),
all_structs, &meta_index_counter,
Temp_Arena);
end_temp_arena(Temp_Arena);
} while(s_head = s_head->next);
printf("};\n");
......@@ -315,39 +212,7 @@ int main(int argc, char** argv)
#if 1
do {
if(p->name == NULL) continue;
for(isize i = 0; i < p->decorators_count; ++i) {
printf("%s ", p->decorators[i]);
}
printf("%s(", p->name);
for(isize i = 0; i < p->args_count; ++i) {
Proc_Arg* a = p->args + i;
for(isize j = 0; j < a->count; ++j) {
printf("%s", a->terms[j]);
if(j == a->count - 1) {
if(a->defaults == NULL) {
if(i != p->args_count - 1) printf(", ");
} else {
printf(" %s", a->defaults);
if(i != p->args_count - 1) printf(" ");
}
} else {
printf(" ");
}
}
}
if(p->args_count != 0) {
if(p->args[p->args_count - 1].defaults == NULL)
printf(");");
else
printf(";");
}
printf("\n");
print_proc_prototype(p);
} while (p = p->next);
#endif
......
......@@ -640,6 +640,12 @@ void parse_tokens(Lexer* lex, Token* start)
}
void parse_sing(Token* t, int32 brace_level)
{
if(t->hash == hash_literal("sing")) {
fprintf(stderr, "[%d]", brace_level);
}
}
struct Proc_Arg
......@@ -669,11 +675,42 @@ struct Proc_Prototype
Proc_Prototype* next;
};
void parse_sing(Token* t, int32 brace_level)
void print_proc_prototype(Proc_Prototype* p)
{
if(t->hash == hash_literal("sing")) {
fprintf(stderr, "[%d]", brace_level);
if(p->name == NULL) continue;
for(isize i = 0; i < p->decorators_count; ++i) {
printf("%s ", p->decorators[i]);
}
printf("%s(", p->name);
for(isize i = 0; i < p->args_count; ++i) {
Proc_Arg* a = p->args + i;
for(isize j = 0; j < a->count; ++j) {
printf("%s", a->terms[j]);
if(j == a->count - 1) {
if(a->defaults == NULL) {
if(i != p->args_count - 1) printf(", ");
} else {
printf(" %s", a->defaults);
if(i != p->args_count - 1) printf(" ");
}
} else {
printf(" ");
}
}
}
if(p->args_count != 0) {
if(p->args[p->args_count - 1].defaults == NULL)
printf(");");
else
printf(";");
}
printf("\n");
}
Proc_Prototype* find_proc_prototypes(Lexer* lex, Token* start, Memory_Arena* arena)
......
......@@ -1207,7 +1207,7 @@ StructKind_Member src/metaprogram/metaprogram_parser.cpp /^ StructKind_Member$/;
StructKind_None src/metaprogram/metaprogram_parser.cpp /^ StructKind_None,$/;" e enum:Struct_Kind file:
StructKind_Struct src/metaprogram/metaprogram_parser.cpp /^ StructKind_Struct,$/;" e enum:Struct_Kind file:
StructKind_Union src/metaprogram/metaprogram_parser.cpp /^ StructKind_Union,$/;" e enum:Struct_Kind file:
StructMemberCapacity src/metaprogram/metaprogram_parser.cpp 867;" d file:
StructMemberCapacity src/metaprogram/metaprogram_parser.cpp 904;" d file:
Struct_Def src/metaprogram/metaprogram_parser.cpp /^struct Struct_Def$/;" s file:
Struct_Kind src/metaprogram/metaprogram_parser.cpp /^enum Struct_Kind$/;" g file:
Struct_Member src/metaprogram/metaprogram_parser.cpp /^typedef union Struct_Member Struct_Member;$/;" t typeref:union:Struct_Member file:
......@@ -2470,6 +2470,7 @@ prev src/metaprogram/metaprogram_parser.cpp /^ Token *prev, *next;$/;" m struct:
prev_time src/rituals_main.cpp /^ usize current_time = 0, prev_time = 0;$/;" m struct:Play_State file:
prev_time src/rituals_win32.cpp /^usize current_time = 0, prev_time = 0;$/;" v
print_indent src/metaprogram/metaprogram_parser.cpp /^void print_indent(int32 indent)$/;" f
print_proc_prototype src/metaprogram/metaprogram_parser.cpp /^void print_proc_prototype(Proc_Prototype* p)$/;" f
print_reflection_data src/metaprogram/metaprogram_parser.cpp /^void print_reflection_data(Struct_Def* def)$/;" f
print_struct src/metaprogram/metaprogram_parser.cpp /^void print_struct(Struct_Def* def, bool as_member_struct = false, int32 indent = 0)$/;" f
print_struct_names src/metaprogram/metaprogram_parser.cpp /^void print_struct_names(Struct_Def* def, isize index, char* prefix, isize prefix_len, Struct_Def** all_structs, isize* counter, Memory_Arena* arena)$/;" f
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment