@devaloop/devalang 0.0.1-beta.2 → 0.1.1

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 (329) hide show
  1. package/README.md +177 -146
  2. package/out-tsc/api.d.ts +180 -0
  3. package/out-tsc/api.d.ts.map +1 -0
  4. package/out-tsc/api.js +286 -0
  5. package/out-tsc/api.js.map +1 -0
  6. package/out-tsc/bin/index.d.ts +12 -0
  7. package/out-tsc/bin/index.d.ts.map +1 -0
  8. package/out-tsc/bin/index.js +20 -54
  9. package/out-tsc/bin/index.js.map +1 -0
  10. package/out-tsc/examples/basic-usage.d.ts +8 -0
  11. package/out-tsc/examples/basic-usage.d.ts.map +1 -0
  12. package/out-tsc/examples/basic-usage.js +113 -0
  13. package/out-tsc/examples/basic-usage.js.map +1 -0
  14. package/out-tsc/index.d.ts +19 -5
  15. package/out-tsc/index.d.ts.map +1 -0
  16. package/out-tsc/index.js +24 -6
  17. package/out-tsc/index.js.map +1 -0
  18. package/out-tsc/scripts/copy-wasm-dts.d.ts +7 -0
  19. package/out-tsc/scripts/copy-wasm-dts.d.ts.map +1 -0
  20. package/out-tsc/scripts/copy-wasm-dts.js +36 -32
  21. package/out-tsc/scripts/copy-wasm-dts.js.map +1 -0
  22. package/out-tsc/scripts/postinstall.d.ts +1 -0
  23. package/out-tsc/scripts/postinstall.d.ts.map +1 -0
  24. package/out-tsc/scripts/postinstall.js +4 -1
  25. package/out-tsc/scripts/postinstall.js.map +1 -0
  26. package/out-tsc/scripts/version/bump.d.ts +5 -1
  27. package/out-tsc/scripts/version/bump.d.ts.map +1 -0
  28. package/out-tsc/scripts/version/bump.js +114 -44
  29. package/out-tsc/scripts/version/bump.js.map +1 -0
  30. package/out-tsc/scripts/version/fetch.d.ts +12 -1
  31. package/out-tsc/scripts/version/fetch.d.ts.map +1 -0
  32. package/out-tsc/scripts/version/fetch.js +68 -24
  33. package/out-tsc/scripts/version/fetch.js.map +1 -0
  34. package/out-tsc/scripts/version/index.d.ts +6 -0
  35. package/out-tsc/scripts/version/index.d.ts.map +1 -0
  36. package/out-tsc/scripts/version/index.js +44 -22
  37. package/out-tsc/scripts/version/index.js.map +1 -0
  38. package/out-tsc/scripts/version/sync.d.ts +5 -1
  39. package/out-tsc/scripts/version/sync.d.ts.map +1 -0
  40. package/out-tsc/scripts/version/sync.js +78 -29
  41. package/out-tsc/scripts/version/sync.js.map +1 -0
  42. package/out-tsc/types.d.ts +68 -0
  43. package/out-tsc/types.d.ts.map +1 -0
  44. package/out-tsc/{core/types/value.js → types.js} +4 -0
  45. package/out-tsc/types.js.map +1 -0
  46. package/out-tsc/wasm.d.ts +8 -0
  47. package/out-tsc/wasm.d.ts.map +1 -0
  48. package/out-tsc/{core/index.js → wasm.js} +9 -6
  49. package/out-tsc/wasm.js.map +1 -0
  50. package/package.json +50 -37
  51. package/.cargo/config.toml +0 -2
  52. package/.devalang +0 -9
  53. package/.github/workflows/ci.yml +0 -103
  54. package/Cargo.toml +0 -81
  55. package/docs/CHANGELOG.md +0 -581
  56. package/docs/CONTRIBUTING.md +0 -101
  57. package/docs/ROADMAP.md +0 -38
  58. package/docs/TODO.md +0 -71
  59. package/examples/automation.deva +0 -42
  60. package/examples/bank.deva +0 -7
  61. package/examples/bus.deva +0 -10
  62. package/examples/condition.deva +0 -20
  63. package/examples/duration.deva +0 -9
  64. package/examples/effect.deva +0 -2
  65. package/examples/events.deva +0 -12
  66. package/examples/filter.deva +0 -11
  67. package/examples/function.deva +0 -15
  68. package/examples/group.deva +0 -12
  69. package/examples/index.deva +0 -63
  70. package/examples/lfo.deva +0 -9
  71. package/examples/loop.deva +0 -10
  72. package/examples/pattern.deva +0 -8
  73. package/examples/plugin.deva +0 -16
  74. package/examples/samples/hat-808.wav +0 -0
  75. package/examples/samples/kick-808.wav +0 -0
  76. package/examples/synth.deva +0 -24
  77. package/examples/synth_types.deva +0 -17
  78. package/examples/variables.deva +0 -9
  79. package/out-tsc/core/functions/index.d.ts +0 -42
  80. package/out-tsc/core/functions/index.js +0 -87
  81. package/out-tsc/core/index.d.ts +0 -6
  82. package/out-tsc/core/types/index.d.ts +0 -4
  83. package/out-tsc/core/types/index.js +0 -20
  84. package/out-tsc/core/types/plugin.d.ts +0 -18
  85. package/out-tsc/core/types/plugin.js +0 -2
  86. package/out-tsc/core/types/result.d.ts +0 -27
  87. package/out-tsc/core/types/result.js +0 -2
  88. package/out-tsc/core/types/statement.d.ts +0 -106
  89. package/out-tsc/core/types/statement.js +0 -2
  90. package/out-tsc/core/types/value.d.ts +0 -43
  91. package/out-tsc/pkg/devalang_core.d.ts +0 -15
  92. package/out-tsc/pkg/devalang_core.js +0 -65
  93. package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +0 -34
  94. package/project-version.json +0 -6
  95. package/rust/cli/bank/api.rs +0 -122
  96. package/rust/cli/bank/commands.rs +0 -306
  97. package/rust/cli/bank/mod.rs +0 -29
  98. package/rust/cli/build/commands.rs +0 -153
  99. package/rust/cli/build/mod.rs +0 -2
  100. package/rust/cli/build/process.rs +0 -165
  101. package/rust/cli/check/mod.rs +0 -208
  102. package/rust/cli/discover/commands.rs +0 -253
  103. package/rust/cli/discover/config.rs +0 -111
  104. package/rust/cli/discover/fs.rs +0 -19
  105. package/rust/cli/discover/install.rs +0 -103
  106. package/rust/cli/discover/metadata.rs +0 -48
  107. package/rust/cli/discover/mod.rs +0 -5
  108. package/rust/cli/init/commands.rs +0 -88
  109. package/rust/cli/init/mod.rs +0 -1
  110. package/rust/cli/install/addon.rs +0 -118
  111. package/rust/cli/install/bank.rs +0 -72
  112. package/rust/cli/install/commands.rs +0 -35
  113. package/rust/cli/install/mod.rs +0 -4
  114. package/rust/cli/install/plugin.rs +0 -80
  115. package/rust/cli/login/commands.rs +0 -124
  116. package/rust/cli/login/mod.rs +0 -1
  117. package/rust/cli/mod.rs +0 -12
  118. package/rust/cli/parser.rs +0 -359
  119. package/rust/cli/play/commands.rs +0 -375
  120. package/rust/cli/play/io.rs +0 -17
  121. package/rust/cli/play/mod.rs +0 -5
  122. package/rust/cli/play/process.rs +0 -159
  123. package/rust/cli/play/realtime.rs +0 -91
  124. package/rust/cli/play/utils.rs +0 -23
  125. package/rust/cli/telemetry/commands.rs +0 -22
  126. package/rust/cli/telemetry/event_creator.rs +0 -80
  127. package/rust/cli/telemetry/mod.rs +0 -3
  128. package/rust/cli/telemetry/send.rs +0 -51
  129. package/rust/cli/template/commands.rs +0 -69
  130. package/rust/cli/template/mod.rs +0 -1
  131. package/rust/cli/update/commands.rs +0 -6
  132. package/rust/cli/update/mod.rs +0 -1
  133. package/rust/config/driver.rs +0 -112
  134. package/rust/config/mod.rs +0 -3
  135. package/rust/config/ops.rs +0 -26
  136. package/rust/config/settings.rs +0 -101
  137. package/rust/core/audio/engine/driver.rs +0 -220
  138. package/rust/core/audio/engine/export.rs +0 -169
  139. package/rust/core/audio/engine/helpers.rs +0 -178
  140. package/rust/core/audio/engine/mod.rs +0 -56
  141. package/rust/core/audio/engine/notes/dsp.rs +0 -85
  142. package/rust/core/audio/engine/notes/mod.rs +0 -44
  143. package/rust/core/audio/engine/notes/params.rs +0 -294
  144. package/rust/core/audio/engine/sample/insert.rs +0 -199
  145. package/rust/core/audio/engine/sample/mod.rs +0 -40
  146. package/rust/core/audio/engine/sample/padding.rs +0 -170
  147. package/rust/core/audio/evaluator/condition.rs +0 -61
  148. package/rust/core/audio/evaluator/mod.rs +0 -9
  149. package/rust/core/audio/evaluator/numeric.rs +0 -152
  150. package/rust/core/audio/evaluator/rhs.rs +0 -16
  151. package/rust/core/audio/evaluator/string_expr.rs +0 -94
  152. package/rust/core/audio/interpreter/driver.rs +0 -574
  153. package/rust/core/audio/interpreter/mod.rs +0 -2
  154. package/rust/core/audio/interpreter/statements/arrow_call/interprete.rs +0 -175
  155. package/rust/core/audio/interpreter/statements/arrow_call/methods/chord.rs +0 -384
  156. package/rust/core/audio/interpreter/statements/arrow_call/methods/mod.rs +0 -2
  157. package/rust/core/audio/interpreter/statements/arrow_call/methods/note.rs +0 -316
  158. package/rust/core/audio/interpreter/statements/arrow_call/mod.rs +0 -3
  159. package/rust/core/audio/interpreter/statements/arrow_call/types/arp.rs +0 -192
  160. package/rust/core/audio/interpreter/statements/arrow_call/types/mod.rs +0 -24
  161. package/rust/core/audio/interpreter/statements/arrow_call/types/pad.rs +0 -116
  162. package/rust/core/audio/interpreter/statements/arrow_call/types/pluck.rs +0 -97
  163. package/rust/core/audio/interpreter/statements/arrow_call/types/sub.rs +0 -100
  164. package/rust/core/audio/interpreter/statements/automate.rs +0 -16
  165. package/rust/core/audio/interpreter/statements/call.rs +0 -295
  166. package/rust/core/audio/interpreter/statements/condition.rs +0 -72
  167. package/rust/core/audio/interpreter/statements/function.rs +0 -24
  168. package/rust/core/audio/interpreter/statements/let_.rs +0 -36
  169. package/rust/core/audio/interpreter/statements/load.rs +0 -17
  170. package/rust/core/audio/interpreter/statements/loop_.rs +0 -115
  171. package/rust/core/audio/interpreter/statements/mod.rs +0 -12
  172. package/rust/core/audio/interpreter/statements/sleep.rs +0 -28
  173. package/rust/core/audio/interpreter/statements/spawn.rs +0 -253
  174. package/rust/core/audio/interpreter/statements/tempo.rs +0 -40
  175. package/rust/core/audio/interpreter/statements/trigger.rs +0 -239
  176. package/rust/core/audio/loader/mod.rs +0 -1
  177. package/rust/core/audio/loader/trigger.rs +0 -98
  178. package/rust/core/audio/mod.rs +0 -6
  179. package/rust/core/audio/player.rs +0 -70
  180. package/rust/core/audio/special/easing.rs +0 -189
  181. package/rust/core/audio/special/env.rs +0 -45
  182. package/rust/core/audio/special/math.rs +0 -134
  183. package/rust/core/audio/special/mod.rs +0 -9
  184. package/rust/core/audio/special/modulator.rs +0 -143
  185. package/rust/core/builder/mod.rs +0 -129
  186. package/rust/core/debugger/lexer.rs +0 -27
  187. package/rust/core/debugger/logs.rs +0 -52
  188. package/rust/core/debugger/mod.rs +0 -30
  189. package/rust/core/debugger/preprocessor.rs +0 -27
  190. package/rust/core/debugger/store.rs +0 -38
  191. package/rust/core/error/mod.rs +0 -269
  192. package/rust/core/lexer/driver.rs +0 -59
  193. package/rust/core/lexer/handler/arrow.rs +0 -82
  194. package/rust/core/lexer/handler/at.rs +0 -21
  195. package/rust/core/lexer/handler/brace.rs +0 -41
  196. package/rust/core/lexer/handler/colon.rs +0 -21
  197. package/rust/core/lexer/handler/comment.rs +0 -30
  198. package/rust/core/lexer/handler/dot.rs +0 -21
  199. package/rust/core/lexer/handler/driver.rs +0 -337
  200. package/rust/core/lexer/handler/identifier.rs +0 -47
  201. package/rust/core/lexer/handler/indent.rs +0 -66
  202. package/rust/core/lexer/handler/mod.rs +0 -15
  203. package/rust/core/lexer/handler/newline.rs +0 -23
  204. package/rust/core/lexer/handler/number.rs +0 -31
  205. package/rust/core/lexer/handler/operator.rs +0 -46
  206. package/rust/core/lexer/handler/parenthesis.rs +0 -41
  207. package/rust/core/lexer/handler/slash.rs +0 -21
  208. package/rust/core/lexer/handler/string.rs +0 -63
  209. package/rust/core/lexer/mod.rs +0 -3
  210. package/rust/core/lexer/token.rs +0 -91
  211. package/rust/core/mod.rs +0 -9
  212. package/rust/core/parser/driver/block.rs +0 -111
  213. package/rust/core/parser/driver/cursor.rs +0 -82
  214. package/rust/core/parser/driver/driver_impl.rs +0 -139
  215. package/rust/core/parser/driver/mod.rs +0 -6
  216. package/rust/core/parser/driver/parse_array.rs +0 -120
  217. package/rust/core/parser/driver/parse_map.rs +0 -223
  218. package/rust/core/parser/driver/parser.rs +0 -160
  219. package/rust/core/parser/handler/arrow_call.rs +0 -277
  220. package/rust/core/parser/handler/at.rs +0 -279
  221. package/rust/core/parser/handler/bank.rs +0 -104
  222. package/rust/core/parser/handler/condition.rs +0 -83
  223. package/rust/core/parser/handler/dot.rs +0 -148
  224. package/rust/core/parser/handler/identifier/automate.rs +0 -254
  225. package/rust/core/parser/handler/identifier/call.rs +0 -91
  226. package/rust/core/parser/handler/identifier/emit.rs +0 -70
  227. package/rust/core/parser/handler/identifier/function.rs +0 -113
  228. package/rust/core/parser/handler/identifier/group.rs +0 -89
  229. package/rust/core/parser/handler/identifier/let_.rs +0 -173
  230. package/rust/core/parser/handler/identifier/mod.rs +0 -55
  231. package/rust/core/parser/handler/identifier/on.rs +0 -107
  232. package/rust/core/parser/handler/identifier/print.rs +0 -49
  233. package/rust/core/parser/handler/identifier/sleep.rs +0 -96
  234. package/rust/core/parser/handler/identifier/spawn.rs +0 -91
  235. package/rust/core/parser/handler/identifier/synth.rs +0 -135
  236. package/rust/core/parser/handler/loop_.rs +0 -194
  237. package/rust/core/parser/handler/mod.rs +0 -9
  238. package/rust/core/parser/handler/pattern.rs +0 -74
  239. package/rust/core/parser/handler/tempo.rs +0 -105
  240. package/rust/core/parser/mod.rs +0 -3
  241. package/rust/core/parser/statement.rs +0 -10
  242. package/rust/core/plugin/loader.rs +0 -137
  243. package/rust/core/plugin/mod.rs +0 -2
  244. package/rust/core/plugin/runner/mod.rs +0 -11
  245. package/rust/core/plugin/runner/non_wasm.rs +0 -297
  246. package/rust/core/plugin/runner/wasm32.rs +0 -43
  247. package/rust/core/preprocessor/loader/inject.rs +0 -278
  248. package/rust/core/preprocessor/loader/loader_helpers.rs +0 -110
  249. package/rust/core/preprocessor/loader/mod.rs +0 -235
  250. package/rust/core/preprocessor/mod.rs +0 -4
  251. package/rust/core/preprocessor/module.rs +0 -55
  252. package/rust/core/preprocessor/processor/handlers.rs +0 -107
  253. package/rust/core/preprocessor/processor/mod.rs +0 -1
  254. package/rust/core/preprocessor/resolver/bank.rs +0 -49
  255. package/rust/core/preprocessor/resolver/call.rs +0 -124
  256. package/rust/core/preprocessor/resolver/condition.rs +0 -95
  257. package/rust/core/preprocessor/resolver/driver.rs +0 -324
  258. package/rust/core/preprocessor/resolver/function.rs +0 -69
  259. package/rust/core/preprocessor/resolver/group.rs +0 -122
  260. package/rust/core/preprocessor/resolver/let_.rs +0 -32
  261. package/rust/core/preprocessor/resolver/loop_.rs +0 -318
  262. package/rust/core/preprocessor/resolver/mod.rs +0 -16
  263. package/rust/core/preprocessor/resolver/pattern.rs +0 -83
  264. package/rust/core/preprocessor/resolver/spawn.rs +0 -99
  265. package/rust/core/preprocessor/resolver/synth.rs +0 -54
  266. package/rust/core/preprocessor/resolver/tempo.rs +0 -48
  267. package/rust/core/preprocessor/resolver/trigger.rs +0 -116
  268. package/rust/core/preprocessor/resolver/value.rs +0 -176
  269. package/rust/core/store/global.rs +0 -57
  270. package/rust/core/store/mod.rs +0 -1
  271. package/rust/lib.rs +0 -323
  272. package/rust/main.rs +0 -388
  273. package/rust/types/Cargo.toml +0 -11
  274. package/rust/types/src/addons.rs +0 -55
  275. package/rust/types/src/ast.rs +0 -202
  276. package/rust/types/src/config.rs +0 -84
  277. package/rust/types/src/lib.rs +0 -15
  278. package/rust/types/src/plugin.rs +0 -20
  279. package/rust/types/src/store.rs +0 -139
  280. package/rust/types/src/telemetry.rs +0 -85
  281. package/rust/utils/Cargo.toml +0 -26
  282. package/rust/utils/src/error.rs +0 -186
  283. package/rust/utils/src/file.rs +0 -94
  284. package/rust/utils/src/first_usage.rs +0 -97
  285. package/rust/utils/src/lib.rs +0 -9
  286. package/rust/utils/src/logger.rs +0 -200
  287. package/rust/utils/src/path.rs +0 -129
  288. package/rust/utils/src/signature.rs +0 -41
  289. package/rust/utils/src/spinner.rs +0 -20
  290. package/rust/utils/src/version.rs +0 -27
  291. package/rust/utils/src/watcher.rs +0 -46
  292. package/rust/web/api.rs +0 -5
  293. package/rust/web/cdn.rs +0 -34
  294. package/rust/web/mod.rs +0 -3
  295. package/rust/web/sso.rs +0 -5
  296. package/templates/minimal/.devalang +0 -5
  297. package/templates/minimal/README.md +0 -218
  298. package/templates/minimal/src/index.deva +0 -2
  299. package/templates/welcome/.devalang +0 -5
  300. package/templates/welcome/README.md +0 -218
  301. package/templates/welcome/samples/kick-808.wav +0 -0
  302. package/templates/welcome/src/index.deva +0 -61
  303. package/templates/welcome/src/variables.deva +0 -3
  304. package/tests/integration.rs +0 -21
  305. package/tests/rust/cli_check_build.rs +0 -21
  306. package/tests/rust/cli_help.rs +0 -12
  307. package/tests/rust/cli_template_list.rs +0 -10
  308. package/tests/rust/cli_version.rs +0 -11
  309. package/tests/typescript/index.spec.ts +0 -136
  310. package/tests/typescript/playhead.spec.ts +0 -36
  311. package/tests/typescript/render_e2e.spec.ts +0 -77
  312. package/tsconfig.json +0 -115
  313. package/typescript/bin/index.ts +0 -28
  314. package/typescript/core/functions/index.ts +0 -94
  315. package/typescript/core/index.ts +0 -6
  316. package/typescript/core/types/index.ts +0 -4
  317. package/typescript/core/types/plugin.ts +0 -19
  318. package/typescript/core/types/result.ts +0 -29
  319. package/typescript/core/types/statement.ts +0 -47
  320. package/typescript/core/types/value.ts +0 -29
  321. package/typescript/index.ts +0 -8
  322. package/typescript/pkg/devalang_core.d.ts +0 -4
  323. package/typescript/pkg/devalang_core.ts +0 -65
  324. package/typescript/scripts/copy-wasm-dts.ts +0 -41
  325. package/typescript/scripts/postinstall.ts +0 -85
  326. package/typescript/scripts/version/bump.ts +0 -44
  327. package/typescript/scripts/version/fetch.ts +0 -18
  328. package/typescript/scripts/version/index.ts +0 -25
  329. package/typescript/scripts/version/sync.ts +0 -24
@@ -1,113 +0,0 @@
1
- use devalang_types::Value;
2
-
3
- use crate::core::{
4
- lexer::token::TokenKind,
5
- parser::{
6
- driver::parser::Parser,
7
- statement::{Statement, StatementKind},
8
- },
9
- store::global::GlobalStore,
10
- };
11
-
12
- pub fn parse_function_token(parser: &mut Parser, global_store: &mut GlobalStore) -> Statement {
13
- parser.advance(); // consume 'fn'
14
-
15
- let fn_token = match parser.previous_clone() {
16
- Some(tok) => tok,
17
- None => return Statement::unknown(),
18
- };
19
-
20
- let name_token = match parser.peek_clone() {
21
- Some(tok) => tok,
22
- None => {
23
- return crate::core::parser::statement::error_from_token(
24
- fn_token,
25
- "Expected function name after 'fn'".to_string(),
26
- );
27
- }
28
- };
29
-
30
- if name_token.kind != TokenKind::Identifier {
31
- return crate::core::parser::statement::error_from_token(
32
- name_token.clone(),
33
- "Expected function name to be an identifier".to_string(),
34
- );
35
- }
36
-
37
- let function_name = name_token.lexeme.clone();
38
- parser.advance(); // consume function name
39
-
40
- let mut parameters = Vec::new();
41
-
42
- // Expect '('
43
- if parser.peek_kind() != Some(TokenKind::LParen) {
44
- return crate::core::parser::statement::error_from_token(
45
- name_token.clone(),
46
- "Expected '(' after function name".to_string(),
47
- );
48
- }
49
- parser.advance(); // consume '('
50
-
51
- // Parse parameters until ')'
52
- let tokens = parser.collect_until(|t| t.kind == TokenKind::RParen || t.kind == TokenKind::EOF);
53
- for token in tokens {
54
- if token.kind == TokenKind::Identifier {
55
- parameters.push(token.lexeme.clone());
56
- }
57
- }
58
-
59
- if parser.peek_kind() == Some(TokenKind::RParen) {
60
- parser.advance(); // consume ')'
61
- } else {
62
- return crate::core::parser::statement::error_from_token(
63
- name_token.clone(),
64
- "Expected ')' after parameters".to_string(),
65
- );
66
- }
67
-
68
- // Expect colon
69
- if parser.peek_kind() != Some(TokenKind::Colon) {
70
- return crate::core::parser::statement::error_from_token(
71
- name_token.clone(),
72
- "Expected ':' after ')'".to_string(),
73
- );
74
- }
75
- parser.advance(); // consume ':'
76
-
77
- // Collect ALL tokens indented after this line until Dedent
78
- let base_indent = fn_token.indent;
79
- let mut body_tokens = Vec::new();
80
-
81
- while let Some(tok) = parser.peek() {
82
- if tok.kind == TokenKind::Dedent && tok.indent <= base_indent {
83
- break;
84
- }
85
- if let Some(t) = parser.advance() {
86
- body_tokens.push(t.clone());
87
- } else {
88
- break;
89
- }
90
- }
91
-
92
- // Parse those tokens into block statements
93
- let body = parser.parse_block(body_tokens.clone(), global_store);
94
-
95
- // Skip Dedent if present
96
- if let Some(tok) = parser.peek() {
97
- if tok.kind == TokenKind::Dedent {
98
- parser.advance();
99
- }
100
- }
101
-
102
- Statement {
103
- kind: StatementKind::Function {
104
- name: function_name.clone(),
105
- parameters: parameters.clone(),
106
- body: body.clone(),
107
- },
108
- value: Value::Null,
109
- indent: fn_token.indent,
110
- line: fn_token.line,
111
- column: fn_token.column,
112
- }
113
- }
@@ -1,89 +0,0 @@
1
- use devalang_types::Value;
2
-
3
- use crate::core::{
4
- lexer::token::{Token, TokenKind},
5
- parser::{
6
- driver::parser::Parser,
7
- statement::{Statement, StatementKind},
8
- },
9
- store::global::GlobalStore,
10
- };
11
- use std::collections::HashMap;
12
-
13
- pub fn parse_group_token(
14
- parser: &mut Parser,
15
- current_token: Token,
16
- global_store: &mut GlobalStore,
17
- ) -> Statement {
18
- parser.advance(); // consume "group"
19
-
20
- let Some(identifier_token) = parser.peek_clone() else {
21
- return crate::core::parser::statement::error_from_token(
22
- current_token,
23
- "Expected identifier after 'group'".to_string(),
24
- );
25
- };
26
-
27
- if identifier_token.kind != TokenKind::Identifier && identifier_token.kind != TokenKind::String
28
- {
29
- return crate::core::parser::statement::error_from_token(
30
- identifier_token,
31
- "Expected valid identifier".to_string(),
32
- );
33
- }
34
-
35
- parser.advance(); // consume identifier
36
-
37
- let Some(colon_token) = parser.peek_clone() else {
38
- return crate::core::parser::statement::error_from_token(
39
- identifier_token,
40
- "Expected ':' after group identifier".to_string(),
41
- );
42
- };
43
-
44
- if colon_token.kind != TokenKind::Colon {
45
- return crate::core::parser::statement::error_from_token(
46
- colon_token.clone(),
47
- "Expected ':' after group identifier".to_string(),
48
- );
49
- }
50
-
51
- parser.advance(); // consume ':'
52
-
53
- let base_indent = current_token.indent;
54
-
55
- // Clone without consuming tokens
56
- let mut index = parser.token_index;
57
- let mut tokens_inside_group = Vec::new();
58
-
59
- while index < parser.tokens.len() {
60
- let token = parser.tokens[index].clone();
61
-
62
- if token.indent <= base_indent && token.kind != TokenKind::Newline {
63
- break;
64
- }
65
-
66
- tokens_inside_group.push(token);
67
- index += 1;
68
- }
69
-
70
- // Advance index once to skip the processed tokens
71
- parser.token_index = index;
72
-
73
- let body = parser.parse_block(tokens_inside_group, global_store);
74
-
75
- let mut value_map = HashMap::new();
76
- value_map.insert(
77
- "identifier".to_string(),
78
- Value::String(identifier_token.lexeme.clone()),
79
- );
80
- value_map.insert("body".to_string(), Value::Block(body));
81
-
82
- Statement {
83
- kind: StatementKind::Group,
84
- value: Value::Map(value_map),
85
- indent: current_token.indent,
86
- line: current_token.line,
87
- column: current_token.column,
88
- }
89
- }
@@ -1,173 +0,0 @@
1
- use std::collections::HashMap;
2
-
3
- use crate::core::{
4
- lexer::token::{Token, TokenKind},
5
- parser::{
6
- driver::parser::Parser,
7
- handler::{dot::parse_dot_token, identifier::synth::parse_synth_token},
8
- statement::{Statement, StatementKind},
9
- },
10
- store::global::GlobalStore,
11
- };
12
- use devalang_types::Value;
13
-
14
- pub fn parse_let_token(
15
- parser: &mut Parser,
16
- current_token: Token,
17
- global_store: &mut GlobalStore,
18
- ) -> Statement {
19
- parser.advance(); // consume "let"
20
-
21
- let identifier = if let Some(token) = parser.peek_clone() {
22
- if token.kind == TokenKind::Identifier {
23
- parser.advance();
24
- token.lexeme.clone()
25
- } else {
26
- return crate::core::parser::statement::error_from_token(
27
- token,
28
- "Expected identifier after 'let'".to_string(),
29
- );
30
- }
31
- } else {
32
- return crate::core::parser::statement::error_from_token(
33
- current_token,
34
- "Expected identifier after 'let'".to_string(),
35
- );
36
- };
37
-
38
- if !parser.match_token(TokenKind::Equals) {
39
- return crate::core::parser::statement::error_from_token(
40
- current_token,
41
- "Expected '=' after identifier".to_string(),
42
- );
43
- }
44
-
45
- // If RHS begins with '$' or contains expression tokens ('+', '-', '*', '/', '(', '['),
46
- // collect the rest of the line as a raw expression string.
47
- if let Some(tok) = parser.peek_clone() {
48
- let line = tok.line;
49
- if tok.lexeme.starts_with('$')
50
- || matches!(
51
- tok.kind,
52
- TokenKind::Identifier | TokenKind::Number | TokenKind::LParen | TokenKind::LBracket
53
- )
54
- {
55
- // Collect tokens until end of the current line
56
- let collected = parser.collect_until(|t| {
57
- t.line != line || matches!(t.kind, TokenKind::Newline | TokenKind::EOF)
58
- });
59
- let mut text = String::new();
60
- for t in collected.iter() {
61
- if matches!(t.kind, TokenKind::Newline | TokenKind::EOF) {
62
- break;
63
- }
64
- text.push_str(&t.lexeme);
65
- }
66
- return Statement {
67
- kind: StatementKind::Let { name: identifier },
68
- value: Value::String(text.trim().to_string()),
69
- indent: current_token.indent,
70
- line: current_token.line,
71
- column: current_token.column,
72
- };
73
- }
74
- }
75
-
76
- let value = match parser.peek_clone() {
77
- Some(token) if token.kind == TokenKind::Dot => {
78
- let dot_stmt = parse_dot_token(parser, global_store);
79
- Value::Statement(Box::new(dot_stmt))
80
- }
81
- Some(token) if token.kind == TokenKind::Synth => {
82
- let synth_stmt = parse_synth_token(parser, token.clone(), global_store);
83
- Value::Statement(Box::new(synth_stmt))
84
- }
85
- Some(token) if token.kind == TokenKind::Identifier => {
86
- parser.advance();
87
- Value::Identifier(token.lexeme.clone())
88
- }
89
- Some(token) if token.kind == TokenKind::String => {
90
- parser.advance();
91
- Value::String(token.lexeme.clone())
92
- }
93
- Some(token) if token.kind == TokenKind::Number => {
94
- parser.advance();
95
- Value::Number(token.lexeme.parse().unwrap_or(0.0))
96
- }
97
- Some(token) if token.kind == TokenKind::Boolean => {
98
- parser.advance();
99
- Value::Boolean(token.lexeme.parse().unwrap_or(false))
100
- }
101
- Some(token) if token.kind == TokenKind::LBrace => {
102
- parser.advance();
103
-
104
- let mut map = HashMap::new();
105
-
106
- while let Some(key_token) = parser.peek_clone() {
107
- if key_token.kind == TokenKind::RBrace {
108
- parser.advance(); // consume '}'
109
- break;
110
- }
111
-
112
- if key_token.kind != TokenKind::Identifier {
113
- return crate::core::parser::statement::error_from_token(
114
- token,
115
- "Expected key identifier in map".to_string(),
116
- );
117
- }
118
- parser.advance();
119
- let key = key_token.lexeme.clone();
120
-
121
- if !parser.match_token(TokenKind::Colon) {
122
- let message = format!("Expected ':' after key '{}'", key);
123
- return crate::core::parser::statement::error_from_token(token, message);
124
- }
125
-
126
- let val = match parser.peek_clone() {
127
- Some(t) if t.kind == TokenKind::Number => {
128
- parser.advance();
129
- Value::Number(t.lexeme.parse().unwrap_or(0.0))
130
- }
131
- Some(t) if t.kind == TokenKind::String => {
132
- parser.advance();
133
- Value::String(t.lexeme.clone())
134
- }
135
- Some(t) if t.kind == TokenKind::Identifier => {
136
- parser.advance();
137
- Value::Identifier(t.lexeme.clone())
138
- }
139
- _ => Value::Null,
140
- };
141
-
142
- if val == Value::Null {
143
- let message = format!("Invalid value for key '{}'", key);
144
- return crate::core::parser::statement::error_from_token(token, message);
145
- }
146
-
147
- map.insert(key, val);
148
-
149
- if let Some(t) = parser.peek() {
150
- if t.kind == TokenKind::Comma {
151
- parser.advance(); // skip comma
152
- }
153
- }
154
- }
155
-
156
- Value::Map(map)
157
- }
158
- _ => {
159
- return crate::core::parser::statement::error_from_token(
160
- current_token,
161
- "Unhandled value type after '='".to_string(),
162
- );
163
- }
164
- };
165
-
166
- Statement {
167
- kind: StatementKind::Let { name: identifier },
168
- value,
169
- indent: current_token.indent,
170
- line: current_token.line,
171
- column: current_token.column,
172
- }
173
- }
@@ -1,55 +0,0 @@
1
- pub mod automate;
2
- pub mod call;
3
- pub mod emit;
4
- pub mod function;
5
- pub mod group;
6
- pub mod let_;
7
- pub mod on;
8
- pub mod print;
9
- pub mod sleep;
10
- pub mod spawn;
11
- pub mod synth;
12
-
13
- use crate::core::{
14
- parser::{
15
- driver::parser::Parser,
16
- handler::identifier::{
17
- automate::parse_automate_token, call::parse_call_token, emit::parse_emit_token,
18
- group::parse_group_token, let_::parse_let_token, on::parse_on_token,
19
- print::parse_print_token, sleep::parse_sleep_token, spawn::parse_spawn_token,
20
- synth::parse_synth_token,
21
- },
22
- statement::Statement,
23
- },
24
- store::global::GlobalStore,
25
- };
26
-
27
- pub fn parse_identifier_token(parser: &mut Parser, global_store: &mut GlobalStore) -> Statement {
28
- let Some(current_token) = parser.peek_clone() else {
29
- return Statement::unknown();
30
- };
31
-
32
- let current_token_clone = current_token.clone();
33
- let current_token_lexeme = current_token_clone.lexeme.clone();
34
-
35
- match current_token_lexeme.as_str() {
36
- "let" => parse_let_token(parser, current_token_clone, global_store),
37
- "group" => parse_group_token(parser, current_token_clone, global_store),
38
- "call" => parse_call_token(parser, current_token_clone, global_store),
39
- "spawn" => parse_spawn_token(parser, current_token_clone, global_store),
40
- "sleep" => parse_sleep_token(parser, current_token_clone, global_store),
41
- "synth" => parse_synth_token(parser, current_token_clone, global_store),
42
- "automate" => parse_automate_token(parser, current_token_clone, global_store),
43
- "print" => parse_print_token(parser, current_token_clone, global_store),
44
- "on" => parse_on_token(parser, global_store),
45
- "emit" => parse_emit_token(parser, current_token_clone, global_store),
46
- _ => {
47
- parser.advance(); // consume identifier
48
-
49
- crate::core::parser::statement::error_from_token(
50
- current_token_clone,
51
- "Unexpected identifier".to_string(),
52
- )
53
- }
54
- }
55
- }
@@ -1,107 +0,0 @@
1
- use devalang_types::Value;
2
-
3
- use crate::core::{
4
- lexer::token::TokenKind,
5
- parser::{
6
- driver::parser::Parser,
7
- statement::{Statement, StatementKind},
8
- },
9
- store::global::GlobalStore,
10
- };
11
-
12
- pub fn parse_on_token(parser: &mut Parser, _global_store: &mut GlobalStore) -> Statement {
13
- // consume 'on'
14
- let on_tok = match parser.peek_clone() {
15
- Some(tok) => tok,
16
- None => return Statement::unknown(),
17
- };
18
- parser.advance();
19
-
20
- // Expect event name identifier
21
- let event_tok = match parser.peek_clone() {
22
- Some(tok) if tok.kind == TokenKind::Identifier => tok,
23
- Some(other) => {
24
- return crate::core::parser::statement::error_from_token(
25
- other,
26
- "Expected event name after 'on'".to_string(),
27
- );
28
- }
29
- None => {
30
- return crate::core::parser::statement::error_from_token(
31
- on_tok,
32
- "Expected event name after 'on'".to_string(),
33
- );
34
- }
35
- };
36
- let event_name = event_tok.lexeme.clone();
37
- parser.advance();
38
-
39
- // Optional parenthesized args on same line
40
- let mut args: Option<Vec<Value>> = None;
41
- if parser.peek_kind() == Some(TokenKind::LParen) {
42
- parser.advance(); // '('
43
- let mut collected: Vec<Value> = Vec::new();
44
- // Collect tokens until ')', supporting numbers and identifiers separated by comma
45
- while let Some(tok) = parser.peek_clone() {
46
- match tok.kind {
47
- TokenKind::RParen => {
48
- parser.advance();
49
- break;
50
- }
51
- TokenKind::Number => {
52
- parser.advance();
53
- collected.push(Value::Number(tok.lexeme.parse().unwrap_or(0.0)));
54
- }
55
- TokenKind::Identifier => {
56
- parser.advance();
57
- collected.push(Value::Identifier(tok.lexeme));
58
- }
59
- TokenKind::Comma => {
60
- parser.advance();
61
- }
62
- TokenKind::Whitespace | TokenKind::Newline => {
63
- parser.advance();
64
- }
65
- _ => {
66
- break;
67
- }
68
- }
69
- }
70
- if !collected.is_empty() {
71
- args = Some(collected);
72
- }
73
- }
74
-
75
- // Expect ':' then block
76
- if parser.peek_kind() != Some(TokenKind::Colon) {
77
- return crate::core::parser::statement::error_from_token(
78
- event_tok,
79
- "Expected ':' after event name".to_string(),
80
- );
81
- }
82
- parser.advance(); // consume ':'
83
-
84
- let base_indent = on_tok.indent;
85
- let block_tokens = parser.collect_block_tokens(base_indent);
86
- // Parse body within current store context
87
- let body = parser.parse_block(block_tokens, _global_store);
88
-
89
- let stmt = Statement {
90
- kind: StatementKind::On {
91
- event: event_name,
92
- args,
93
- body,
94
- },
95
- value: Value::Null,
96
- indent: on_tok.indent,
97
- line: on_tok.line,
98
- column: on_tok.column,
99
- };
100
-
101
- // Register in global store for later emission
102
- if let StatementKind::On { event, .. } = &stmt.kind {
103
- _global_store.register_event_handler(event, stmt.clone());
104
- }
105
-
106
- stmt
107
- }
@@ -1,49 +0,0 @@
1
- use crate::core::{
2
- lexer::token::{Token, TokenKind},
3
- parser::{
4
- driver::parser::Parser,
5
- statement::{Statement, StatementKind},
6
- },
7
- store::global::GlobalStore,
8
- };
9
- use devalang_types::Value;
10
-
11
- pub fn parse_print_token(
12
- parser: &mut Parser,
13
- current_token: Token,
14
- _global_store: &mut GlobalStore,
15
- ) -> Statement {
16
- // consume 'print'
17
- parser.advance();
18
-
19
- let collected = parser.collect_until(|t| matches!(t.kind, TokenKind::Newline | TokenKind::EOF));
20
- // Accept: print <identifier|string|number|expression>
21
- let value = if collected.len() == 1 {
22
- match collected[0].kind {
23
- TokenKind::Identifier => Value::Identifier(collected[0].lexeme.clone()),
24
- TokenKind::String => Value::String(collected[0].lexeme.clone()),
25
- TokenKind::Number => {
26
- let n = collected[0].lexeme.parse::<f32>().unwrap_or(0.0);
27
- Value::Number(n)
28
- }
29
- _ => Value::String(collected[0].lexeme.clone()),
30
- }
31
- } else {
32
- // Join tokens with spaces to preserve readability for expressions/text
33
- let text = collected
34
- .iter()
35
- .filter(|t| !matches!(t.kind, TokenKind::Newline | TokenKind::EOF))
36
- .map(|t| t.lexeme.clone())
37
- .collect::<Vec<_>>()
38
- .join(" ");
39
- Value::String(text.trim().to_string())
40
- };
41
-
42
- Statement {
43
- kind: StatementKind::Print,
44
- value,
45
- indent: current_token.indent,
46
- line: current_token.line,
47
- column: current_token.column,
48
- }
49
- }
@@ -1,96 +0,0 @@
1
- use devalang_types::Value;
2
-
3
- use crate::core::{
4
- lexer::token::{Token, TokenKind},
5
- parser::{
6
- driver::parser::Parser,
7
- statement::{Statement, StatementKind},
8
- },
9
- store::global::GlobalStore,
10
- };
11
-
12
- pub fn parse_sleep_token(
13
- parser: &mut Parser,
14
- current_token: Token,
15
- _global_store: &mut GlobalStore,
16
- ) -> Statement {
17
- parser.advance(); // consume "sleep"
18
-
19
- // Accept number, decimal, fraction like 1/4 (-> Duration::Beat), string, or identifier
20
- let duration_value = if let Some(token) = parser.peek_clone() {
21
- match token.kind {
22
- TokenKind::Number => {
23
- let mut num = token.lexeme.clone();
24
- parser.advance();
25
- // decimal part
26
- if let Some(dot) = parser.peek_clone() {
27
- if dot.kind == TokenKind::Dot {
28
- if let Some(next) = parser.peek_nth(1).cloned() {
29
- if next.kind == TokenKind::Number {
30
- parser.advance(); // consume dot
31
- parser.advance(); // consume next number
32
- num.push('.');
33
- num.push_str(&next.lexeme);
34
- }
35
- }
36
- }
37
- }
38
-
39
- // fraction form 1/4 -> Duration::Beat("1/4")
40
- if let Some(slash) = parser.peek_clone() {
41
- if slash.kind == TokenKind::Slash {
42
- parser.advance();
43
- if let Some(den) = parser.peek_clone() {
44
- if den.kind == TokenKind::Number || den.kind == TokenKind::Identifier {
45
- let frac = format!("{}/{}", num, den.lexeme);
46
- parser.advance();
47
- Value::Duration(devalang_types::Duration::Beat(frac))
48
- } else {
49
- return crate::core::parser::statement::error_from_token(
50
- slash,
51
- "Expected denominator after '/' in sleep".to_string(),
52
- );
53
- }
54
- } else {
55
- return crate::core::parser::statement::error_from_token(
56
- slash,
57
- "Expected denominator after '/' in sleep".to_string(),
58
- );
59
- }
60
- } else {
61
- Value::Number(num.parse().unwrap_or(0.0))
62
- }
63
- } else {
64
- Value::Number(num.parse().unwrap_or(0.0))
65
- }
66
- }
67
- TokenKind::String => {
68
- parser.advance();
69
- Value::String(token.lexeme.clone())
70
- }
71
- TokenKind::Identifier => {
72
- parser.advance();
73
- Value::Identifier(token.lexeme.clone())
74
- }
75
- _ => {
76
- return crate::core::parser::statement::error_from_token(
77
- token,
78
- "Expected duration after 'sleep'".to_string(),
79
- );
80
- }
81
- }
82
- } else {
83
- return crate::core::parser::statement::error_from_token(
84
- current_token,
85
- "Expected duration after 'sleep'".to_string(),
86
- );
87
- };
88
-
89
- Statement {
90
- kind: StatementKind::Sleep,
91
- value: duration_value,
92
- indent: current_token.indent,
93
- line: current_token.line,
94
- column: current_token.column,
95
- }
96
- }