diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-04-19 19:38:08 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-04-19 19:38:08 +0200 |
| commit | f1dc7c0b27f95df8999b6b12c5284476dc0bc64d (patch) | |
| tree | 7d326e9e22ff163a408f193f562c18f2fab5edbe | |
| parent | c708f649ece3859306765964b22eba6302a1cd34 (diff) | |
more work
| -rw-r--r-- | core/odin/printer/printer.odin | 4 | ||||
| -rw-r--r-- | core/odin/printer/visit.odin | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/core/odin/printer/printer.odin b/core/odin/printer/printer.odin index 600f0bfe3..c972be019 100644 --- a/core/odin/printer/printer.odin +++ b/core/odin/printer/printer.odin @@ -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);
}
diff --git a/core/odin/printer/visit.odin b/core/odin/printer/visit.odin index b1b1d2693..953e0951f 100644 --- a/core/odin/printer/visit.odin +++ b/core/odin/printer/visit.odin @@ -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;
|