more work

This commit is contained in:
Daniel Gavin
2021-04-19 19:38:08 +02:00
parent c708f649ec
commit f1dc7c0b27
2 changed files with 9 additions and 3 deletions

View File

@@ -124,6 +124,8 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
}
set_source_position(p, file.pkg_token.pos);
p.last_source_position.line = 1;
set_line(p, 0);
@@ -187,6 +189,8 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
last_line = line_index;
}
strings.write_string(&builder, newline);
return strings.to_string(builder);
}

View File

@@ -106,10 +106,8 @@ push_comment :: proc(p: ^Printer, comment: tokenizer.Token) -> int {
} else if c == '/' && comment.text[min(c_len - 1, i + 1)] == '*' {
strings.write_string(&builder, "/*");
trim_space = true;
p.depth += 1;
i += 1;
} else if c == '*' && comment.text[min(c_len - 1, i + 1)] == '/' {
p.depth -= 1;
trim_space = true;
strings.write_string(&builder, "*/");
i += 1;
@@ -453,7 +451,11 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) {
push_generic_token(p, .Colon, 0);
}
visit_exprs(p, v.values, true);
if len(v.values) == 1 {
visit_expr(p, v.values[0]); //this is too ensure that one value are never newlined(procs, structs, etc.)
} else {
visit_exprs(p, v.values, true);
}
add_semicolon := true;