@devaloop/devalang 0.0.1-alpha.11 → 0.0.1-alpha.13

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 (66) hide show
  1. package/.devalang +8 -8
  2. package/Cargo.toml +8 -8
  3. package/README.md +1 -14
  4. package/docs/CHANGELOG.md +44 -0
  5. package/docs/TODO.md +1 -1
  6. package/examples/index.deva +10 -11
  7. package/out-tsc/bin/devalang.exe +0 -0
  8. package/package.json +2 -1
  9. package/project-version.json +3 -3
  10. package/rust/cli/build.rs +25 -2
  11. package/rust/cli/check.rs +26 -3
  12. package/rust/cli/play.rs +1 -1
  13. package/rust/core/audio/engine.rs +207 -41
  14. package/rust/core/audio/interpreter/call.rs +72 -47
  15. package/rust/core/audio/interpreter/condition.rs +14 -12
  16. package/rust/core/audio/interpreter/driver.rs +84 -127
  17. package/rust/core/audio/interpreter/function.rs +21 -0
  18. package/rust/core/audio/interpreter/load.rs +1 -1
  19. package/rust/core/audio/interpreter/loop_.rs +24 -18
  20. package/rust/core/audio/interpreter/mod.rs +2 -1
  21. package/rust/core/audio/interpreter/sleep.rs +0 -6
  22. package/rust/core/audio/interpreter/spawn.rs +78 -60
  23. package/rust/core/audio/interpreter/trigger.rs +169 -61
  24. package/rust/core/audio/loader/trigger.rs +37 -4
  25. package/rust/core/audio/player.rs +20 -10
  26. package/rust/core/audio/renderer.rs +24 -25
  27. package/rust/core/debugger/mod.rs +2 -0
  28. package/rust/core/debugger/module.rs +47 -0
  29. package/rust/core/debugger/store.rs +25 -11
  30. package/rust/core/error/mod.rs +6 -0
  31. package/rust/core/lexer/handler/driver.rs +23 -1
  32. package/rust/core/lexer/handler/identifier.rs +1 -0
  33. package/rust/core/lexer/handler/mod.rs +1 -0
  34. package/rust/core/lexer/handler/parenthesis.rs +41 -0
  35. package/rust/core/lexer/token.rs +3 -0
  36. package/rust/core/parser/driver.rs +31 -3
  37. package/rust/core/parser/handler/dot.rs +65 -129
  38. package/rust/core/parser/handler/identifier/call.rs +69 -22
  39. package/rust/core/parser/handler/identifier/function.rs +92 -0
  40. package/rust/core/parser/handler/identifier/let_.rs +13 -19
  41. package/rust/core/parser/handler/identifier/mod.rs +1 -0
  42. package/rust/core/parser/handler/identifier/spawn.rs +74 -27
  43. package/rust/core/parser/statement.rs +16 -4
  44. package/rust/core/preprocessor/loader.rs +45 -29
  45. package/rust/core/preprocessor/module.rs +3 -1
  46. package/rust/core/preprocessor/processor.rs +26 -1
  47. package/rust/core/preprocessor/resolver/call.rs +61 -84
  48. package/rust/core/preprocessor/resolver/condition.rs +11 -6
  49. package/rust/core/preprocessor/resolver/driver.rs +52 -6
  50. package/rust/core/preprocessor/resolver/function.rs +78 -0
  51. package/rust/core/preprocessor/resolver/group.rs +43 -13
  52. package/rust/core/preprocessor/resolver/let_.rs +7 -10
  53. package/rust/core/preprocessor/resolver/mod.rs +2 -1
  54. package/rust/core/preprocessor/resolver/spawn.rs +64 -30
  55. package/rust/core/preprocessor/resolver/trigger.rs +7 -3
  56. package/rust/core/preprocessor/resolver/value.rs +10 -1
  57. package/rust/core/shared/value.rs +4 -1
  58. package/rust/core/store/function.rs +34 -0
  59. package/rust/core/store/global.rs +9 -10
  60. package/rust/core/store/mod.rs +2 -1
  61. package/rust/core/store/variable.rs +6 -0
  62. package/rust/installer/bank.rs +1 -1
  63. package/rust/installer/mod.rs +2 -1
  64. package/rust/lib.rs +10 -8
  65. package/rust/utils/mod.rs +44 -1
  66. /package/rust/{utils/installer.rs → installer/utils.rs} +0 -0
package/rust/utils/mod.rs CHANGED
@@ -4,4 +4,47 @@ pub mod spinner;
4
4
  pub mod watcher;
5
5
  pub mod file;
6
6
  pub mod logger;
7
- pub mod installer;
7
+
8
+ use crate::core::parser::statement::{Statement, StatementKind};
9
+ use crate::core::error::ErrorResult;
10
+ use crate::core::shared::value::Value;
11
+
12
+ pub fn collect_errors_recursively(statements: &[Statement]) -> Vec<ErrorResult> {
13
+ let mut errors: Vec<ErrorResult> = Vec::new();
14
+
15
+ for stmt in statements {
16
+ match &stmt.kind {
17
+ StatementKind::Unknown => {
18
+ errors.push(ErrorResult {
19
+ message: format!("Unknown statement at line {}:{}", stmt.line, stmt.column),
20
+ line: stmt.line,
21
+ column: stmt.column,
22
+ });
23
+ }
24
+ StatementKind::Error { message } => {
25
+ errors.push(ErrorResult {
26
+ message: message.clone(),
27
+ line: stmt.line,
28
+ column: stmt.column,
29
+ });
30
+ }
31
+ StatementKind::Loop => {
32
+ if let Some(body_statements) = extract_loop_body_statements(&stmt.value) {
33
+ errors.extend(collect_errors_recursively(body_statements));
34
+ }
35
+ }
36
+ _ => {}
37
+ }
38
+ }
39
+
40
+ errors
41
+ }
42
+
43
+ pub fn extract_loop_body_statements(value: &Value) -> Option<&[Statement]> {
44
+ if let Value::Map(map) = value {
45
+ if let Some(Value::Block(statements)) = map.get("body") {
46
+ return Some(statements);
47
+ }
48
+ }
49
+ None
50
+ }
File without changes