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

Commit

Permalink
Merge pull request #567 from Jaseci-Labs/access_mod
Browse files Browse the repository at this point in the history
Access Modifier Space check
  • Loading branch information
marsninja authored Aug 15, 2024
2 parents de00856 + 8ede189 commit e46728d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jaclang/compiler/passes/tool/jac_formatter_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def exit_sub_tag(self, node: ast.SubTag) -> None:
tag: T,
"""
start = True
prev_token = None
for i in node.kid:
if isinstance(i, ast.CommentToken):
if i.is_inline:
Expand All @@ -336,8 +337,13 @@ def exit_sub_tag(self, node: ast.SubTag) -> None:
elif i.gen.jac == ",":
self.emit(node, f"{i.gen.jac} ")
else:
if start:
self.emit(node, i.gen.jac)
if isinstance(i, ast.Token) and not isinstance(i, ast.BuiltinType):
try:
prev_token = self.token_before(i)
except Exception:
prev_token = None
if start or (prev_token and prev_token.gen.jac.strip() == ":"):
self.emit(node, i.gen.jac.strip())
start = False
else:
self.emit(node, f" {i.gen.jac}")
Expand Down Expand Up @@ -651,6 +657,8 @@ def exit_ability(self, node: ast.Ability) -> None:
self.emit(node, i.gen.jac)
elif isinstance(i, ast.SubNodeList) and i.gen.jac.startswith("@"):
self.emit_ln(node, i.gen.jac)
elif isinstance(i, ast.SubTag):
self.emit(node, i.gen.jac)
else:
if start:
self.emit(node, i.gen.jac)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
can:priv hash(func: Any) {
can inner(a: Any) {
print(("#" * 20));
func(a);
print(("#" * 20));
}
return inner;
}

can:protect exclaim(func: Any) {
can inner(b: Any) {
print(("!" * 20));
func(b);
print(("!" * 20));
}
return inner;
}

@hash
@exclaim
can greeter(name: Any) {
print("Hello, " + name + "!");
}

with entry {
greeter("World");
}

0 comments on commit e46728d

Please sign in to comment.