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

Commit 235c9cc

Browse files
committed
Merge branch 'main' into enhancements/persistent-v2
2 parents e24caf0 + 23517e9 commit 235c9cc

File tree

7 files changed

+75
-23
lines changed

7 files changed

+75
-23
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Jac Website] | [Getting started] | [Learn] | [Documentation] | [Contributing]
1111

12-
[![PyPI version](https://img.shields.io/pypi/v/jaclang.svg)](https://pypi.org/project/jaclang/) [![Tests](https://github.com/chandralegend/jaclang/actions/workflows/run_pytest.yml/badge.svg?branch=main)](https://github.com/chandralegend/jaclang/actions/workflows/run_pytest.yml) [![codecov](https://codecov.io/github/chandralegend/jaclang/graph/badge.svg?token=OAX26B0FE4)](https://codecov.io/github/chandralegend/jaclang)
12+
[![PyPI version](https://img.shields.io/pypi/v/jaclang.svg)](https://pypi.org/project/jaclang/) [![Tests](https://github.com/Jaseci-Labs/jaclang/actions/workflows/run_pytest.yml/badge.svg)](https://github.com/Jaseci-Labs/jaclang/actions/workflows/run_pytest.yml) [![codecov](https://codecov.io/github/chandralegend/jaclang/graph/badge.svg?token=OAX26B0FE4)](https://codecov.io/github/chandralegend/jaclang)
1313
</div>
1414

1515
This is the main source code repository for the [Jac] programming language. It contains the compiler, language server, and documentation.
@@ -77,4 +77,4 @@ Third-party logos may be subject to third-party copyrights and trademarks. See [
7777

7878
[jaseci]: https://jaseci.org/
7979
[media-guide]: https://jaseci.org/policies/logo-policy-and-media-guide/
80-
[policies-licenses]: https://www.jaseci.org/policies/licenses
80+
[policies-licenses]: https://www.jaseci.org/policies/licenses

jaclang/compiler/passes/main/registry_pass.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def exit_has_var(self, node: ast.HasVar) -> None:
8686

8787
def exit_ability(self, node: ast.Ability) -> None:
8888
"""Save ability information."""
89-
scope = get_sem_scope(node.parent) # type: ignore[arg-type]
89+
scope = get_sem_scope(node.parent) if node.parent else None
90+
if not scope:
91+
raise self.ice("Ability has no parent. Impossible")
9092
seminfo = SemInfo(
9193
node.name_ref.sym_name,
9294
"Ability",

jaclang/compiler/passes/tool/jac_formatter_pass.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ def exit_sub_node_list(self, node: ast.SubNodeList) -> None:
289289
self.emit(node, f"{stmt.value} ")
290290
elif stmt.value == "=":
291291
self.emit(node, f" {stmt.value} ")
292+
elif prev_token and prev_token.gen.jac.strip() == "@":
293+
self.emit_ln(node, stmt.value)
292294
else:
293295
self.emit(node, f"{stmt.gen.jac}")
294296
prev_token = stmt
@@ -2418,7 +2420,7 @@ def exit_name(self, node: ast.Name) -> None:
24182420
"""
24192421
self.emit(node, f"<>{node.value}" if node.is_kwesc else node.value)
24202422

2421-
def enter_float(self, node: ast.Float) -> None:
2423+
def exit_float(self, node: ast.Float) -> None:
24222424
"""Sub objects.
24232425
24242426
name: str,
@@ -2431,7 +2433,7 @@ def enter_float(self, node: ast.Float) -> None:
24312433
"""
24322434
self.emit(node, node.value)
24332435

2434-
def enter_int(self, node: ast.Int) -> None:
2436+
def exit_int(self, node: ast.Int) -> None:
24352437
"""Sub objects.
24362438
24372439
name: str,
@@ -2444,7 +2446,7 @@ def enter_int(self, node: ast.Int) -> None:
24442446
"""
24452447
self.emit(node, node.value)
24462448

2447-
def enter_string(self, node: ast.String) -> None:
2449+
def exit_string(self, node: ast.String) -> None:
24482450
"""Sub objects.
24492451
24502452
name: str,
@@ -2456,7 +2458,11 @@ def enter_string(self, node: ast.String) -> None:
24562458
pos_end: int,
24572459
"""
24582460
# if string is in docstring format and spans multiple lines turn into the multiple single quoted strings
2459-
if "\n" in node.value and node.parent and isinstance(node.parent, ast.Expr):
2461+
if "\n" in node.value and (
2462+
node.parent
2463+
and isinstance(node.parent, ast.Expr)
2464+
and not isinstance(node.parent, ast.MultiString)
2465+
):
24602466
string_type = node.value[0:3]
24612467
pure_string = node.value[3:-3]
24622468
lines = pure_string.split("\n")
@@ -2474,14 +2480,14 @@ def enter_string(self, node: ast.String) -> None:
24742480
string_type = node.value[0:3]
24752481
pure_string = node.value[3:-3]
24762482
lines = pure_string.split("\n")
2477-
self.emit(node, string_type)
2478-
for line in lines[:-1]:
2479-
self.emit_ln(node, line)
2480-
self.emit_ln(node, f"{lines[-1]}{string_type}")
2483+
self.emit_ln(node, f"{string_type}{lines[0].lstrip()}")
2484+
for line in lines[1:-1]:
2485+
self.emit_ln(node, line.lstrip())
2486+
self.emit(node, f"{lines[-1].lstrip()}{string_type}")
24812487
else:
24822488
self.emit(node, node.value)
24832489

2484-
def enter_bool(self, node: ast.Bool) -> None:
2490+
def exit_bool(self, node: ast.Bool) -> None:
24852491
"""Sub objects.
24862492
24872493
name: str,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
can star(func: Any) {
2+
can inner(x: Any) {
3+
print(("*" * 30));
4+
func(x);
5+
print(("*" * 30));
6+
}
7+
return inner;
8+
}
9+
10+
can percent(func: Any) {
11+
can inner(y: Any) {
12+
print(("%" * 30));
13+
func(y);
14+
print(("%" * 30));
15+
}
16+
return inner;
17+
}
18+
19+
can percent2(func: Any) {
20+
can inner(y: Any) {
21+
print(("-" * 30));
22+
func(y);
23+
print(("+" * 30));
24+
}
25+
return inner;
26+
}
27+
28+
@star
29+
@percent
30+
@percent2
31+
can printer(msg: Any) {
32+
print(msg);
33+
}
34+
35+
with entry {
36+
printer("Hello");
37+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
with entry {
2+
triple_quoted_string = """This is a triple quoted string.
3+
It can span multiple lines.
4+
It can contain any number of quotes or apostrophes.
5+
""";
6+
}
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import:py re;
22

3-
glob a: int=5;
3+
glob a: int = 5;
44

55
with entry {
6-
arguments = {x:None for x in re.findall(r'\{([A-Za-z0-9_]+)\}', "Apple {apple} pineapple {pineapple}")};
7-
a: int=5;
6+
arguments = {x: None for x in re.findall(
7+
r'\{([A-Za-z0-9_]+)\}',
8+
"Apple {apple} pineapple {pineapple}"
9+
)};
10+
a: int = 5;
811
if False {
912
with open(f"Apple{apple}.txt") as f { # Fix syntax highlighting
1013

1114
print(f.read());
1215
}
1316
}
1417
print(arguments);
15-
print(
16-
"""This is a long
17-
line of code."""
18-
);
18+
print("""This is a long
19+
line of code.""");
1920
}
2021

21-
with entry{
22-
a={"a":"apple", "b":"ball", "c":"cat"};
23-
y={**a, "d":"dog", "e":"elephant"};
22+
with entry {
23+
a = {"a": "apple", "b": "ball", "c": "cat"};
24+
y = {**a, "d": "dog", "e": "elephant"};
2425
print(y);
2526
}
2627
# Use before def error would be nice

jaclang/tests/test_language.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_chandra_bugs2(self) -> None:
108108
stdout_value,
109109
"{'apple': None, 'pineapple': None}\n"
110110
"This is a long\n"
111-
" line of code.\n"
111+
" line of code.\n"
112112
"{'a': 'apple', 'b': 'ball', 'c': 'cat', 'd': 'dog', 'e': 'elephant'}\n",
113113
)
114114

0 commit comments

Comments
 (0)