-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgIdea.txt
53 lines (43 loc) · 1.16 KB
/
algIdea.txt
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
# The initial design idea for this light-weight front-end.
# Updated in 2017 Jun. 26 by Charles Chen.
multiDecl:
{
line: x,
[
{
col: xxx,
type: xxx
},
...
]
}
// assumption: decls in the same file sorted by lineNo, decls on same line sorted by col
// overlap kinds:
// 1. start on same line
// 2. one end, one start on same line
xxxxxx1; typeA decl1, decl2; xxxxx2; typeB decl3, decl4; xxxxx3;
xxxxxx1; typeA decl1,
decl2,
decl3; xxx2; typeB decl4,
decl5; xxxx3; typeC decl6, decl7; xxx4; typeD decl8, decl9;
//refactor
{
start_line:
start_col:
end_line:
end_col:
decl_type:
}
// change to iterate next_refactor seems nicer
ori_line_no = 0
last_refactor = {0, 0, 0, 0, "None"}
for refactor in refactor_list:
while ori_line_no < refactor['start_line']:
write ori_line_no
# deal with overlap
if last_refactor['end_line'] == refactor['start_line']:
overlap_line = ORIGIN_LINES[refactor['start_line']]
write overlap_line[last_refactor['end_col'] : refactor['start_col']]
for decl in get_decl_list(refactor):
write decl
...