-
Notifications
You must be signed in to change notification settings - Fork 5
/
22impl.c
91 lines (69 loc) · 2.5 KB
/
22impl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "common.h"
sNode*% top_level(char* buf, char* head, int head_sline, sInfo* info) version 93
{
if(!gComeC && buf === "impl") {
char* source_head = info.p;
var word = parse_word(info);
if(*info->p == '<') {
info->p++;
skip_spaces_and_lf();
info.generics_type_names.reset();
while(true) {
var generics_name = parse_word();
info.generics_type_names.push_back(clone generics_name);
if(*info->p == ',') {
info->p++;
skip_spaces_and_lf();
}
else if(*info->p == '>') {
info->p++;
skip_spaces_and_lf();
break;
}
else {
err_msg(info, "invalid character on impl (%c)", *info->p);
exit(2);
}
}
}
int pointer_num = 0;
while(*info->p == '*') {
info->p++;
skip_spaces_and_lf();
pointer_num++;
}
expected_next_character('{', info);
info->impl_type = new sType(word);
info->impl_type->mPointerNum = pointer_num;
while(*info->p != '}') {
parse_sharp();
char* head = info.p;
string buf = parse_word();
parse_sharp(info);
sNode*% node = top_level(buf, head, head_sline, info);
parse_sharp(info);
while(*info->p == ';') {
info->p++;
skip_spaces_and_lf();
}
parse_sharp(info);
if(node != null) {
node_compile(node).elif {
err_msg(info, "compiling is faield(Y)");
exit(2);
}
}
parse_sharp(info);
skip_spaces_and_lf();
}
expected_next_character('}');
info.generics_type_names.reset();
info->impl_type = null;
char* source_tail = info.p;
buffer*% header = new buffer();
header.append(source_head, source_tail - source_head);
add_come_code_at_come_header(info, "impl %s\n", header.to_string());
return (sNode*%)null;
}
return inherit(buf, head, head_sline, info);
}