Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

test: comment file needs fixing #527

Merged
merged 6 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion jaclang/compiler/passes/tool/jac_formatter_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def indent_str(self) -> str:

def emit(self, node: ast.AstNode, s: str, strip_mode: bool = True) -> None:
"""Emit code to node."""
node.gen.jac += self.indent_str() + s.replace("\n", "\n" + self.indent_str())
indented_str = re.sub(r"\n(?!\n)", f"\n{self.indent_str()}", s)
node.gen.jac += self.indent_str() + indented_str
if "\n" in node.gen.jac:
if strip_mode:
node.gen.jac = node.gen.jac.rstrip(" ")
Expand Down Expand Up @@ -1098,6 +1099,9 @@ def exit_expr_stmt(self, node: ast.ExprStmt) -> None:
if isinstance(i, ast.CommentToken):
if i.is_inline:
self.emit(node, f" {i.gen.jac}")
elif (tok := self.token_before(i)) and (i.line_no - tok.line_no == 1):
self.emit_ln(node, "")
self.emit(node, i.gen.jac)
else:
self.emit_ln(node, "")
self.emit_ln(node, "")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with entry:__main__ {
app = App();
app.run();
# ray.init_window(800, 450, "Hello");
# while not ray.window_should_close() {
# ray.begin_drawing();
# ray.clear_background(ray.WHITE);
# ray.draw_text("Hello world", 190, 200, 20, ray.VIOLET);
# ray.end_drawing();
# }

# ray.close_window();
}
Loading