jaclang 0.7.21__py3-none-any.whl → 0.7.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of jaclang might be problematic. Click here for more details.

@@ -2873,13 +2873,24 @@ class FString(AtomExpr):
2873
2873
  if deep:
2874
2874
  res = self.parts.normalize(deep) if self.parts else res
2875
2875
  new_kid: list[AstNode] = []
2876
+ is_single_quote = (
2877
+ isinstance(self.kid[0], Token) and self.kid[0].name == Tok.FSTR_SQ_START
2878
+ )
2876
2879
  if self.parts:
2880
+ if is_single_quote:
2881
+ new_kid.append(self.gen_token(Tok.FSTR_SQ_START))
2882
+ else:
2883
+ new_kid.append(self.gen_token(Tok.FSTR_START))
2877
2884
  for i in self.parts.items:
2878
2885
  if isinstance(i, String):
2879
2886
  i.value = (
2880
2887
  "{{" if i.value == "{" else "}}" if i.value == "}" else i.value
2881
2888
  )
2882
2889
  new_kid.append(self.parts)
2890
+ if is_single_quote:
2891
+ new_kid.append(self.gen_token(Tok.FSTR_SQ_END))
2892
+ else:
2893
+ new_kid.append(self.gen_token(Tok.FSTR_END))
2883
2894
  self.set_kids(nodes=new_kid)
2884
2895
  return res
2885
2896
 
@@ -4257,7 +4268,6 @@ class String(Literal):
4257
4268
  """Return literal value in its python type."""
4258
4269
  if isinstance(self.value, bytes):
4259
4270
  return self.value
4260
- prefix_len = 3 if self.value.startswith(("'''", '"""')) else 1
4261
4271
  if any(
4262
4272
  self.value.startswith(prefix)
4263
4273
  and self.value[len(prefix) :].startswith(("'", '"'))
@@ -4266,8 +4276,23 @@ class String(Literal):
4266
4276
  return eval(self.value)
4267
4277
 
4268
4278
  elif self.value.startswith(("'", '"')):
4269
- ret_str = self.value[prefix_len:-prefix_len]
4270
- return ret_str.encode().decode("unicode_escape", errors="backslashreplace")
4279
+ repr_str = self.value.encode().decode("unicode_escape")
4280
+ if (
4281
+ self.value.startswith('"""')
4282
+ and self.value.endswith('"""')
4283
+ and not self.find_parent_of_type(FString)
4284
+ ):
4285
+ return repr_str[3:-3]
4286
+ if (not self.find_parent_of_type(FString)) or (
4287
+ not (
4288
+ self.parent
4289
+ and isinstance(self.parent, SubNodeList)
4290
+ and self.parent.parent
4291
+ and isinstance(self.parent.parent, FString)
4292
+ )
4293
+ ):
4294
+ return repr_str[1:-1]
4295
+ return repr_str
4271
4296
  else:
4272
4297
  return self.value
4273
4298
 
@@ -1148,14 +1148,16 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
1148
1148
  else:
1149
1149
  token_type = f"{value_type.__name__.upper()}"
1150
1150
 
1151
+ if value_type == str:
1152
+ raw_repr = repr(node.value)
1153
+ quote = "'" if raw_repr.startswith("'") else '"'
1154
+ value = f"{quote}{raw_repr[1:-1]}{quote}"
1155
+ else:
1156
+ value = str(node.value)
1151
1157
  return type_mapping[value_type](
1152
1158
  file_path=self.mod_path,
1153
1159
  name=token_type,
1154
- value=(
1155
- f'"{repr(node.value)[1:-1]}"'
1156
- if value_type == str
1157
- else str(node.value)
1158
- ),
1160
+ value=value,
1159
1161
  line=node.lineno,
1160
1162
  end_line=node.end_lineno if node.end_lineno else node.lineno,
1161
1163
  col_start=node.col_offset,
@@ -2625,7 +2627,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
2625
2627
 
2626
2628
  def convert_to_doc(self, string: ast.String) -> None:
2627
2629
  """Convert a string to a docstring."""
2628
- string.value = f'""{string.value}""'
2630
+ string.value = f'"""{string.value[1:-1]}"""'
2629
2631
 
2630
2632
  def aug_op_map(self, tok_dict: dict, op: ast.Token) -> str:
2631
2633
  """aug_mapper."""
@@ -1,4 +1,47 @@
1
1
  """Small test for fstrings."""
2
2
 
3
+ glob apple = 2;
4
+ glob a=f"hello {40 + 2} wor{apple}ld ";
3
5
 
4
- glob a=f"hello {40 + 2} wor{apple}ld ";
6
+ with entry {
7
+ a = 9;
8
+ s_2 = "'''hello'''";
9
+ s_3 = "'''hello '''";
10
+ s_4 = "''' hello'''";
11
+ s_5 = '""" hello"""';
12
+ s_6 = '"""hello"""';
13
+ s_7 = '"""hello"" "';
14
+ s_8 = '"""hello""" ';
15
+ print(
16
+ len(s_2),
17
+ len(s_3),
18
+ len(s_4),
19
+ len(s_5),
20
+ len(s_6),
21
+ len(s_7),
22
+ len(s_8)
23
+ ) ;
24
+ b1 = f"{"'''hello''' "}";
25
+ b_2 = f"{'"""hello""" '}";
26
+ f_1 = f"{'hello '}{a}{'"""hello"""'}";
27
+ f_2 = f"{'hello '}{a}{"'''hello'''"}";
28
+ print(len(b1),len(b_2), b_2,len(f_1), len(f_2)) ;
29
+ f_3 = f"{'"""again"""'}";
30
+ f_4 = f"{'"""again""" '}";
31
+ f_5 = f"{"'''again'''"}";
32
+ f_6 = f"{"'''again''' "}";
33
+ f_7 = f"{'"""again"""'}";
34
+ f_s1 = f"{'hello '}{a}{'"""hello"""'}";
35
+ f_s2 = f"{'hello '}{a}{"'''hello'''"}{'kklkl'}";
36
+ print(
37
+ len(f_3),
38
+ len(f_4),
39
+ len(f_5),
40
+ len(f_6),
41
+ len(f_7),
42
+ len(f_s1), len(f_s2)
43
+ ) ;
44
+ """sdfsdf\nsdfsdfsdfsd dffgdfgd.""" ;
45
+ }
46
+ can func() {;
47
+ }
@@ -101,7 +101,7 @@ class JacLanguageTests(TestCase):
101
101
  stdout_value = captured_output.getvalue()
102
102
  self.assertEqual(
103
103
  stdout_value,
104
- "<link href='{'new_val': 3, 'where': 'from_foo'} rel='stylesheet'\nTrue\n",
104
+ "<link href='{'new_val': 3, 'where': 'from_foo'}' rel='stylesheet'>\nTrue\n",
105
105
  )
106
106
 
107
107
  def test_chandra_bugs2(self) -> None:
@@ -212,6 +212,20 @@ class JacLanguageTests(TestCase):
212
212
  self.assertEqual(stdout_value.count(r"\\\\"), 2)
213
213
  self.assertEqual(stdout_value.count("<class 'bytes'>"), 3)
214
214
 
215
+ def test_fstring_multiple_quotation(self) -> None:
216
+ """Test fstring with multiple quotation."""
217
+ captured_output = io.StringIO()
218
+ sys.stdout = captured_output
219
+ jac_import(
220
+ "compiler/passes/main/tests/fixtures/fstrings",
221
+ base_path=self.fixture_abs_path("../../"),
222
+ )
223
+ sys.stdout = sys.__stdout__
224
+ stdout_value = captured_output.getvalue()
225
+ self.assertEqual(stdout_value.split("\n")[0], "11 13 12 12 11 12 12")
226
+ self.assertEqual(stdout_value.split("\n")[1], '12 12 """hello""" 18 18')
227
+ self.assertEqual(stdout_value.split("\n")[2], "11 12 11 12 11 18 23")
228
+
215
229
  def test_deep_imports(self) -> None:
216
230
  """Parse micro jac file."""
217
231
  captured_output = io.StringIO()
@@ -511,13 +525,11 @@ class JacLanguageTests(TestCase):
511
525
  self.assertIn("can greet2(**kwargs: Any)", output)
512
526
  self.assertEqual(output.count("with entry {"), 13)
513
527
  self.assertIn(
514
- '"""Enum for shape types"""\nenum ShapeType{ CIRCLE = "Circle",\n',
528
+ '"""Enum for shape types"""\nenum ShapeType{ CIRCLE = \'Circle\',\n',
515
529
  output,
516
530
  )
517
- self.assertIn(
518
- "UNKNOWN = \"Unknown\",\n::py::\nprint('hello')\n::py::\n }", output
519
- )
520
- self.assertIn('assert x == 5 , "x should be equal to 5" ;', output)
531
+ self.assertIn("\nUNKNOWN = 'Unknown',\n::py::\nprint('hello')\n::", output)
532
+ self.assertIn("assert x == 5 , 'x should be equal to 5' ;", output)
521
533
  self.assertIn("if not x == y {", output)
522
534
  self.assertIn("can greet2(**kwargs: Any) {", output)
523
535
  self.assertIn("squares_dict = {x: (x ** 2) for x in numbers};", output)
@@ -792,7 +804,7 @@ class JacLanguageTests(TestCase):
792
804
  settings.print_py_raised_ast = True
793
805
  ir = jac_pass_to_pass(py_ast_build_pass, schedule=py_code_gen_typed).ir
794
806
  jac_ast = ir.pp()
795
- self.assertIn(' | +-- String - "Loop compl', jac_ast)
807
+ self.assertIn(" | +-- String - 'Loop completed normally{}'", jac_ast)
796
808
  self.assertEqual(len(ir.get_all_sub_nodes(ast.SubNodeList)), 269)
797
809
  captured_output = io.StringIO()
798
810
  sys.stdout = captured_output
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaclang
3
- Version: 0.7.21
3
+ Version: 0.7.22
4
4
  Summary: Jac is a unique and powerful programming language that runs on top of Python, offering an unprecedented level of intelligence and intuitive understanding.
5
5
  Home-page: https://jaseci.org
6
6
  License: MIT
@@ -6,7 +6,7 @@ jaclang/cli/cli.py,sha256=P2Hqzpb9q9uR_mbyFb8ojr3ff3oDbcP6m1G1kKWkR80,15911
6
6
  jaclang/cli/cmdreg.py,sha256=5mhzLJnpHfc0Z22qKQgcEOICgBaC95G9gSJZ-R7GqvU,8282
7
7
  jaclang/compiler/.gitignore,sha256=n1k2_xXTorp9PY8hhYM4psHircn-NMaFx95bSgDKopo,10
8
8
  jaclang/compiler/__init__.py,sha256=O1GO5Hb02vRlz7OpYHinQV5lQ7YuNUV9Hgjlc3QWtZg,2780
9
- jaclang/compiler/absyntree.py,sha256=6sFVBPhLJKopwfYYtK3-VQBh9AukXmmUGdE60FVyMaE,138072
9
+ jaclang/compiler/absyntree.py,sha256=cBF837cKo7lUDzBX_dvzCf0pCOcq4eNsHgseIjgEvXk,139002
10
10
  jaclang/compiler/codeloc.py,sha256=YhJcHjhMCOT6mV1qLehwriuFgW0H2-ntq68k_r8yBs4,2800
11
11
  jaclang/compiler/compile.py,sha256=0d8p4i2LXg2RCu1XfWx_Jq_dx7pK2Zn2VIj-apvX_nI,3389
12
12
  jaclang/compiler/constant.py,sha256=gKccXK4Qf3CWuv8J1oaWrwqdP7CRIf7ndayquRx6Xgs,9007
@@ -22,7 +22,7 @@ jaclang/compiler/passes/main/fuse_typeinfo_pass.py,sha256=-rhK5SN9ORr7gTv9KVS1TG
22
22
  jaclang/compiler/passes/main/import_pass.py,sha256=9uoC_gxDs3FmLBBzQ8A1YQNHUlWQkAlKi55-AMkM3hs,12690
23
23
  jaclang/compiler/passes/main/py_collect_dep_pass.py,sha256=lzMOYH8TarhkJFt0vqvZFknthZ08OjsdO7tO2u2EN40,2834
24
24
  jaclang/compiler/passes/main/pyast_gen_pass.py,sha256=ACUhGsLq34N-Sfo96IAgkTnds9ZY6I7J6okr6rFvPpo,142105
25
- jaclang/compiler/passes/main/pyast_load_pass.py,sha256=k-tf5cZVlygDg4BGBYcAznO6w0hM4-0Pdzlwr4Sw48I,94027
25
+ jaclang/compiler/passes/main/pyast_load_pass.py,sha256=DPbHECLOHmThoGvmHJCr3mjR21MMGtlY3dp_8S2-iPQ,94148
26
26
  jaclang/compiler/passes/main/pybc_gen_pass.py,sha256=CjA9AqyMO3Pv_b5Hh0YI6JmCqIru2ASonO6rhrkau-M,1336
27
27
  jaclang/compiler/passes/main/pyjac_ast_link_pass.py,sha256=1pW0uLEnhM5hCwVFAREdd_miyr3qTK0h_SJVfR_ryig,8604
28
28
  jaclang/compiler/passes/main/pyout_pass.py,sha256=QWVB-AyVBha3OespP89LMuslRsdG2niZErwtnRPiURM,3191
@@ -42,7 +42,7 @@ jaclang/compiler/passes/main/tests/fixtures/blip.jac,sha256=Fx9zqQ8VkiQ6vgzbQv9L
42
42
  jaclang/compiler/passes/main/tests/fixtures/codegentext.jac,sha256=U9xyk8hDlWM3jUaozQXOD61f5p9SI-_QfDxA68DUYds,562
43
43
  jaclang/compiler/passes/main/tests/fixtures/decls.jac,sha256=vPHNZeXuFKLclAFJfe92ajOX7n0ULsvEi5jBoDU-Ns8,123
44
44
  jaclang/compiler/passes/main/tests/fixtures/defs_and_uses.jac,sha256=zTTq_0u8ITmODu8rjRloI5Imwf2dICHdiKdOnzcgpbg,901
45
- jaclang/compiler/passes/main/tests/fixtures/fstrings.jac,sha256=h5bj-VWRv8g6POMVxQ1VPq6SI7QitZahAFMSmrp6Daw,75
45
+ jaclang/compiler/passes/main/tests/fixtures/fstrings.jac,sha256=6QRZtTSuG1vIA7egTv-rY27U6HRaXeiOyuNs1sIU5Bk,1089
46
46
  jaclang/compiler/passes/main/tests/fixtures/func.jac,sha256=i175hPkR4tgf5SMZOrrCHjAE12mVlf6qUsu0mcJmJBE,297
47
47
  jaclang/compiler/passes/main/tests/fixtures/func2.jac,sha256=ZxgLe7VA57daLkqoB8MefdEE8dZIoFv2Dq-Zx-yHKxI,124
48
48
  jaclang/compiler/passes/main/tests/fixtures/game1.jac,sha256=oiTadkrYJRUo6ZkHUi7I54J_0GoTTtsNLhhofTlz0uY,263
@@ -291,7 +291,7 @@ jaclang/tests/fixtures/walker_update.jac,sha256=_bN3ASAN6LpfIQFfDMRnrx2oteM-ef7O
291
291
  jaclang/tests/fixtures/with_context.jac,sha256=cDA_4YWe5UVmQRgcpktzkZ_zsswQpV_T2Otf_rFnPy8,466
292
292
  jaclang/tests/test_bugs.py,sha256=tBPsIlSPqZDIz4QaScNRT-WdGIdJ0uU-aRBWq1XUZ6o,555
293
293
  jaclang/tests/test_cli.py,sha256=7PYJvJeKKb13yyP0TQ_pHbdRowWN5TI7kG-tNUESbaI,13461
294
- jaclang/tests/test_language.py,sha256=8eOyQeMJrMZbn8XZJqaddaajx4htlUJWvwPM1PTNubE,44376
294
+ jaclang/tests/test_language.py,sha256=pe5GbGDvxX6u0uqCLtYCYR9SFtBswxfF0zZkKgUNQfw,45020
295
295
  jaclang/tests/test_man_code.py,sha256=ZdNarlZVfT_-8Jv3FjLplHw76tsvkCuISyfX3M4qxPg,5027
296
296
  jaclang/tests/test_reference.py,sha256=FISQpZbB8cmRoAeJOFfXUy13WVxykZjpkPSb1OTotfI,3340
297
297
  jaclang/tests/test_settings.py,sha256=TIX5uiu8H9IpZN2__uFiclcdCpBpPpcAwtlEHyFC4kk,1999
@@ -1525,7 +1525,7 @@ jaclang/vendor/typing_extensions-4.12.2.dist-info/METADATA,sha256=BeUQIa8cnYbrjW
1525
1525
  jaclang/vendor/typing_extensions-4.12.2.dist-info/RECORD,sha256=XS4fBVrPI7kaNZ56Ggl2RGa76jySWLqTzcrUpZIQTVM,418
1526
1526
  jaclang/vendor/typing_extensions-4.12.2.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
1527
1527
  jaclang/vendor/typing_extensions.py,sha256=gwekpyG9DVG3lxWKX4ni8u7nk3We5slG98mA9F3DJQw,134451
1528
- jaclang-0.7.21.dist-info/METADATA,sha256=PHYewc1q1XV9rbxXxH3sxGKUdo4Tp6630L7bONTYsGY,4914
1529
- jaclang-0.7.21.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1530
- jaclang-0.7.21.dist-info/entry_points.txt,sha256=8sMi4Tvi9f8tQDN2QAXsSA2icO27zQ4GgEdph6bNEZM,49
1531
- jaclang-0.7.21.dist-info/RECORD,,
1528
+ jaclang-0.7.22.dist-info/METADATA,sha256=RRjM8ycf_J5Kh88mQ0FqNAHngok4LAZhlMwJjMYkvSg,4914
1529
+ jaclang-0.7.22.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1530
+ jaclang-0.7.22.dist-info/entry_points.txt,sha256=8sMi4Tvi9f8tQDN2QAXsSA2icO27zQ4GgEdph6bNEZM,49
1531
+ jaclang-0.7.22.dist-info/RECORD,,