make sure to print comments at the end of the file

This commit is contained in:
Daniel Gavin
2021-04-13 23:52:23 +02:00
parent b09e53d7fe
commit 2001384ae6
2 changed files with 17 additions and 2 deletions
+15
View File
@@ -118,6 +118,12 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
visit_decl(p, cast(^ast.Decl)decl);
}
if len(p.comments) > 0 {
infinite := p.comments[len(p.comments)-1].end;
infinite.offset = 9999999;
push_comments(p, infinite);
}
fix_lines(p);
builder := strings.make_builder(p.allocator);
@@ -163,12 +169,17 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
fix_lines :: proc(p: ^Printer) {
align_comments(p);
align_var_decls(p);
align_blocks(p);
}
align_var_decls :: proc(p: ^Printer) {
}
align_blocks :: proc(p: ^Printer) {
}
align_comments :: proc(p: ^Printer) {
Comment_Align_Info :: struct {
@@ -222,6 +233,10 @@ align_comments :: proc(p: ^Printer) {
for info in comment_infos {
if info.begin == info.end {
continue;
}
for i := info.begin; i <= info.end; i += 1 {
l := p.lines[i];