@devaloop/devalang 0.0.1-alpha.5 → 0.0.1-alpha.8
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.
- package/Cargo.toml +1 -1
- package/README.md +45 -14
- package/docs/CHANGELOG.md +39 -0
- package/docs/ROADMAP.md +2 -2
- package/docs/SYNTAX.md +80 -18
- package/docs/TODO.md +12 -11
- package/examples/condition.deva +24 -0
- package/examples/group.deva +12 -0
- package/examples/index.deva +8 -9
- package/examples/loop.deva +15 -0
- package/examples/variables.deva +9 -0
- package/out-tsc/bin/devalang.exe +0 -0
- package/package.json +44 -44
- package/project-version.json +5 -5
- package/rust/cli/build.rs +6 -2
- package/rust/cli/play.rs +2 -1
- package/rust/core/audio/evaluator.rs +31 -0
- package/rust/core/audio/interpreter/call.rs +42 -0
- package/rust/core/audio/interpreter/condition.rs +65 -0
- package/rust/core/audio/interpreter/driver.rs +204 -0
- package/rust/core/audio/interpreter/let_.rs +19 -0
- package/rust/core/audio/interpreter/load.rs +18 -0
- package/rust/core/audio/interpreter/loop_.rs +59 -0
- package/rust/core/audio/interpreter/mod.rs +11 -0
- package/rust/core/audio/interpreter/sleep.rs +36 -0
- package/rust/core/audio/interpreter/spawn.rs +65 -0
- package/rust/core/audio/interpreter/tempo.rs +16 -0
- package/rust/core/audio/interpreter/trigger.rs +69 -0
- package/rust/core/audio/loader/mod.rs +1 -0
- package/rust/{audio/loader.rs → core/audio/loader/trigger.rs} +6 -0
- package/rust/{audio → core/audio}/mod.rs +2 -1
- package/rust/{audio/render.rs → core/audio/renderer.rs} +2 -2
- package/rust/core/builder/mod.rs +2 -1
- package/rust/core/debugger/lexer.rs +1 -1
- package/rust/core/debugger/mod.rs +1 -0
- package/rust/core/debugger/store.rs +25 -0
- package/rust/core/error/mod.rs +1 -1
- package/rust/core/lexer/handler/driver.rs +215 -0
- package/rust/core/lexer/handler/identifier.rs +2 -0
- package/rust/core/lexer/handler/indent.rs +1 -1
- package/rust/core/lexer/handler/mod.rs +3 -228
- package/rust/core/lexer/handler/operator.rs +44 -0
- package/rust/core/lexer/handler/string.rs +3 -6
- package/rust/core/lexer/mod.rs +1 -1
- package/rust/core/lexer/token.rs +36 -9
- package/rust/core/mod.rs +2 -1
- package/rust/core/parser/driver.rs +312 -0
- package/rust/core/parser/handler/at.rs +3 -7
- package/rust/core/parser/handler/bank.rs +5 -2
- package/rust/core/parser/handler/condition.rs +74 -0
- package/rust/core/parser/handler/dot.rs +1 -1
- package/rust/core/parser/handler/identifier.rs +130 -2
- package/rust/core/parser/handler/loop_.rs +1 -1
- package/rust/core/parser/handler/mod.rs +2 -1
- package/rust/core/parser/handler/tempo.rs +1 -1
- package/rust/core/parser/mod.rs +3 -237
- package/rust/core/parser/statement.rs +30 -33
- package/rust/core/preprocessor/loader.rs +7 -6
- package/rust/core/preprocessor/processor.rs +29 -3
- package/rust/core/preprocessor/resolver/bank.rs +10 -9
- package/rust/core/preprocessor/resolver/call.rs +53 -0
- package/rust/core/preprocessor/resolver/condition.rs +66 -0
- package/rust/core/preprocessor/resolver/driver.rs +182 -0
- package/rust/core/preprocessor/resolver/group.rs +118 -0
- package/rust/core/preprocessor/resolver/loop_.rs +3 -6
- package/rust/core/preprocessor/resolver/mod.rs +6 -147
- package/rust/core/preprocessor/resolver/spawn.rs +53 -0
- package/rust/core/preprocessor/resolver/trigger.rs +0 -3
- package/rust/lib.rs +0 -1
- package/rust/main.rs +0 -1
- package/examples/exported.deva +0 -7
- package/rust/audio/interpreter.rs +0 -143
- package/rust/core/lexer/handler/equal.rs +0 -32
- /package/rust/{audio → core/audio}/engine.rs +0 -0
- /package/rust/{audio → core/audio}/player.rs +0 -0
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
audio::{ engine::AudioEngine, loader::load_trigger },
|
|
3
|
-
core::{
|
|
4
|
-
parser::statement::{ Statement, StatementKind },
|
|
5
|
-
shared::value::Value,
|
|
6
|
-
store::variable::VariableTable,
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
pub fn interprete_statements(
|
|
11
|
-
statements: &Vec<Statement>,
|
|
12
|
-
audio_engine: AudioEngine,
|
|
13
|
-
entry: String,
|
|
14
|
-
output: String
|
|
15
|
-
) -> (AudioEngine, f32, f32) {
|
|
16
|
-
let mut base_bpm = 120.0;
|
|
17
|
-
let mut base_duration = 60.0 / base_bpm;
|
|
18
|
-
|
|
19
|
-
let variable_table = audio_engine.variables.clone();
|
|
20
|
-
|
|
21
|
-
let (updated_audio_engine, base_bpm, max_end_time) = execute_audio_statements(
|
|
22
|
-
audio_engine.clone(),
|
|
23
|
-
variable_table.clone(),
|
|
24
|
-
statements.clone(),
|
|
25
|
-
base_bpm.clone(),
|
|
26
|
-
base_duration.clone(),
|
|
27
|
-
0.0,
|
|
28
|
-
0.0
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
(updated_audio_engine, base_bpm, max_end_time)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
pub fn execute_audio_statements(
|
|
35
|
-
mut audio_engine: AudioEngine,
|
|
36
|
-
mut variable_table: VariableTable,
|
|
37
|
-
mut statements: Vec<Statement>,
|
|
38
|
-
mut base_bpm: f32,
|
|
39
|
-
mut base_duration: f32,
|
|
40
|
-
mut max_end_time: f32,
|
|
41
|
-
mut cursor_time: f32
|
|
42
|
-
) -> (AudioEngine, f32, f32) {
|
|
43
|
-
for stmt in statements {
|
|
44
|
-
match &stmt.kind {
|
|
45
|
-
StatementKind::Load { source, alias } => {
|
|
46
|
-
variable_table.set(alias.to_string(), Value::String(source.clone()));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
StatementKind::Let { name } => {
|
|
50
|
-
variable_table.set(name.to_string(), stmt.value.clone());
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
StatementKind::Tempo => {
|
|
54
|
-
if let Value::Number(bpm_) = &stmt.value {
|
|
55
|
-
base_bpm = *bpm_ as f32;
|
|
56
|
-
base_duration = 60.0 / base_bpm;
|
|
57
|
-
} else {
|
|
58
|
-
eprintln!("❌ Invalid tempo value: {:?}", stmt.value);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
StatementKind::Trigger { entity, duration } => {
|
|
63
|
-
if let Some(trigger_val) = variable_table.get(entity) {
|
|
64
|
-
let (src, duration_secs) = load_trigger(
|
|
65
|
-
trigger_val,
|
|
66
|
-
duration,
|
|
67
|
-
base_duration,
|
|
68
|
-
variable_table.clone()
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
audio_engine.insert(&src, cursor_time, duration_secs, None);
|
|
72
|
-
|
|
73
|
-
cursor_time += duration_secs;
|
|
74
|
-
|
|
75
|
-
if cursor_time > max_end_time {
|
|
76
|
-
max_end_time = cursor_time;
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
eprintln!("❌ Unknown trigger entity: {}", entity);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
StatementKind::Loop => {
|
|
84
|
-
if let Value::Map(loop_value) = &stmt.value {
|
|
85
|
-
let iterator = loop_value.get("iterator");
|
|
86
|
-
let body = loop_value.get("body");
|
|
87
|
-
|
|
88
|
-
let loop_count = if let Some(Value::Number(n)) = iterator {
|
|
89
|
-
*n as usize
|
|
90
|
-
} else {
|
|
91
|
-
eprintln!("❌ Loop iterator must be a number: {:?}", iterator);
|
|
92
|
-
continue;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
let loop_body = if let Some(Value::Block(body)) = body {
|
|
96
|
-
body.clone()
|
|
97
|
-
} else {
|
|
98
|
-
eprintln!("❌ Loop body must be a block: {:?}", body);
|
|
99
|
-
continue;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
for _ in 0..loop_count {
|
|
103
|
-
let (loop_engine, _, loop_end_time) = execute_audio_statements(
|
|
104
|
-
audio_engine.clone(),
|
|
105
|
-
variable_table.clone(),
|
|
106
|
-
loop_body.clone(),
|
|
107
|
-
base_bpm,
|
|
108
|
-
base_duration,
|
|
109
|
-
max_end_time,
|
|
110
|
-
cursor_time
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
audio_engine = loop_engine;
|
|
114
|
-
|
|
115
|
-
// Update time and max_end_time after each loop iteration
|
|
116
|
-
cursor_time = loop_end_time;
|
|
117
|
-
if loop_end_time > max_end_time {
|
|
118
|
-
max_end_time = loop_end_time;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
StatementKind::Bank => {}
|
|
125
|
-
|
|
126
|
-
StatementKind::Import { names, source } => {}
|
|
127
|
-
|
|
128
|
-
StatementKind::Export { names, source } => {}
|
|
129
|
-
|
|
130
|
-
StatementKind::Unknown => {
|
|
131
|
-
// Ignore unknown statements
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
_ => {
|
|
135
|
-
eprintln!("Unsupported statement kind: {:?}", stmt);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
audio_engine.set_variables(variable_table);
|
|
141
|
-
|
|
142
|
-
(audio_engine, base_bpm, max_end_time)
|
|
143
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn handle_equal_lexer(
|
|
4
|
-
char: char,
|
|
5
|
-
chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
6
|
-
current_indent: &mut usize,
|
|
7
|
-
indent_stack: &mut Vec<usize>,
|
|
8
|
-
tokens: &mut Vec<Token>,
|
|
9
|
-
line: &mut usize,
|
|
10
|
-
column: &mut usize
|
|
11
|
-
) {
|
|
12
|
-
if let Some('=') = chars.peek() {
|
|
13
|
-
chars.next();
|
|
14
|
-
tokens.push(Token {
|
|
15
|
-
kind: TokenKind::DoubleEquals,
|
|
16
|
-
lexeme: char.to_string(),
|
|
17
|
-
line: *line,
|
|
18
|
-
column: *column,
|
|
19
|
-
indent: *current_indent,
|
|
20
|
-
});
|
|
21
|
-
*column += 2;
|
|
22
|
-
} else {
|
|
23
|
-
tokens.push(Token {
|
|
24
|
-
kind: TokenKind::Equals,
|
|
25
|
-
lexeme: char.to_string(),
|
|
26
|
-
line: *line,
|
|
27
|
-
column: *column,
|
|
28
|
-
indent: *current_indent,
|
|
29
|
-
});
|
|
30
|
-
*column += 1;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
File without changes
|
|
File without changes
|