@devaloop/devalang 0.0.1-alpha.2 → 0.0.1-alpha.4

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 (107) hide show
  1. package/.devalang +1 -1
  2. package/Cargo.toml +46 -46
  3. package/README.md +48 -30
  4. package/docs/CHANGELOG.md +28 -6
  5. package/docs/COMMANDS.md +31 -0
  6. package/docs/CONFIG.md +6 -4
  7. package/docs/ROADMAP.md +5 -1
  8. package/docs/TODO.md +10 -35
  9. package/examples/exported.deva +1 -1
  10. package/examples/index.deva +8 -1
  11. package/examples/samples/hat-808.wav +0 -0
  12. package/out-tsc/bin/devalang.exe +0 -0
  13. package/package.json +41 -42
  14. package/project-version.json +5 -5
  15. package/rust/audio/engine.rs +130 -0
  16. package/rust/audio/interpreter.rs +143 -0
  17. package/rust/audio/loader.rs +46 -0
  18. package/rust/audio/mod.rs +5 -1
  19. package/rust/audio/player.rs +54 -0
  20. package/rust/audio/render.rs +57 -0
  21. package/rust/cli/build.rs +73 -45
  22. package/rust/cli/check.rs +47 -111
  23. package/rust/cli/init.rs +1 -1
  24. package/rust/cli/mod.rs +203 -2
  25. package/rust/cli/play.rs +191 -0
  26. package/rust/{utils/config.rs → config/loader.rs} +3 -2
  27. package/rust/config/mod.rs +16 -0
  28. package/rust/core/builder/mod.rs +69 -27
  29. package/rust/core/debugger/lexer.rs +27 -0
  30. package/rust/core/debugger/mod.rs +12 -49
  31. package/rust/core/debugger/preprocessor.rs +27 -0
  32. package/rust/core/error/mod.rs +60 -0
  33. package/rust/core/lexer/{at.rs → handler/at.rs} +1 -1
  34. package/rust/core/lexer/{brace.rs → handler/brace.rs} +1 -1
  35. package/rust/core/lexer/{colon.rs → handler/colon.rs} +1 -1
  36. package/rust/core/lexer/{comment.rs → handler/comment.rs} +3 -3
  37. package/rust/core/lexer/{dot.rs → handler/dot.rs} +1 -1
  38. package/rust/core/lexer/{equal.rs → handler/equal.rs} +1 -1
  39. package/rust/core/lexer/{identifier.rs → handler/identifier.rs} +1 -1
  40. package/rust/core/lexer/{indent.rs → handler/indent.rs} +10 -5
  41. package/rust/core/lexer/handler/mod.rs +238 -0
  42. package/rust/core/lexer/{newline.rs → handler/newline.rs} +6 -10
  43. package/rust/core/lexer/{number.rs → handler/number.rs} +1 -1
  44. package/rust/core/lexer/handler/string.rs +66 -0
  45. package/rust/core/lexer/mod.rs +25 -14
  46. package/rust/core/lexer/token.rs +55 -0
  47. package/rust/core/mod.rs +5 -2
  48. package/rust/core/parser/handler/at.rs +166 -0
  49. package/rust/core/parser/handler/bank.rs +38 -0
  50. package/rust/core/parser/handler/dot.rs +112 -0
  51. package/rust/core/parser/handler/identifier.rs +134 -0
  52. package/rust/core/parser/handler/loop_.rs +55 -0
  53. package/rust/core/parser/handler/mod.rs +6 -0
  54. package/rust/core/parser/handler/tempo.rs +47 -0
  55. package/rust/core/parser/mod.rs +204 -166
  56. package/rust/core/parser/statement.rs +91 -0
  57. package/rust/core/preprocessor/loader.rs +116 -0
  58. package/rust/core/preprocessor/mod.rs +2 -24
  59. package/rust/core/preprocessor/module.rs +37 -56
  60. package/rust/core/preprocessor/processor.rs +41 -0
  61. package/rust/core/preprocessor/resolver/bank.rs +38 -51
  62. package/rust/core/preprocessor/resolver/loop_.rs +126 -65
  63. package/rust/core/preprocessor/resolver/mod.rs +119 -80
  64. package/rust/core/preprocessor/resolver/tempo.rs +40 -61
  65. package/rust/core/preprocessor/resolver/trigger.rs +93 -155
  66. package/rust/core/shared/duration.rs +8 -0
  67. package/rust/core/shared/mod.rs +2 -0
  68. package/rust/core/shared/value.rs +18 -0
  69. package/rust/core/store/export.rs +28 -0
  70. package/rust/core/store/global.rs +39 -0
  71. package/rust/core/store/import.rs +28 -0
  72. package/rust/core/store/mod.rs +4 -0
  73. package/rust/core/store/variable.rs +28 -0
  74. package/rust/core/utils/mod.rs +2 -0
  75. package/rust/core/utils/validation.rs +35 -0
  76. package/rust/lib.rs +0 -1
  77. package/rust/main.rs +22 -18
  78. package/rust/utils/logger.rs +69 -34
  79. package/rust/utils/mod.rs +3 -5
  80. package/rust/utils/watcher.rs +10 -2
  81. package/templates/minimal/.devalang +1 -1
  82. package/templates/welcome/.devalang +1 -1
  83. package/rust/core/lexer/bracket.rs +0 -41
  84. package/rust/core/lexer/driver.rs +0 -286
  85. package/rust/core/lexer/quote.rs +0 -61
  86. package/rust/core/parser/at.rs +0 -142
  87. package/rust/core/parser/bank.rs +0 -42
  88. package/rust/core/parser/dot.rs +0 -137
  89. package/rust/core/parser/identifer.rs +0 -91
  90. package/rust/core/parser/loop_.rs +0 -62
  91. package/rust/core/parser/tempo.rs +0 -42
  92. package/rust/core/parser/variable.rs +0 -129
  93. package/rust/core/preprocessor/dependencies.rs +0 -54
  94. package/rust/core/preprocessor/resolver/at.rs +0 -24
  95. package/rust/core/types/cli.rs +0 -182
  96. package/rust/core/types/config.rs +0 -15
  97. package/rust/core/types/mod.rs +0 -8
  98. package/rust/core/types/module.rs +0 -41
  99. package/rust/core/types/parser.rs +0 -73
  100. package/rust/core/types/statement.rs +0 -105
  101. package/rust/core/types/store.rs +0 -116
  102. package/rust/core/types/token.rs +0 -83
  103. package/rust/core/types/variable.rs +0 -32
  104. package/rust/runner/executer.rs +0 -44
  105. package/rust/runner/mod.rs +0 -1
  106. /package/rust/{utils → core/utils}/path.rs +0 -0
  107. /package/rust/utils/{loader.rs → spinner.rs} +0 -0
@@ -1,73 +0,0 @@
1
- use crate::core::types::{
2
- store::{ ExportTable, ImportTable, VariableTable },
3
- token::{ Token, TokenKind },
4
- };
5
-
6
- #[derive(Debug, Clone)]
7
- pub struct Parser {
8
- pub tokens: Vec<Token>,
9
- pub token_index: usize,
10
- pub variable_table: VariableTable,
11
- pub export_table: ExportTable,
12
- pub import_table: ImportTable,
13
- pub current_module: String,
14
- }
15
-
16
- impl Parser {
17
- pub fn new(tokens: Vec<Token>) -> Self {
18
- Self {
19
- tokens,
20
- token_index: 0,
21
- variable_table: VariableTable::new(),
22
- export_table: ExportTable::new(),
23
- import_table: ImportTable::new(),
24
- current_module: String::new(),
25
- }
26
- }
27
-
28
- pub fn set_tokens(&mut self, tokens: Vec<Token>) {
29
- self.tokens = tokens;
30
- self.token_index = 0;
31
- }
32
-
33
- pub fn peek(&self) -> Option<&Token> {
34
- self.tokens.get(self.token_index)
35
- }
36
-
37
- pub fn next(&mut self) -> Option<&Token> {
38
- let tok = self.tokens.get(self.token_index);
39
- self.token_index += 1;
40
- tok
41
- }
42
-
43
- pub fn expect(&mut self, kind: TokenKind) -> Result<&Token, String> {
44
- let tok = self.next().ok_or("Unexpected end of input")?;
45
- if tok.kind == kind {
46
- Ok(tok)
47
- } else {
48
- Err(format!("Expected {:?}, got {:?}", kind, tok.kind))
49
- }
50
- }
51
-
52
- pub fn collect_until<F>(&mut self, condition: F) -> Vec<Token> where F: Fn(&Token) -> bool {
53
- let mut collected = Vec::new();
54
- while let Some(token) = self.peek() {
55
- if token.kind == TokenKind::Newline || token.kind == TokenKind::Indent {
56
- self.next(); // Skip newlines and indents
57
- continue;
58
- }
59
- if token.kind == TokenKind::EOF {
60
- break;
61
- }
62
- if condition(token) {
63
- break;
64
- }
65
- collected.push(self.next().unwrap().clone());
66
- }
67
- collected
68
- }
69
-
70
- pub fn is_eof(&self) -> bool {
71
- self.token_index >= self.tokens.len()
72
- }
73
- }
@@ -1,105 +0,0 @@
1
- use std::collections::HashMap;
2
- use serde::Serialize;
3
- use crate::core::types::{ token::{ Token, TokenDuration, TokenParam }, variable::VariableValue };
4
-
5
- #[derive(Debug, Clone, Serialize)]
6
- pub struct Statement {
7
- pub kind: StatementKind,
8
- pub value: VariableValue,
9
- pub indent: usize,
10
- pub line: usize,
11
- pub column: usize,
12
- }
13
-
14
- #[derive(Debug, Clone, Serialize)]
15
- pub struct StatementResolved {
16
- pub kind: StatementKind,
17
- pub value: StatementResolvedValue,
18
- pub indent: usize,
19
- pub line: usize,
20
- pub column: usize,
21
- }
22
-
23
- #[derive(Debug, Clone, Serialize)]
24
- pub enum StatementValue {
25
- Boolean(bool),
26
- Number(f32),
27
- String(String),
28
- Array(Vec<Statement>),
29
- Map(HashMap<String, VariableValue>),
30
- Unknown,
31
- }
32
-
33
- #[derive(Debug, Clone, Serialize)]
34
- pub enum StatementResolvedValue {
35
- Boolean(bool),
36
- Number(f32),
37
- String(String),
38
- Array(Vec<StatementResolved>),
39
- Map(HashMap<String, StatementResolvedValue>),
40
- Unknown,
41
- Null,
42
- }
43
-
44
- #[derive(Debug, Clone, Serialize)]
45
- pub enum StatementIterator {
46
- Identifier(String),
47
- Number(f32),
48
- Array(Vec<Statement>),
49
- Map(HashMap<String, VariableValue>),
50
- Unknown,
51
- }
52
-
53
- #[derive(Debug, Serialize, Clone)]
54
- /// Represents the kind of a statement
55
- pub enum StatementKind {
56
- // Trigger statements
57
- Trigger {
58
- entity: String,
59
- duration: TokenDuration,
60
- // params: Vec<TokenParam>,
61
- },
62
-
63
- // Variable statements
64
- Let {
65
- name: String,
66
- },
67
-
68
- // Loop statements
69
- Loop {
70
- iterator: StatementIterator,
71
- },
72
-
73
- // Conditional statements
74
- // If {
75
- // // condition: ConditionParts,
76
- // condition_state: bool,
77
- // body: Vec<Statement>,
78
- // },
79
-
80
- // Keyword statements
81
- Tempo,
82
- Bank,
83
-
84
- // At (@) statements
85
- Include(String),
86
- Export,
87
- Import {
88
- names: Vec<String>,
89
- source: String,
90
- },
91
- Load {
92
- source: String,
93
- alias: String,
94
- },
95
-
96
- // Error & Unknown statements
97
- Unknown,
98
- Error,
99
-
100
- // Empty or ignored statements
101
- Comment(String),
102
- Indent,
103
- Dedent,
104
- NewLine,
105
- }
@@ -1,116 +0,0 @@
1
- use std::collections::HashMap;
2
-
3
- use crate::core::types::{ module::Module, variable::VariableValue };
4
-
5
- #[derive(Debug, Default)]
6
- pub struct GlobalStore {
7
- pub modules: HashMap<String, Module>,
8
- }
9
-
10
- impl GlobalStore {
11
- pub fn new() -> Self {
12
- GlobalStore {
13
- modules: HashMap::new(),
14
- }
15
- }
16
-
17
- pub fn insert_module(&mut self, path: String, module: Module) {
18
- self.modules.insert(path, module);
19
- }
20
-
21
- pub fn update_module(&mut self, path: String, module: Module) {
22
- if !self.modules.contains_key(&path) {
23
- eprintln!("❌ Module {} not found in global store for update", path);
24
- return;
25
- }
26
-
27
- // Remove the existing module if it exists
28
- self.modules.remove(&path);
29
-
30
- // Insert the updated module
31
- self.modules.insert(path, module);
32
- }
33
-
34
- pub fn get_module(&self, path: &str) -> Option<&Module> {
35
- self.modules.get(path)
36
- }
37
-
38
- pub fn remove_module(&mut self, path: &str) -> Option<Module> {
39
- self.modules.remove(path)
40
- }
41
- }
42
-
43
- #[derive(Debug, Default, Clone)]
44
- pub struct VariableTable {
45
- pub variables: HashMap<String, VariableValue>,
46
- }
47
-
48
- impl VariableTable {
49
- pub fn new() -> Self {
50
- VariableTable {
51
- variables: HashMap::new(),
52
- }
53
- }
54
-
55
- pub fn set(&mut self, name: String, value: VariableValue) {
56
- self.variables.insert(name, value);
57
- }
58
-
59
- pub fn get(&self, name: &str) -> Option<&VariableValue> {
60
- self.variables.get(name)
61
- }
62
-
63
- pub fn remove(&mut self, name: &str) -> Option<VariableValue> {
64
- self.variables.remove(name)
65
- }
66
- }
67
-
68
- #[derive(Debug, Default, Clone)]
69
- pub struct ExportTable {
70
- pub exports: HashMap<String, VariableValue>,
71
- }
72
-
73
- impl ExportTable {
74
- pub fn new() -> Self {
75
- ExportTable {
76
- exports: HashMap::new(),
77
- }
78
- }
79
-
80
- pub fn add_export(&mut self, name: String, value: VariableValue) {
81
- self.exports.insert(name, value);
82
- }
83
-
84
- pub fn get_export(&self, name: &str) -> Option<&VariableValue> {
85
- self.exports.get(name)
86
- }
87
-
88
- pub fn remove_export(&mut self, name: &str) -> Option<VariableValue> {
89
- self.exports.remove(name)
90
- }
91
- }
92
-
93
- #[derive(Debug, Default, Clone)]
94
- pub struct ImportTable {
95
- pub imports: HashMap<String, VariableValue>,
96
- }
97
-
98
- impl ImportTable {
99
- pub fn new() -> Self {
100
- ImportTable {
101
- imports: HashMap::new(),
102
- }
103
- }
104
-
105
- pub fn add_import(&mut self, name: String, value: VariableValue) {
106
- self.imports.insert(name, value);
107
- }
108
-
109
- pub fn get_import(&self, name: &str) -> Option<&VariableValue> {
110
- self.imports.get(name)
111
- }
112
-
113
- pub fn remove_import(&mut self, name: &str) -> Option<VariableValue> {
114
- self.imports.remove(name)
115
- }
116
- }
@@ -1,83 +0,0 @@
1
- use std::collections::HashMap;
2
-
3
- use serde::Serialize;
4
-
5
- #[derive(Debug, Clone, PartialEq, Serialize)]
6
- pub struct Token {
7
- pub kind: TokenKind,
8
- pub lexeme: String,
9
- pub indent: usize,
10
- pub line: usize,
11
- pub column: usize,
12
- }
13
-
14
- impl Token {
15
- pub fn is_error(&self) -> bool {
16
- match &self.kind {
17
- TokenKind::Error(_) => {
18
- return true;
19
- },
20
- _ => {
21
- return false;
22
- },
23
- };
24
- }
25
- }
26
-
27
- #[derive(Debug, Clone, PartialEq, Serialize)]
28
- pub enum TokenKind {
29
- At,
30
- Tempo,
31
- Bank,
32
- Loop,
33
- Identifier,
34
- Map,
35
- Array,
36
- Number,
37
- String,
38
- Boolean,
39
- Colon,
40
- Comma,
41
- Equals,
42
- DoubleEquals,
43
- Dot,
44
- LBrace,
45
- RBrace,
46
- DbQuote,
47
- Quote,
48
- LBracket,
49
- RBracket,
50
- Newline,
51
- Indent,
52
- Dedent,
53
- Comment(String),
54
- Unknown,
55
- Error(String),
56
- EOF,
57
- }
58
-
59
- #[derive(Debug, Clone, PartialEq, Serialize)]
60
- pub enum TokenDuration {
61
- Number(f32),
62
- Identifier(String),
63
- Infinite,
64
- Auto,
65
- Unknown,
66
- }
67
-
68
- #[derive(Debug, Clone, PartialEq, Serialize)]
69
- pub struct TokenParam {
70
- pub name: String,
71
- pub value: TokenParamValue,
72
- }
73
-
74
- #[derive(Debug, Clone, PartialEq, Serialize)]
75
- pub enum TokenParamValue {
76
- Number(f32),
77
- String(String),
78
- Boolean(bool),
79
- Identifier(String),
80
- Map(HashMap<String, TokenParamValue>),
81
- Array(Vec<TokenParamValue>),
82
- Unknown,
83
- }
@@ -1,32 +0,0 @@
1
- use std::collections::HashMap;
2
- use serde::Serialize;
3
- use crate::core::types::token::{Token, TokenParamValue};
4
-
5
- #[derive(Debug, Clone, Serialize)]
6
- pub enum VariableValue {
7
- Number(f32),
8
- Array(Vec<Token>),
9
- Map(HashMap<String, TokenParamValue>),
10
- Text(String),
11
- Boolean(bool),
12
- Sample(String),
13
- Unknown,
14
- Null,
15
- }
16
- pub struct Variable {
17
- pub value: VariableValue,
18
- }
19
-
20
- impl Variable {
21
- pub fn from_number(value: f32) -> Self {
22
- Variable {
23
- value: VariableValue::Number(value),
24
- }
25
- }
26
-
27
- pub fn from_token(value: Token) -> Self {
28
- Variable {
29
- value: VariableValue::Text(value.lexeme),
30
- }
31
- }
32
- }
@@ -1,44 +0,0 @@
1
- use crate::core::{
2
- preprocessor::resolver::resolve_statement,
3
- types::{
4
- module::Module,
5
- statement::{ StatementKind, StatementResolved, StatementResolvedValue },
6
- },
7
- };
8
-
9
- /// Exécute tous les statements d'un module avec résolution des variables
10
- pub fn execute_statements(module: &mut Module) -> Vec<StatementResolved> {
11
- let mut resolved_statements: Vec<StatementResolved> = Vec::new();
12
-
13
- if module.clone().statements.is_empty() {
14
- return resolved_statements;
15
- }
16
-
17
- for stmt in module.clone().statements {
18
- match &stmt.kind {
19
- StatementKind::Tempo { .. } => {
20
- let resolved = resolve_statement(&stmt, module);
21
- resolved_statements.push(resolved);
22
- }
23
- StatementKind::Trigger { .. } => {
24
- let resolved = resolve_statement(&stmt, module);
25
- resolved_statements.push(resolved);
26
- }
27
- StatementKind::Bank { .. } => {
28
- let resolved = resolve_statement(&stmt, module);
29
- resolved_statements.push(resolved);
30
- }
31
- StatementKind::Loop { .. } => {
32
- let resolved = resolve_statement(&stmt, module);
33
- resolved_statements.push(resolved);
34
- }
35
- StatementKind::Load { .. } => {
36
- let resolved = resolve_statement(&stmt, module);
37
- resolved_statements.push(resolved);
38
- }
39
- _ => {}
40
- }
41
- }
42
-
43
- resolved_statements
44
- }
@@ -1 +0,0 @@
1
- pub mod executer;
File without changes
File without changes