koatl 0.2.2__tar.gz → 0.2.3__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 (139) hide show
  1. koatl-0.2.3/Cargo.lock +218 -0
  2. {koatl-0.2.2 → koatl-0.2.3}/PKG-INFO +1 -1
  3. {koatl-0.2.2 → koatl-0.2.3}/koatl/Cargo.toml +1 -1
  4. {koatl-0.2.2 → koatl-0.2.3}/koatl/src/emit_py.rs +63 -12
  5. koatl-0.2.3/koatl/tests/parse/numbers.tl +24 -0
  6. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/ast.rs +6 -1
  7. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/ast_builder.rs +2 -2
  8. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/lib.rs +9 -19
  9. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/lift_cst.rs +19 -1
  10. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/main.rs +2 -2
  11. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/py/ast.rs +26 -22
  12. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/py/ast_builder.rs +19 -19
  13. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/py/emit.rs +42 -28
  14. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/transform.rs +26 -17
  15. {koatl-0.2.2 → koatl-0.2.3}/koatl-parser/Cargo.toml +0 -1
  16. {koatl-0.2.2 → koatl-0.2.3}/koatl-parser/src/lexer.rs +487 -146
  17. koatl-0.2.3/koatl-parser/src/lib.rs +7 -0
  18. {koatl-0.2.2 → koatl-0.2.3}/koatl-parser/src/parser.rs +13 -6
  19. {koatl-0.2.2 → koatl-0.2.3}/koatl-parser/src/simple_fmt.rs +1 -1
  20. koatl-0.2.2/Cargo.lock +0 -438
  21. koatl-0.2.2/koatl-parser/src/lib.rs +0 -11
  22. koatl-0.2.2/koatl-parser/src/parser_error.rs +0 -419
  23. {koatl-0.2.2 → koatl-0.2.3}/Cargo.toml +0 -0
  24. {koatl-0.2.2 → koatl-0.2.3}/README.md +0 -0
  25. {koatl-0.2.2 → koatl-0.2.3}/koatl/.github/workflows/CI.yml +0 -0
  26. {koatl-0.2.2 → koatl-0.2.3}/koatl/.gitignore +0 -0
  27. {koatl-0.2.2 → koatl-0.2.3}/koatl/LICENSE +0 -0
  28. {koatl-0.2.2 → koatl-0.2.3}/koatl/README.md +0 -0
  29. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/__init__.py +0 -0
  30. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/__main__.py +0 -0
  31. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/cli.py +0 -0
  32. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/notebook/__init__.py +0 -0
  33. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/notebook/magic.py +0 -0
  34. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/prelude/__init__.tl +0 -0
  35. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/runtime/__init__.py +0 -0
  36. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/runtime/meta_finder.py +0 -0
  37. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/runtime/record.py +0 -0
  38. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/runtime/vattr.py +0 -0
  39. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/alg/__init__.tl +0 -0
  40. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/alg/async.tl +0 -0
  41. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/alg/base.tl +0 -0
  42. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/alg/do.tl +0 -0
  43. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/alg/env.tl +0 -0
  44. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/alg/memo.tl +0 -0
  45. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/alg/result.tl +0 -0
  46. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/data/__init__.tl +0 -0
  47. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/data/list.tl +0 -0
  48. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/data/record.tl +0 -0
  49. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/ext.tl +0 -0
  50. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/io.tl +0 -0
  51. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/iter.tl +0 -0
  52. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/json.tl +0 -0
  53. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/lazy_module.tl +0 -0
  54. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/pickle.tl +0 -0
  55. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/re.tl +0 -0
  56. {koatl-0.2.2 → koatl-0.2.3}/koatl/python/koatl/std/trait.py +0 -0
  57. {koatl-0.2.2 → koatl-0.2.3}/koatl/requirements.txt +0 -0
  58. {koatl-0.2.2 → koatl-0.2.3}/koatl/src/lib.rs +0 -0
  59. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/containers.tl +0 -0
  60. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/data.txt +0 -0
  61. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/decorators.tl +0 -0
  62. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
  63. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/destructure.tl +0 -0
  64. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/escape_ident.tl +0 -0
  65. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/fstr.tl +0 -0
  66. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/functions.tl +0 -0
  67. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/generator.tl +0 -0
  68. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/if_expr.tl +0 -0
  69. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/loops.tl +0 -0
  70. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/match.tl +0 -0
  71. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/nary-list.tl +0 -0
  72. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/placeholder.tl +0 -0
  73. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/precedence.tl +0 -0
  74. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/scopes.tl +0 -0
  75. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
  76. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/short_circuit.tl +0 -0
  77. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/base/with.tl +0 -0
  78. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/async.tl +0 -0
  79. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/aug_assign.tl +0 -0
  80. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/coal.tl +0 -0
  81. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/env.tl +0 -0
  82. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/imports.tl +0 -0
  83. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/iterables.tl +0 -0
  84. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/list.tl +0 -0
  85. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/memo.tl +0 -0
  86. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/record.tl +0 -0
  87. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/result.tl +0 -0
  88. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/slice.tl +0 -0
  89. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/try.tl +0 -0
  90. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/prelude/virtual.tl +0 -0
  91. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/util/__init__.py +0 -0
  92. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/util/module0.tl +0 -0
  93. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/util/module1.tl +0 -0
  94. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/e2e/util/module2.tl +0 -0
  95. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/parse/arith.tl +0 -0
  96. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/parse/assign.tl +0 -0
  97. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/parse/block-comments.tl +0 -0
  98. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/parse/deco.tl +0 -0
  99. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/parse/func.tl +0 -0
  100. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/parse/matches.tl +0 -0
  101. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/test_e2e.py +0 -0
  102. {koatl-0.2.2 → koatl-0.2.3}/koatl/tests/test_parse.py +0 -0
  103. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/Cargo.toml +0 -0
  104. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/inference.rs +0 -0
  105. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/parse_timer.rs +0 -0
  106. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/py/mod.rs +0 -0
  107. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/resolve_scopes.rs +0 -0
  108. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/types.rs +0 -0
  109. {koatl-0.2.2 → koatl-0.2.3}/koatl-core/src/util.rs +0 -0
  110. {koatl-0.2.2 → koatl-0.2.3}/koatl-parser/src/cst.rs +0 -0
  111. {koatl-0.2.2 → koatl-0.2.3}/pyproject.toml +0 -0
  112. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/__init__.py +0 -0
  113. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/__main__.py +0 -0
  114. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/cli.py +0 -0
  115. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/notebook/__init__.py +0 -0
  116. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/notebook/magic.py +0 -0
  117. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/prelude/__init__.tl +0 -0
  118. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/runtime/__init__.py +0 -0
  119. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/runtime/meta_finder.py +0 -0
  120. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/runtime/record.py +0 -0
  121. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/runtime/vattr.py +0 -0
  122. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/alg/__init__.tl +0 -0
  123. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/alg/async.tl +0 -0
  124. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/alg/base.tl +0 -0
  125. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/alg/do.tl +0 -0
  126. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/alg/env.tl +0 -0
  127. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/alg/memo.tl +0 -0
  128. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/alg/result.tl +0 -0
  129. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/data/__init__.tl +0 -0
  130. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/data/list.tl +0 -0
  131. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/data/record.tl +0 -0
  132. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/ext.tl +0 -0
  133. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/io.tl +0 -0
  134. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/iter.tl +0 -0
  135. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/json.tl +0 -0
  136. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/lazy_module.tl +0 -0
  137. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/pickle.tl +0 -0
  138. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/re.tl +0 -0
  139. {koatl-0.2.2 → koatl-0.2.3}/python/koatl/std/trait.py +0 -0
koatl-0.2.3/Cargo.lock ADDED
@@ -0,0 +1,218 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "ariadne"
7
+ version = "0.5.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "36f5e3dca4e09a6f340a61a0e9c7b61e030c69fc27bf29d73218f7e5e3b7638f"
10
+ dependencies = [
11
+ "unicode-width",
12
+ "yansi",
13
+ ]
14
+
15
+ [[package]]
16
+ name = "autocfg"
17
+ version = "1.5.0"
18
+ source = "registry+https://github.com/rust-lang/crates.io-index"
19
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
20
+
21
+ [[package]]
22
+ name = "heck"
23
+ version = "0.5.0"
24
+ source = "registry+https://github.com/rust-lang/crates.io-index"
25
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
26
+
27
+ [[package]]
28
+ name = "indoc"
29
+ version = "2.0.6"
30
+ source = "registry+https://github.com/rust-lang/crates.io-index"
31
+ checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
32
+
33
+ [[package]]
34
+ name = "koatl"
35
+ version = "0.2.3"
36
+ dependencies = [
37
+ "ariadne",
38
+ "koatl-core",
39
+ "once_cell",
40
+ "pyo3",
41
+ ]
42
+
43
+ [[package]]
44
+ name = "koatl-core"
45
+ version = "0.1.0"
46
+ dependencies = [
47
+ "ariadne",
48
+ "koatl-parser",
49
+ "once_cell",
50
+ "slotmap",
51
+ ]
52
+
53
+ [[package]]
54
+ name = "koatl-parser"
55
+ version = "0.1.0"
56
+
57
+ [[package]]
58
+ name = "libc"
59
+ version = "0.2.174"
60
+ source = "registry+https://github.com/rust-lang/crates.io-index"
61
+ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
62
+
63
+ [[package]]
64
+ name = "memoffset"
65
+ version = "0.9.1"
66
+ source = "registry+https://github.com/rust-lang/crates.io-index"
67
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
68
+ dependencies = [
69
+ "autocfg",
70
+ ]
71
+
72
+ [[package]]
73
+ name = "once_cell"
74
+ version = "1.21.3"
75
+ source = "registry+https://github.com/rust-lang/crates.io-index"
76
+ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
77
+
78
+ [[package]]
79
+ name = "portable-atomic"
80
+ version = "1.11.1"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
83
+
84
+ [[package]]
85
+ name = "proc-macro2"
86
+ version = "1.0.95"
87
+ source = "registry+https://github.com/rust-lang/crates.io-index"
88
+ checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
89
+ dependencies = [
90
+ "unicode-ident",
91
+ ]
92
+
93
+ [[package]]
94
+ name = "pyo3"
95
+ version = "0.25.1"
96
+ source = "registry+https://github.com/rust-lang/crates.io-index"
97
+ checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a"
98
+ dependencies = [
99
+ "indoc",
100
+ "libc",
101
+ "memoffset",
102
+ "once_cell",
103
+ "portable-atomic",
104
+ "pyo3-build-config",
105
+ "pyo3-ffi",
106
+ "pyo3-macros",
107
+ "unindent",
108
+ ]
109
+
110
+ [[package]]
111
+ name = "pyo3-build-config"
112
+ version = "0.25.1"
113
+ source = "registry+https://github.com/rust-lang/crates.io-index"
114
+ checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598"
115
+ dependencies = [
116
+ "once_cell",
117
+ "target-lexicon",
118
+ ]
119
+
120
+ [[package]]
121
+ name = "pyo3-ffi"
122
+ version = "0.25.1"
123
+ source = "registry+https://github.com/rust-lang/crates.io-index"
124
+ checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c"
125
+ dependencies = [
126
+ "libc",
127
+ "pyo3-build-config",
128
+ ]
129
+
130
+ [[package]]
131
+ name = "pyo3-macros"
132
+ version = "0.25.1"
133
+ source = "registry+https://github.com/rust-lang/crates.io-index"
134
+ checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50"
135
+ dependencies = [
136
+ "proc-macro2",
137
+ "pyo3-macros-backend",
138
+ "quote",
139
+ "syn",
140
+ ]
141
+
142
+ [[package]]
143
+ name = "pyo3-macros-backend"
144
+ version = "0.25.1"
145
+ source = "registry+https://github.com/rust-lang/crates.io-index"
146
+ checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc"
147
+ dependencies = [
148
+ "heck",
149
+ "proc-macro2",
150
+ "pyo3-build-config",
151
+ "quote",
152
+ "syn",
153
+ ]
154
+
155
+ [[package]]
156
+ name = "quote"
157
+ version = "1.0.40"
158
+ source = "registry+https://github.com/rust-lang/crates.io-index"
159
+ checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
160
+ dependencies = [
161
+ "proc-macro2",
162
+ ]
163
+
164
+ [[package]]
165
+ name = "slotmap"
166
+ version = "1.0.7"
167
+ source = "registry+https://github.com/rust-lang/crates.io-index"
168
+ checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a"
169
+ dependencies = [
170
+ "version_check",
171
+ ]
172
+
173
+ [[package]]
174
+ name = "syn"
175
+ version = "2.0.104"
176
+ source = "registry+https://github.com/rust-lang/crates.io-index"
177
+ checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
178
+ dependencies = [
179
+ "proc-macro2",
180
+ "quote",
181
+ "unicode-ident",
182
+ ]
183
+
184
+ [[package]]
185
+ name = "target-lexicon"
186
+ version = "0.13.2"
187
+ source = "registry+https://github.com/rust-lang/crates.io-index"
188
+ checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a"
189
+
190
+ [[package]]
191
+ name = "unicode-ident"
192
+ version = "1.0.18"
193
+ source = "registry+https://github.com/rust-lang/crates.io-index"
194
+ checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
195
+
196
+ [[package]]
197
+ name = "unicode-width"
198
+ version = "0.1.14"
199
+ source = "registry+https://github.com/rust-lang/crates.io-index"
200
+ checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
201
+
202
+ [[package]]
203
+ name = "unindent"
204
+ version = "0.2.4"
205
+ source = "registry+https://github.com/rust-lang/crates.io-index"
206
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
207
+
208
+ [[package]]
209
+ name = "version_check"
210
+ version = "0.9.5"
211
+ source = "registry+https://github.com/rust-lang/crates.io-index"
212
+ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
213
+
214
+ [[package]]
215
+ name = "yansi"
216
+ version = "1.0.1"
217
+ source = "registry+https://github.com/rust-lang/crates.io-index"
218
+ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koatl
3
- Version: 0.2.2
3
+ Version: 0.2.3
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.2.2"
3
+ version = "0.2.3"
4
4
  edition = "2021"
5
5
 
6
6
  [lib]
@@ -512,21 +512,72 @@ trait PyLiteralExt<'src> {
512
512
  impl<'src> PyLiteralExt<'src> for PyLiteral<'src> {
513
513
  fn emit_py<'py>(&self, ctx: &PyCtx<'py, 'src>, span: &Span) -> PyTlResult<PyObject> {
514
514
  Ok(match self {
515
- PyLiteral::Num(num) => {
515
+ PyLiteral::Int(num) => {
516
516
  let num = num.replace('_', "");
517
-
518
517
  match num.parse::<i128>() {
519
518
  Ok(i) => ctx.ast_node("Constant", (i,), span)?,
520
- Err(_) => match num.parse::<f64>() {
521
- Ok(f) => ctx.ast_node("Constant", (f,), span)?,
522
- Err(_) => {
523
- return Err(PyTlErr {
524
- message: format!("Invalid number literal: {}", num),
525
- py_err: None,
526
- span: Some(*span),
527
- });
528
- }
529
- },
519
+ Err(_) => {
520
+ return Err(PyTlErr {
521
+ message: format!("Invalid integer literal: {}", num),
522
+ py_err: None,
523
+ span: Some(*span),
524
+ });
525
+ }
526
+ }
527
+ }
528
+ PyLiteral::IntBin(num) => {
529
+ let num = num.replace('_', "");
530
+ // Keep the 0b prefix for Python compatibility
531
+ match i128::from_str_radix(&num[2..], 2) {
532
+ Ok(i) => ctx.ast_node("Constant", (i,), span)?,
533
+ Err(_) => {
534
+ return Err(PyTlErr {
535
+ message: format!("Invalid binary literal: {}", num),
536
+ py_err: None,
537
+ span: Some(*span),
538
+ });
539
+ }
540
+ }
541
+ }
542
+ PyLiteral::IntOct(num) => {
543
+ let num = num.replace('_', "");
544
+ // Keep the 0o prefix for Python compatibility
545
+ match i128::from_str_radix(&num[2..], 8) {
546
+ Ok(i) => ctx.ast_node("Constant", (i,), span)?,
547
+ Err(_) => {
548
+ return Err(PyTlErr {
549
+ message: format!("Invalid octal literal: {}", num),
550
+ py_err: None,
551
+ span: Some(*span),
552
+ });
553
+ }
554
+ }
555
+ }
556
+ PyLiteral::IntHex(num) => {
557
+ let num = num.replace('_', "");
558
+ // Keep the 0x prefix for Python compatibility
559
+ match i128::from_str_radix(&num[2..], 16) {
560
+ Ok(i) => ctx.ast_node("Constant", (i,), span)?,
561
+ Err(_) => {
562
+ return Err(PyTlErr {
563
+ message: format!("Invalid hexadecimal literal: {}", num),
564
+ py_err: None,
565
+ span: Some(*span),
566
+ });
567
+ }
568
+ }
569
+ }
570
+ PyLiteral::Float(num) => {
571
+ let num = num.replace('_', "");
572
+ match num.parse::<f64>() {
573
+ Ok(f) => ctx.ast_node("Constant", (f,), span)?,
574
+ Err(_) => {
575
+ return Err(PyTlErr {
576
+ message: format!("Invalid float literal: {}", num),
577
+ py_err: None,
578
+ span: Some(*span),
579
+ });
580
+ }
530
581
  }
531
582
  }
532
583
  PyLiteral::Bool(b) => ctx.ast_node("Constant", (b,), span)?,
@@ -0,0 +1,24 @@
1
+ # Test various number literal formats
2
+
3
+ # Integer literals
4
+ let decimal_int = 42
5
+ let decimal_int_underscore = 1_000_000
6
+
7
+ # Binary literals
8
+ let binary = 0b1010
9
+ let binary_underscore = 0b1010_1010
10
+
11
+ # Octal literals
12
+ let octal = 0o755
13
+ let octal_underscore = 0o7_5_5
14
+
15
+ # Hexadecimal literals
16
+ let hex = 0xFF
17
+ let hex_underscore = 0xDEAD_BEEF
18
+
19
+ # Float literals
20
+ let float = 3.14
21
+ let float_underscore = 3.14_159
22
+ let scientific = 1.23e10
23
+ let scientific_neg = 1.23e-10
24
+ let scientific_plus = 1.23e+10
@@ -50,7 +50,12 @@ pub type SIdent<'a> = Spanned<Ident<'a>>;
50
50
 
51
51
  #[derive(Debug, Clone)]
52
52
  pub enum Literal<'a> {
53
- Num(Cow<'a, str>),
53
+ Float(Cow<'a, str>),
54
+ Int(Cow<'a, str>),
55
+ IntHex(Cow<'a, str>),
56
+ IntOct(Cow<'a, str>),
57
+ IntBin(Cow<'a, str>),
58
+
54
59
  Str(Cow<'a, str>),
55
60
  Bool(bool),
56
61
  None,
@@ -190,8 +190,8 @@ impl AstBuilder {
190
190
  }
191
191
 
192
192
  // Literal builders
193
- pub fn num<'src>(&self, value: impl Into<Cow<'src, str>>) -> SExpr<'src> {
194
- Expr::Literal(Literal::Num(value.into()).spanned(self.span)).spanned(self.span)
193
+ pub fn int<'src>(&self, value: impl Into<Cow<'src, str>>) -> SExpr<'src> {
194
+ Expr::Literal(Literal::Int(value.into()).spanned(self.span)).spanned(self.span)
195
195
  }
196
196
 
197
197
  pub fn str<'src>(&self, value: impl Into<Cow<'src, str>>) -> SExpr<'src> {
@@ -120,11 +120,7 @@ pub fn transpile_to_py_ast<'src>(
120
120
 
121
121
  let mut py_ast = output.py_block;
122
122
 
123
- let a = PyAstBuilder::new(Span {
124
- start: 0,
125
- end: 0,
126
- context: (),
127
- });
123
+ let a = PyAstBuilder::new(Span::new(0..0));
128
124
 
129
125
  if options.inject_prelude {
130
126
  py_ast.0.insert(
@@ -218,7 +214,7 @@ pub fn format_errs(errs: &TlErrs, filename: &str, src: &str) -> Vec<u8> {
218
214
  let mut writer = Vec::<u8>::new();
219
215
 
220
216
  for e in &errs.0 {
221
- let range = e.span.map(|e| e.into_range()).unwrap_or(0..0);
217
+ let range = e.span.map(|e| e.start..e.end).unwrap_or(0..0);
222
218
 
223
219
  Report::build(ReportKind::Error, (filename.clone(), range.clone()))
224
220
  .with_config(ariadne::Config::new().with_index_type(ariadne::IndexType::Byte))
@@ -235,7 +231,7 @@ pub fn format_errs(errs: &TlErrs, filename: &str, src: &str) -> Vec<u8> {
235
231
  label.clone()
236
232
  };
237
233
 
238
- Label::new((filename.clone(), span.into_range()))
234
+ Label::new((filename.clone(), span.start..span.end))
239
235
  .with_message(msg)
240
236
  .with_color(Color::Yellow)
241
237
  }))
@@ -256,12 +252,9 @@ pub fn parse_tl<'src>(src: &'src str) -> (Option<SExpr<'src>>, TlErrs) {
256
252
  .into_iter()
257
253
  .map(|e| TlErr {
258
254
  kind: TlErrKind::Tokenize,
259
- message: e.reason().to_string(),
260
- span: Some(*e.span()),
261
- contexts: e
262
- .contexts()
263
- .map(|(label, span)| (label.to_string(), *span))
264
- .collect(),
255
+ message: e.message.to_string(),
256
+ span: Some(e.span),
257
+ contexts: vec![],
265
258
  })
266
259
  .collect(),
267
260
  ));
@@ -278,12 +271,9 @@ pub fn parse_tl<'src>(src: &'src str) -> (Option<SExpr<'src>>, TlErrs) {
278
271
  .into_iter()
279
272
  .map(|e| TlErr {
280
273
  kind: TlErrKind::Parse,
281
- message: e.reason().to_string(),
282
- span: Some(*e.span()),
283
- contexts: e
284
- .contexts()
285
- .map(|(label, span)| (label.to_string(), *span))
286
- .collect(),
274
+ span: Some(e.0),
275
+ message: e.1,
276
+ contexts: vec![],
287
277
  })
288
278
  .collect(),
289
279
  ));
@@ -28,6 +28,19 @@ fn lift_fstr<'src, 'tok>(
28
28
  Token::FstrContinue(s) => s.clone(),
29
29
  _ => panic!("Expected FstrContinue token"),
30
30
  };
31
+
32
+ if fmt_expr.stmts.value.len() == 1 {
33
+ if let cst::Stmt::Expr { expr } = &fmt_expr.stmts.value[0].value {
34
+ return (
35
+ ast::FmtExpr {
36
+ expr: expr.lift(),
37
+ fmt: fmt_expr.fmt.as_ref().map(|(_, fmt)| fmt.lift()),
38
+ },
39
+ cont_str.spanned(cont.span),
40
+ );
41
+ }
42
+ }
43
+
31
44
  (
32
45
  ast::FmtExpr {
33
46
  expr: fmt_expr.stmts.lift(),
@@ -37,6 +50,7 @@ fn lift_fstr<'src, 'tok>(
37
50
  )
38
51
  })
39
52
  .collect();
53
+
40
54
  ast::Expr::Fstr(begin_str.spanned(begin.span), fmt_parts)
41
55
  }
42
56
 
@@ -63,7 +77,11 @@ impl<'src> STokenExt<'src> for SToken<'src> {
63
77
 
64
78
  fn lift_as_literal(&self) -> Spanned<ast::Literal<'src>> {
65
79
  match &self.token {
66
- Token::Num(n) => ast::Literal::Num(Cow::Borrowed(n)),
80
+ Token::Int(n) => ast::Literal::Int(Cow::Borrowed(n)),
81
+ Token::IntHex(n) => ast::Literal::IntHex(Cow::Borrowed(n)),
82
+ Token::IntOct(n) => ast::Literal::IntOct(Cow::Borrowed(n)),
83
+ Token::IntBin(n) => ast::Literal::IntBin(Cow::Borrowed(n)),
84
+ Token::Float(n) => ast::Literal::Float(Cow::Borrowed(n)),
67
85
  Token::Str(s) => ast::Literal::Str(s.clone().into()),
68
86
  Token::Bool(b) => ast::Literal::Bool(*b),
69
87
  Token::None => ast::Literal::None,
@@ -35,7 +35,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
35
35
  },
36
36
  Err(errs) => {
37
37
  errs.0.into_iter().for_each(|e| {
38
- let range = e.span.map(|e| e.into_range()).unwrap_or(0..0);
38
+ let range = e.span.map(|e| e.start..e.end).unwrap_or(0..0);
39
39
  let err_prefix = match e.kind {
40
40
  TlErrKind::Tokenize => "Tokenization Error: ",
41
41
  TlErrKind::Parse => "Parser Error: ",
@@ -53,7 +53,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
53
53
  .with_color(Color::Red),
54
54
  )
55
55
  .with_labels(e.contexts.into_iter().map(|(label, span)| {
56
- Label::new((filename.clone(), span.into_range()))
56
+ Label::new((filename.clone(), span.start..span.end))
57
57
  .with_message(format!("while parsing this {label}"))
58
58
  .with_color(Color::Yellow)
59
59
  }))
@@ -2,7 +2,7 @@ use std::borrow::Cow;
2
2
 
3
3
  use koatl_parser::lexer::Span;
4
4
 
5
- pub type PyIdent<'a> = Cow<'a, str>;
5
+ pub type PyToken<'a> = Cow<'a, str>;
6
6
 
7
7
  #[derive(Debug, Clone, PartialEq)]
8
8
  pub enum PyAccessCtx {
@@ -13,14 +13,14 @@ pub enum PyAccessCtx {
13
13
 
14
14
  #[derive(Debug, Clone)]
15
15
  pub struct PyImportAlias<'a> {
16
- pub name: PyIdent<'a>,
17
- pub as_name: Option<PyIdent<'a>>,
16
+ pub name: PyToken<'a>,
17
+ pub as_name: Option<PyToken<'a>>,
18
18
  }
19
19
 
20
20
  #[derive(Debug, Clone)]
21
21
  pub struct PyExceptHandler<'a> {
22
22
  pub typ: Option<SPyExpr<'a>>,
23
- pub name: Option<PyIdent<'a>>,
23
+ pub name: Option<PyToken<'a>>,
24
24
  pub body: PyBlock<'a>,
25
25
  }
26
26
 
@@ -46,7 +46,7 @@ impl<'a> PyDecorators<'a> {
46
46
 
47
47
  #[derive(Debug, Clone)]
48
48
  pub struct PyFnDef<'a> {
49
- pub name: PyIdent<'a>,
49
+ pub name: PyToken<'a>,
50
50
  pub args: Vec<PyArgDefItem<'a>>,
51
51
  pub body: PyBlock<'a>,
52
52
  pub decorators: PyDecorators<'a>,
@@ -55,7 +55,7 @@ pub struct PyFnDef<'a> {
55
55
 
56
56
  #[derive(Debug, Clone)]
57
57
  pub struct PyClassDef<'a> {
58
- pub name: PyIdent<'a>,
58
+ pub name: PyToken<'a>,
59
59
  pub bases: Vec<PyCallItem<'a>>,
60
60
  pub body: PyBlock<'a>,
61
61
  pub decorators: PyDecorators<'a>,
@@ -71,10 +71,10 @@ pub enum PyStmt<'a> {
71
71
  Return(SPyExpr<'a>),
72
72
  Raise(Option<SPyExpr<'a>>),
73
73
  Assert(SPyExpr<'a>, Option<SPyExpr<'a>>),
74
- Global(Vec<PyIdent<'a>>),
75
- Nonlocal(Vec<PyIdent<'a>>),
74
+ Global(Vec<PyToken<'a>>),
75
+ Nonlocal(Vec<PyToken<'a>>),
76
76
  Import(Vec<PyImportAlias<'a>>),
77
- ImportFrom(Option<PyIdent<'a>>, Vec<PyImportAlias<'a>>, usize),
77
+ ImportFrom(Option<PyToken<'a>>, Vec<PyImportAlias<'a>>, usize),
78
78
  FnDef(PyFnDef<'a>),
79
79
  ClassDef(PyClassDef<'a>),
80
80
  While(SPyExpr<'a>, PyBlock<'a>),
@@ -182,16 +182,16 @@ pub enum PyUnaryOp {
182
182
  #[derive(Debug, Clone)]
183
183
  pub enum PyCallItem<'a> {
184
184
  Arg(SPyExpr<'a>),
185
- Kwarg(PyIdent<'a>, SPyExpr<'a>),
185
+ Kwarg(PyToken<'a>, SPyExpr<'a>),
186
186
  ArgSpread(SPyExpr<'a>),
187
187
  KwargSpread(SPyExpr<'a>),
188
188
  }
189
189
 
190
190
  #[derive(Debug, Clone)]
191
191
  pub enum PyArgDefItem<'a> {
192
- Arg(PyIdent<'a>, Option<SPyExpr<'a>>),
193
- ArgSpread(PyIdent<'a>),
194
- KwargSpread(PyIdent<'a>),
192
+ Arg(PyToken<'a>, Option<SPyExpr<'a>>),
193
+ ArgSpread(PyToken<'a>),
194
+ KwargSpread(PyToken<'a>),
195
195
  }
196
196
 
197
197
  #[derive(Debug, Clone)]
@@ -208,7 +208,7 @@ pub enum PyDictItem<'a> {
208
208
 
209
209
  #[derive(Debug, Clone)]
210
210
  pub enum PyFstrPart<'a> {
211
- Str(PyIdent<'a>),
211
+ Str(PyToken<'a>),
212
212
  Expr(SPyExpr<'a>, Option<SPyExpr<'a>>),
213
213
  }
214
214
 
@@ -216,12 +216,12 @@ pub enum PyFstrPart<'a> {
216
216
  pub enum PyExpr<'a> {
217
217
  Literal(PyLiteral<'a>),
218
218
  Fstr(Vec<PyFstrPart<'a>>),
219
- Name(PyIdent<'a>, PyAccessCtx),
219
+ Name(PyToken<'a>, PyAccessCtx),
220
220
 
221
221
  Binary(PyBinaryOp, Box<SPyExpr<'a>>, Box<SPyExpr<'a>>),
222
222
  Unary(PyUnaryOp, Box<SPyExpr<'a>>),
223
223
  Call(Box<SPyExpr<'a>>, Vec<PyCallItem<'a>>),
224
- Attribute(Box<SPyExpr<'a>>, PyIdent<'a>, PyAccessCtx),
224
+ Attribute(Box<SPyExpr<'a>>, PyToken<'a>, PyAccessCtx),
225
225
  Subscript(Box<SPyExpr<'a>>, Box<SPyExpr<'a>>, PyAccessCtx),
226
226
 
227
227
  IfExpr(Box<SPyExpr<'a>>, Box<SPyExpr<'a>>, Box<SPyExpr<'a>>),
@@ -264,8 +264,12 @@ impl<T> From<(T, Span)> for PySpanned<T> {
264
264
 
265
265
  #[derive(Debug, Clone)]
266
266
  pub enum PyLiteral<'a> {
267
- Num(PyIdent<'a>),
268
- Str(PyIdent<'a>),
267
+ Int(PyToken<'a>),
268
+ IntBin(PyToken<'a>),
269
+ IntOct(PyToken<'a>),
270
+ IntHex(PyToken<'a>),
271
+ Float(PyToken<'a>),
272
+ Str(PyToken<'a>),
269
273
  Bool(bool),
270
274
  None,
271
275
  }
@@ -273,21 +277,21 @@ pub enum PyLiteral<'a> {
273
277
  #[derive(Debug, Clone)]
274
278
  pub enum PyPatternSequenceItem<'a> {
275
279
  Item(SPyPattern<'a>),
276
- Spread(Option<PyIdent<'a>>),
280
+ Spread(Option<PyToken<'a>>),
277
281
  }
278
282
 
279
283
  #[derive(Debug, Clone)]
280
284
  pub enum PyPattern<'a> {
281
285
  Value(SPyExpr<'a>),
282
286
  Singleton(PyLiteral<'a>),
283
- As(Option<Box<SPyPattern<'a>>>, Option<PyIdent<'a>>),
287
+ As(Option<Box<SPyPattern<'a>>>, Option<PyToken<'a>>),
284
288
  Or(Vec<SPyPattern<'a>>),
285
289
  Sequence(Vec<PyPatternSequenceItem<'a>>),
286
- Mapping(Vec<(SPyExpr<'a>, SPyPattern<'a>)>, Option<PyIdent<'a>>),
290
+ Mapping(Vec<(SPyExpr<'a>, SPyPattern<'a>)>, Option<PyToken<'a>>),
287
291
  Class(
288
292
  SPyExpr<'a>,
289
293
  Vec<SPyPattern<'a>>,
290
- Vec<(PyIdent<'a>, SPyPattern<'a>)>,
294
+ Vec<(PyToken<'a>, SPyPattern<'a>)>,
291
295
  ),
292
296
  }
293
297