@devaloop/devalang 0.0.1-alpha.1 → 0.0.1-alpha.3
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/.devalang +4 -0
- package/Cargo.toml +46 -45
- package/README.md +35 -10
- package/docs/CHANGELOG.md +58 -0
- package/docs/COMMANDS.md +29 -6
- package/docs/CONFIG.md +28 -0
- package/docs/ROADMAP.md +6 -2
- package/docs/TODO.md +21 -18
- package/examples/exported.deva +1 -1
- package/examples/index.deva +2 -1
- package/out-tsc/bin/devalang.exe +0 -0
- package/package.json +2 -3
- package/project-version.json +4 -4
- package/rust/cli/build.rs +99 -29
- package/rust/cli/check.rs +95 -103
- package/rust/cli/init.rs +77 -0
- package/rust/cli/mod.rs +174 -1
- package/rust/cli/template.rs +56 -0
- package/rust/config/loader.rs +14 -0
- package/rust/config/mod.rs +15 -0
- package/rust/core/builder/mod.rs +21 -27
- package/rust/core/debugger/lexer.rs +12 -0
- package/rust/core/debugger/mod.rs +12 -49
- package/rust/core/debugger/preprocessor.rs +23 -0
- package/rust/core/error/mod.rs +60 -0
- package/rust/core/lexer/handler/at.rs +21 -0
- package/rust/core/lexer/handler/brace.rs +41 -0
- package/rust/core/lexer/handler/colon.rs +21 -0
- package/rust/core/lexer/handler/comment.rs +30 -0
- package/rust/core/lexer/handler/dot.rs +21 -0
- package/rust/core/lexer/handler/equal.rs +32 -0
- package/rust/core/lexer/handler/identifier.rs +38 -0
- package/rust/core/lexer/handler/indent.rs +52 -0
- package/rust/core/lexer/handler/mod.rs +238 -0
- package/rust/core/lexer/handler/newline.rs +19 -0
- package/rust/core/lexer/handler/number.rs +31 -0
- package/rust/core/lexer/handler/string.rs +66 -0
- package/rust/core/lexer/mod.rs +16 -324
- package/rust/core/lexer/token.rs +55 -0
- package/rust/core/mod.rs +5 -2
- package/rust/core/parser/handler/at.rs +166 -0
- package/rust/core/parser/handler/bank.rs +38 -0
- package/rust/core/parser/handler/dot.rs +112 -0
- package/rust/core/parser/handler/identifier.rs +134 -0
- package/rust/core/parser/handler/loop_.rs +55 -0
- package/rust/core/parser/handler/mod.rs +6 -0
- package/rust/core/parser/handler/tempo.rs +47 -0
- package/rust/core/parser/mod.rs +204 -166
- package/rust/core/parser/statement.rs +91 -0
- package/rust/core/preprocessor/loader.rs +105 -0
- package/rust/core/preprocessor/mod.rs +2 -24
- package/rust/core/preprocessor/module.rs +37 -56
- package/rust/core/preprocessor/processor.rs +41 -0
- package/rust/core/preprocessor/resolver.rs +372 -0
- package/rust/core/shared/duration.rs +8 -0
- package/rust/core/shared/mod.rs +2 -0
- package/rust/core/shared/value.rs +18 -0
- package/rust/core/store/export.rs +28 -0
- package/rust/core/store/global.rs +39 -0
- package/rust/core/store/import.rs +28 -0
- package/rust/core/store/mod.rs +4 -0
- package/rust/core/store/variable.rs +28 -0
- package/rust/core/utils/mod.rs +2 -0
- package/rust/core/utils/validation.rs +35 -0
- package/rust/lib.rs +0 -1
- package/rust/main.rs +39 -30
- package/rust/utils/file.rs +35 -0
- package/rust/utils/logger.rs +69 -34
- package/rust/utils/mod.rs +3 -2
- package/rust/utils/watcher.rs +25 -0
- package/templates/minimal/.devalang +4 -0
- package/templates/minimal/src/index.deva +2 -0
- package/templates/welcome/.devalang +4 -0
- package/templates/welcome/README.md +185 -0
- package/templates/welcome/samples/kick-808.wav +0 -0
- package/templates/welcome/src/index.deva +13 -0
- package/templates/welcome/src/variables.deva +5 -0
- package/rust/audio/mod.rs +0 -1
- package/rust/cli/new.rs +0 -1
- package/rust/core/parser/at.rs +0 -142
- package/rust/core/parser/bank.rs +0 -42
- package/rust/core/parser/dot.rs +0 -107
- package/rust/core/parser/identifer.rs +0 -91
- package/rust/core/parser/loop_.rs +0 -62
- package/rust/core/parser/tempo.rs +0 -42
- package/rust/core/parser/variable.rs +0 -129
- package/rust/core/preprocessor/dependencies.rs +0 -54
- package/rust/core/preprocessor/resolver/at.rs +0 -24
- package/rust/core/preprocessor/resolver/bank.rs +0 -59
- package/rust/core/preprocessor/resolver/loop_.rs +0 -82
- package/rust/core/preprocessor/resolver/mod.rs +0 -113
- package/rust/core/preprocessor/resolver/tempo.rs +0 -70
- package/rust/core/preprocessor/resolver/trigger.rs +0 -176
- package/rust/core/types/cli.rs +0 -160
- package/rust/core/types/mod.rs +0 -7
- package/rust/core/types/module.rs +0 -41
- package/rust/core/types/parser.rs +0 -73
- package/rust/core/types/statement.rs +0 -105
- package/rust/core/types/store.rs +0 -116
- package/rust/core/types/token.rs +0 -83
- package/rust/core/types/variable.rs +0 -32
- package/rust/runner/executer.rs +0 -44
- package/rust/runner/mod.rs +0 -1
- /package/rust/{utils → core/utils}/path.rs +0 -0
- /package/rust/utils/{loader.rs → spinner.rs} +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
use crate::core::types::{
|
|
2
|
-
statement::Statement,
|
|
3
|
-
store::{ ExportTable, ImportTable, VariableTable },
|
|
4
|
-
token::Token,
|
|
5
|
-
variable::VariableValue,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
#[derive(Debug, Clone)]
|
|
9
|
-
pub struct Module {
|
|
10
|
-
pub path: String,
|
|
11
|
-
pub tokens: Vec<Token>,
|
|
12
|
-
pub statements: Vec<Statement>,
|
|
13
|
-
pub variable_table: VariableTable,
|
|
14
|
-
pub export_table: ExportTable,
|
|
15
|
-
pub import_table: ImportTable,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
impl Module {
|
|
19
|
-
pub fn new(path: String) -> Self {
|
|
20
|
-
Module {
|
|
21
|
-
path,
|
|
22
|
-
tokens: Vec::new(),
|
|
23
|
-
statements: Vec::new(),
|
|
24
|
-
variable_table: VariableTable::new(),
|
|
25
|
-
export_table: ExportTable::new(),
|
|
26
|
-
import_table: ImportTable::new(),
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
pub fn add_statement(&mut self, statement: Statement) {
|
|
31
|
-
self.statements.push(statement);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
pub fn set_variable(&mut self, name: String, value: VariableValue) {
|
|
35
|
-
self.variable_table.set(name, value);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
pub fn get_variable(&self, name: &str) -> Option<&VariableValue> {
|
|
39
|
-
self.variable_table.get(name)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -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
|
-
}
|
package/rust/core/types/store.rs
DELETED
|
@@ -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
|
-
}
|
package/rust/core/types/token.rs
DELETED
|
@@ -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
|
-
}
|
package/rust/runner/executer.rs
DELETED
|
@@ -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
|
-
}
|
package/rust/runner/mod.rs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pub mod executer;
|
|
File without changes
|
|
File without changes
|