koatl 0.1.15__tar.gz → 0.1.16__tar.gz

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.
Files changed (104) hide show
  1. {koatl-0.1.15 → koatl-0.1.16}/Cargo.lock +1 -1
  2. {koatl-0.1.15 → koatl-0.1.16}/PKG-INFO +1 -1
  3. {koatl-0.1.15 → koatl-0.1.16}/koatl/Cargo.toml +1 -1
  4. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/fstr.tl +3 -3
  5. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/match.tl +1 -1
  6. koatl-0.1.16/koatl/tests/e2e/base/scopes.tl +92 -0
  7. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/parser/src/ast.rs +1 -1
  8. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/parser/src/parser.rs +2 -2
  9. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/parser/src/util.rs +12 -5
  10. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/transform.rs +497 -196
  11. koatl-0.1.15/koatl/tests/e2e/base/scopes.tl +0 -49
  12. {koatl-0.1.15 → koatl-0.1.16}/Cargo.toml +0 -0
  13. {koatl-0.1.15 → koatl-0.1.16}/README.md +0 -0
  14. {koatl-0.1.15 → koatl-0.1.16}/koatl/.github/workflows/CI.yml +0 -0
  15. {koatl-0.1.15 → koatl-0.1.16}/koatl/.gitignore +0 -0
  16. {koatl-0.1.15 → koatl-0.1.16}/koatl/LICENSE +0 -0
  17. {koatl-0.1.15 → koatl-0.1.16}/koatl/README.md +0 -0
  18. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/__init__.py +0 -0
  19. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/__main__.py +0 -0
  20. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/cli.py +0 -0
  21. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/notebook/__init__.py +0 -0
  22. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/notebook/magic.py +0 -0
  23. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/__init__.tl +0 -0
  24. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/functional/__init__.tl +0 -0
  25. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/functional/async.tl +0 -0
  26. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/functional/async_util.py +0 -0
  27. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/functional/monad.tl +0 -0
  28. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/functional/reader.tl +0 -0
  29. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/functional/result.tl +0 -0
  30. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/prelude/iterable.tl +0 -0
  31. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/runtime/__init__.py +0 -0
  32. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/runtime/helpers.py +0 -0
  33. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/runtime/meta_finder.py +0 -0
  34. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/runtime/record.py +0 -0
  35. {koatl-0.1.15 → koatl-0.1.16}/koatl/python/koatl/runtime/virtual.py +0 -0
  36. {koatl-0.1.15 → koatl-0.1.16}/koatl/requirements.txt +0 -0
  37. {koatl-0.1.15 → koatl-0.1.16}/koatl/src/emit_py.rs +0 -0
  38. {koatl-0.1.15 → koatl-0.1.16}/koatl/src/lib.rs +0 -0
  39. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/coal.tl +0 -0
  40. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/containers.tl +0 -0
  41. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/decorators.tl +0 -0
  42. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
  43. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/destructure.tl +0 -0
  44. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/escape_ident.tl +0 -0
  45. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/functions.tl +0 -0
  46. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/generator.tl +0 -0
  47. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/if_expr.tl +0 -0
  48. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/imports.tl +0 -0
  49. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/iterables.tl +0 -0
  50. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/loops.tl +0 -0
  51. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/nary-list.tl +0 -0
  52. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/placeholder.tl +0 -0
  53. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/precedence.tl +0 -0
  54. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
  55. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/slice.tl +0 -0
  56. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/base/try.tl +0 -0
  57. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/destructure.tl +0 -0
  58. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/prelude/async.tl +0 -0
  59. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/prelude/reader.tl +0 -0
  60. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/prelude/result.tl +0 -0
  61. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/prelude/virtual.tl +0 -0
  62. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/util/__init__.py +0 -0
  63. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/util/module0.tl +0 -0
  64. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/util/module1.tl +0 -0
  65. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/e2e/util/module2.tl +0 -0
  66. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/parse/arith.tl +0 -0
  67. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/parse/assign.tl +0 -0
  68. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/parse/deco.tl +0 -0
  69. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/parse/func.tl +0 -0
  70. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/parse/matches.tl +0 -0
  71. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/test_e2e.py +0 -0
  72. {koatl-0.1.15 → koatl-0.1.16}/koatl/tests/test_parse.py +0 -0
  73. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/Cargo.toml +0 -0
  74. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/parser/Cargo.toml +0 -0
  75. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/parser/src/lexer.rs +0 -0
  76. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/parser/src/lib.rs +0 -0
  77. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/parser/tests/lexer.rs +0 -0
  78. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/lib.rs +0 -0
  79. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/linecol.rs +0 -0
  80. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/main.rs +0 -0
  81. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/parser.rs +0 -0
  82. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/py/ast.rs +0 -0
  83. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/py/emit.rs +0 -0
  84. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/py/mod.rs +0 -0
  85. {koatl-0.1.15 → koatl-0.1.16}/koatl-core/src/py/util.rs +0 -0
  86. {koatl-0.1.15 → koatl-0.1.16}/pyproject.toml +0 -0
  87. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/__init__.py +0 -0
  88. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/__main__.py +0 -0
  89. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/cli.py +0 -0
  90. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/notebook/__init__.py +0 -0
  91. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/notebook/magic.py +0 -0
  92. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/__init__.tl +0 -0
  93. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/functional/__init__.tl +0 -0
  94. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/functional/async.tl +0 -0
  95. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/functional/async_util.py +0 -0
  96. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/functional/monad.tl +0 -0
  97. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/functional/reader.tl +0 -0
  98. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/functional/result.tl +0 -0
  99. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/prelude/iterable.tl +0 -0
  100. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/runtime/__init__.py +0 -0
  101. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/runtime/helpers.py +0 -0
  102. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/runtime/meta_finder.py +0 -0
  103. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/runtime/record.py +0 -0
  104. {koatl-0.1.15 → koatl-0.1.16}/python/koatl/runtime/virtual.py +0 -0
@@ -99,7 +99,7 @@ checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
99
99
 
100
100
  [[package]]
101
101
  name = "koatl"
102
- version = "0.1.15"
102
+ version = "0.1.16"
103
103
  dependencies = [
104
104
  "ariadne",
105
105
  "koatl-core",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koatl
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "koatl"
3
- version = "0.1.15"
3
+ version = "0.1.16"
4
4
  edition = "2021"
5
5
 
6
6
  [lib]
@@ -11,9 +11,9 @@ fstr = f"x = {(y => y)(x)}"
11
11
  assert_eq(fstr, "x = 1")
12
12
 
13
13
  fstr = f"={
14
- a = 1
15
- b = 2
16
- c = 3
14
+ let a = 1
15
+ let b = 2
16
+ let c = 3
17
17
  a * b * c
18
18
  }="
19
19
  assert_eq(fstr, "=6=")
@@ -71,6 +71,6 @@ assert_eq(
71
71
 
72
72
  x = 1
73
73
  assert_eq([1, 2, 3] matches [1, 2, 3], True)
74
- assert_eq([1, 2, 3] matches [.x, y, 3], True)
74
+ assert_eq([1, 2, 3] matches [.x, _, 3], True)
75
75
 
76
76
  assert_eq(try 1 matches 1, True)
@@ -0,0 +1,92 @@
1
+ import util.assert_eq
2
+
3
+ #-
4
+ Note: many of the tests in this file are inside temporary functions;
5
+ this is because the global scope is special in Python.
6
+ -#
7
+
8
+
9
+
10
+ # Scope variables shouldn't escape
11
+
12
+ test = 1
13
+ if True:
14
+ test = 2
15
+ assert_eq(test, 2)
16
+ let test = 3
17
+ assert_eq(test, 3)
18
+ test = 4
19
+ assert_eq(test, 4)
20
+ assert_eq(test, 2)
21
+
22
+ # Nested scopes should identify captures properly
23
+
24
+ test = 1
25
+ f = () =>
26
+ test = 2
27
+ let g = () =>
28
+ test = 3
29
+ g()
30
+ assert_eq(test, 3)
31
+ f()
32
+ assert_eq(test, 3)
33
+
34
+ # ...but should also not leak variables
35
+
36
+ test = 1
37
+ f = () =>
38
+ test = 2
39
+ let g = () =>
40
+ let test = 3
41
+ g()
42
+ assert_eq(test, 2)
43
+ f()
44
+ assert_eq(test, 2)
45
+
46
+ # Arguments should shadow all other variables
47
+
48
+ test = 0
49
+ f = test =>
50
+ test = 1
51
+ assert_eq(test, 1)
52
+ f(1)
53
+ assert_eq(test, 0)
54
+
55
+ # Assignment lhs should be lifted into function body scope
56
+
57
+ f = () =>
58
+ let g = 1
59
+ let g = () => g = 2
60
+ g()
61
+ assert_eq(g, 2)
62
+ f()
63
+
64
+ # Recursion should work
65
+
66
+ a = () =>
67
+ let fib = n => n < 2 then 1 else fib(n - 1) + fib(n - 2)
68
+ assert_eq(fib(5), 8)
69
+ a()
70
+
71
+ # Classes should work
72
+
73
+ f = () =>
74
+ let A = class:
75
+ B = 2
76
+
77
+ f = (self, x=B) =>
78
+ x
79
+
80
+ assert_eq(A.B, 2)
81
+ assert_eq(A().f(), 2)
82
+ f()
83
+
84
+ f = () =>
85
+ let A = class:
86
+ f = self =>
87
+ # this should now resolve to the class itself
88
+ A = 2
89
+
90
+ A().f()
91
+ assert_eq(A, 2)
92
+ f()
@@ -83,7 +83,7 @@ pub enum DeclType {
83
83
  pub enum Stmt<'a> {
84
84
  Module,
85
85
  Decl(Vec<SIdent<'a>>, DeclType),
86
- Assign(SExpr<'a>, SExpr<'a>, Option<DeclType>),
86
+ Assign(Indirect<SExpr<'a>>, Indirect<SExpr<'a>>, Option<DeclType>),
87
87
  Expr(SExpr<'a>),
88
88
 
89
89
  Return(SExpr<'a>),
@@ -1203,7 +1203,7 @@ where
1203
1203
  nary_tuple.clone(),
1204
1204
  symbol("=").ignore_then(nary_tuple.clone()),
1205
1205
  ))
1206
- .map(|(decl, lhs, rhs)| Stmt::Assign(lhs, rhs, decl))
1206
+ .map(|(decl, lhs, rhs)| Stmt::Assign(lhs.into(), rhs.into(), decl))
1207
1207
  .boxed();
1208
1208
 
1209
1209
  let inline_assign_stmt = group((
@@ -1211,7 +1211,7 @@ where
1211
1211
  expr.clone(),
1212
1212
  symbol("=").ignore_then(expr.clone()),
1213
1213
  ))
1214
- .map(|(decl, lhs, rhs)| Stmt::Assign(lhs, rhs, decl))
1214
+ .map(|(decl, lhs, rhs)| Stmt::Assign(lhs.into(), rhs.into(), decl))
1215
1215
  .boxed();
1216
1216
 
1217
1217
  let expr_stmt = nary_tuple.clone().map(Stmt::Expr).boxed();
@@ -21,17 +21,24 @@ impl AstBuilder {
21
21
  (Stmt::Expr(expr), self.span)
22
22
  }
23
23
 
24
- pub fn assign<'src>(&self, target: SExpr<'src>, value: SExpr<'src>) -> SStmt<'src> {
25
- (Stmt::Assign(target, value, None), self.span)
24
+ pub fn assign<'src>(
25
+ &self,
26
+ target: impl Into<Indirect<SExpr<'src>>>,
27
+ value: impl Into<Indirect<SExpr<'src>>>,
28
+ ) -> SStmt<'src> {
29
+ (Stmt::Assign(target.into(), value.into(), None), self.span)
26
30
  }
27
31
 
28
32
  pub fn assign_modified<'src>(
29
33
  &self,
30
- target: SExpr<'src>,
31
- value: SExpr<'src>,
34
+ target: impl Into<Indirect<SExpr<'src>>>,
35
+ value: impl Into<Indirect<SExpr<'src>>>,
32
36
  modifier: DeclType,
33
37
  ) -> SStmt<'src> {
34
- (Stmt::Assign(target, value, Some(modifier)), self.span)
38
+ (
39
+ Stmt::Assign(target.into(), value.into(), Some(modifier)),
40
+ self.span,
41
+ )
35
42
  }
36
43
 
37
44
  pub fn return_<'src>(&self, expr: SExpr<'src>) -> SStmt<'src> {