@devaloop/devalang 0.0.1-alpha.2 → 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.
Files changed (96) hide show
  1. package/Cargo.toml +46 -46
  2. package/README.md +7 -6
  3. package/docs/CHANGELOG.md +11 -6
  4. package/docs/ROADMAP.md +5 -1
  5. package/docs/TODO.md +6 -31
  6. package/examples/exported.deva +1 -1
  7. package/examples/index.deva +1 -0
  8. package/out-tsc/bin/devalang.exe +0 -0
  9. package/package.json +1 -2
  10. package/project-version.json +3 -3
  11. package/rust/cli/build.rs +57 -40
  12. package/rust/cli/check.rs +47 -111
  13. package/rust/cli/init.rs +1 -1
  14. package/rust/cli/mod.rs +174 -2
  15. package/rust/{utils/config.rs → config/loader.rs} +3 -2
  16. package/rust/{core/types/config.rs → config/mod.rs} +5 -5
  17. package/rust/core/builder/mod.rs +21 -27
  18. package/rust/core/debugger/lexer.rs +12 -0
  19. package/rust/core/debugger/mod.rs +12 -49
  20. package/rust/core/debugger/preprocessor.rs +23 -0
  21. package/rust/core/error/mod.rs +60 -0
  22. package/rust/core/lexer/{at.rs → handler/at.rs} +1 -1
  23. package/rust/core/lexer/{brace.rs → handler/brace.rs} +1 -1
  24. package/rust/core/lexer/{colon.rs → handler/colon.rs} +1 -1
  25. package/rust/core/lexer/{comment.rs → handler/comment.rs} +3 -3
  26. package/rust/core/lexer/{dot.rs → handler/dot.rs} +1 -1
  27. package/rust/core/lexer/{equal.rs → handler/equal.rs} +1 -1
  28. package/rust/core/lexer/{identifier.rs → handler/identifier.rs} +1 -1
  29. package/rust/core/lexer/{indent.rs → handler/indent.rs} +10 -5
  30. package/rust/core/lexer/handler/mod.rs +238 -0
  31. package/rust/core/lexer/{newline.rs → handler/newline.rs} +6 -10
  32. package/rust/core/lexer/{number.rs → handler/number.rs} +1 -1
  33. package/rust/core/lexer/handler/string.rs +66 -0
  34. package/rust/core/lexer/mod.rs +25 -14
  35. package/rust/core/lexer/token.rs +55 -0
  36. package/rust/core/mod.rs +5 -2
  37. package/rust/core/parser/handler/at.rs +166 -0
  38. package/rust/core/parser/handler/bank.rs +38 -0
  39. package/rust/core/parser/handler/dot.rs +112 -0
  40. package/rust/core/parser/handler/identifier.rs +134 -0
  41. package/rust/core/parser/handler/loop_.rs +55 -0
  42. package/rust/core/parser/handler/mod.rs +6 -0
  43. package/rust/core/parser/handler/tempo.rs +47 -0
  44. package/rust/core/parser/mod.rs +204 -166
  45. package/rust/core/parser/statement.rs +91 -0
  46. package/rust/core/preprocessor/loader.rs +105 -0
  47. package/rust/core/preprocessor/mod.rs +2 -24
  48. package/rust/core/preprocessor/module.rs +37 -56
  49. package/rust/core/preprocessor/processor.rs +41 -0
  50. package/rust/core/preprocessor/resolver.rs +372 -0
  51. package/rust/core/shared/duration.rs +8 -0
  52. package/rust/core/shared/mod.rs +2 -0
  53. package/rust/core/shared/value.rs +18 -0
  54. package/rust/core/store/export.rs +28 -0
  55. package/rust/core/store/global.rs +39 -0
  56. package/rust/core/store/import.rs +28 -0
  57. package/rust/core/store/mod.rs +4 -0
  58. package/rust/core/store/variable.rs +28 -0
  59. package/rust/core/utils/mod.rs +2 -0
  60. package/rust/core/utils/validation.rs +35 -0
  61. package/rust/lib.rs +0 -1
  62. package/rust/main.rs +17 -19
  63. package/rust/utils/logger.rs +69 -34
  64. package/rust/utils/mod.rs +3 -5
  65. package/templates/minimal/.devalang +1 -1
  66. package/templates/welcome/.devalang +1 -1
  67. package/rust/audio/mod.rs +0 -1
  68. package/rust/core/lexer/bracket.rs +0 -41
  69. package/rust/core/lexer/driver.rs +0 -286
  70. package/rust/core/lexer/quote.rs +0 -61
  71. package/rust/core/parser/at.rs +0 -142
  72. package/rust/core/parser/bank.rs +0 -42
  73. package/rust/core/parser/dot.rs +0 -137
  74. package/rust/core/parser/identifer.rs +0 -91
  75. package/rust/core/parser/loop_.rs +0 -62
  76. package/rust/core/parser/tempo.rs +0 -42
  77. package/rust/core/parser/variable.rs +0 -129
  78. package/rust/core/preprocessor/dependencies.rs +0 -54
  79. package/rust/core/preprocessor/resolver/at.rs +0 -24
  80. package/rust/core/preprocessor/resolver/bank.rs +0 -59
  81. package/rust/core/preprocessor/resolver/loop_.rs +0 -82
  82. package/rust/core/preprocessor/resolver/mod.rs +0 -113
  83. package/rust/core/preprocessor/resolver/tempo.rs +0 -70
  84. package/rust/core/preprocessor/resolver/trigger.rs +0 -176
  85. package/rust/core/types/cli.rs +0 -182
  86. package/rust/core/types/mod.rs +0 -8
  87. package/rust/core/types/module.rs +0 -41
  88. package/rust/core/types/parser.rs +0 -73
  89. package/rust/core/types/statement.rs +0 -105
  90. package/rust/core/types/store.rs +0 -116
  91. package/rust/core/types/token.rs +0 -83
  92. package/rust/core/types/variable.rs +0 -32
  93. package/rust/runner/executer.rs +0 -44
  94. package/rust/runner/mod.rs +0 -1
  95. /package/rust/{utils → core/utils}/path.rs +0 -0
  96. /package/rust/utils/{loader.rs → spinner.rs} +0 -0
@@ -0,0 +1,2 @@
1
+ pub mod path;
2
+ pub mod validation;
@@ -0,0 +1,35 @@
1
+ use crate::core::{ preprocessor::module::Module, shared::value::Value, store::global::GlobalStore };
2
+
3
+ pub fn is_valid_entity(entity: &str, module: &Module, global_store: &GlobalStore) -> bool {
4
+ let built_ins = ["kick", "snare", "hat", "clap"];
5
+
6
+ if built_ins.contains(&entity) {
7
+ return true;
8
+ }
9
+
10
+ if let Some(val) = module.variable_table.get(entity) {
11
+ match val {
12
+ Value::Sample(_) => true,
13
+ _ => false,
14
+ }
15
+ } else {
16
+ false
17
+ }
18
+ }
19
+
20
+ pub fn is_valid_identifier(ident: &str, module: &Module) -> bool {
21
+ let built_ins = ["auto"];
22
+
23
+ if built_ins.contains(&ident) {
24
+ return true;
25
+ }
26
+
27
+ if let Some(val) = module.variable_table.get(ident) {
28
+ match val {
29
+ Value::Identifier(_) => true,
30
+ _ => false,
31
+ }
32
+ } else {
33
+ false
34
+ }
35
+ }
package/rust/lib.rs CHANGED
@@ -1 +0,0 @@
1
- // TODO WebAssembly support
package/rust/main.rs CHANGED
@@ -1,10 +1,10 @@
1
1
  pub mod core;
2
2
  pub mod cli;
3
- pub mod runner;
4
- pub mod audio;
5
3
  pub mod utils;
4
+ pub mod config;
6
5
 
7
- use std::{ io };
6
+ use std::io;
7
+ use cli::{ Cli };
8
8
  use clap::Parser;
9
9
  use crate::{
10
10
  cli::{
@@ -12,48 +12,46 @@ use crate::{
12
12
  check::handle_check_command,
13
13
  init::handle_init_command,
14
14
  template::{ handle_template_info_command, handle_template_list_command },
15
+ Commands,
16
+ TemplateCommand,
15
17
  },
16
- core::types::{ cli::{ Cli, CliCommands, CliTemplateCommand }, config::DevalangConfig },
17
- utils::{ config::load_config, logger::log_message },
18
+ config::{ loader::load_config, Config },
18
19
  };
19
20
 
20
21
  fn main() -> io::Result<()> {
21
22
  let cli: Cli = Cli::parse();
22
- let mut config: Option<DevalangConfig> = None;
23
+ let mut config: Option<Config> = None;
23
24
 
24
25
  if !cli.no_config {
25
26
  config = load_config(None);
26
27
  } else {
27
- log_message("Configuration file loading is skipped.", "WARNING");
28
+ println!("No configuration file loaded. Running with arguments only.");
28
29
  }
29
30
 
30
31
  match cli.command {
31
- CliCommands::Init { name, template } => {
32
+ Commands::Init { name, template } => {
32
33
  handle_init_command(name, template);
33
34
  }
34
35
 
35
- CliCommands::Template { command } =>
36
+ Commands::Template { command } =>
36
37
  match command {
37
- CliTemplateCommand::List => {
38
+ TemplateCommand::List => {
38
39
  handle_template_list_command();
39
40
  }
40
- CliTemplateCommand::Info { name } => {
41
+ TemplateCommand::Info { name } => {
41
42
  handle_template_info_command(name);
42
43
  }
43
44
  }
44
45
 
45
- CliCommands::Build { entry, output, watch, compilation_mode, debug, compress } => {
46
- handle_build_command(config, entry, output, watch);
46
+ Commands::Check { entry, output, watch, compilation_mode, debug } => {
47
+ handle_check_command(config, entry, output, watch);
47
48
  }
48
49
 
49
- CliCommands::Check { entry, output, watch, compilation_mode, debug } => {
50
- handle_check_command(config, entry, output, watch);
50
+ Commands::Build { entry, output, watch, compilation_mode, debug, compress } => {
51
+ handle_build_command(config, entry, output, watch);
51
52
  }
52
53
 
53
- // TODO - Implement the play command
54
- // CliCommands::Play {} => {
55
- // log_message("Command 'play' is not implemented yet.", "WARNING");
56
- // }
54
+ _ => {}
57
55
  }
58
56
 
59
57
  Ok(())
@@ -1,49 +1,84 @@
1
- use crossterm::style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor};
1
+ use crossterm::style::{ Attribute, Color, ResetColor, SetAttribute, SetForegroundColor };
2
2
  use std::{ fmt::Write };
3
3
 
4
- pub fn log_message(message: &str, status: &str) {
5
- let formatted_status = format_status(status);
6
- println!("🦊 {} {} {}", language_signature(), formatted_status, message);
4
+ #[derive(Debug, Clone, PartialEq)]
5
+ pub enum LogLevel {
6
+ Success,
7
+ Error,
8
+ Info,
9
+ Warning,
10
+ Watcher,
11
+ Debug,
7
12
  }
8
13
 
9
- fn language_signature() -> String {
10
- let mut s = String::new();
14
+ #[derive(Debug, Clone)]
15
+ pub struct Logger {}
11
16
 
12
- write!(&mut s, "{}", SetForegroundColor(Color::Grey)).unwrap();
13
- s.push('[');
17
+ impl Logger {
18
+ pub fn new() -> Self {
19
+ Logger {}
20
+ }
14
21
 
15
- write!(&mut s, "{}", SetForegroundColor(Color::Rgb { r: 29, g: 211, b: 176 })).unwrap();
16
- write!(&mut s, "{}", SetAttribute(Attribute::Bold)).unwrap();
17
- s.push_str("Devalang");
18
- write!(&mut s, "{}", SetAttribute(Attribute::Reset)).unwrap();
22
+ pub fn log_message(&self, level: LogLevel, message: &str) {
23
+ let formatted_status = self.format_status(level);
24
+ println!("🦊 {} {} {}", self.language_signature(), formatted_status, message);
25
+ }
19
26
 
20
- write!(&mut s, "{}", SetForegroundColor(Color::Grey)).unwrap();
21
- s.push(']');
27
+ pub fn log_error_with_stacktrace(&self, message: &str, stacktrace: &str) {
28
+ let formatted_status = self.format_status(LogLevel::Error);
29
+ println!("🦊 {} {} {}", self.language_signature(), formatted_status, message);
30
+ println!(" ↳ {}", stacktrace);
31
+ }
22
32
 
23
- write!(&mut s, "{}", ResetColor).unwrap();
33
+ fn language_signature(&self) -> String {
34
+ let mut s = String::new();
24
35
 
25
- s
26
- }
36
+ write!(&mut s, "{}", SetForegroundColor(Color::Grey)).unwrap();
37
+ s.push('[');
38
+
39
+ write!(&mut s, "{}", SetForegroundColor(Color::Rgb { r: 29, g: 211, b: 176 })).unwrap();
40
+ write!(&mut s, "{}", SetAttribute(Attribute::Bold)).unwrap();
41
+ s.push_str("Devalang");
42
+ write!(&mut s, "{}", SetAttribute(Attribute::Reset)).unwrap();
43
+
44
+ write!(&mut s, "{}", SetForegroundColor(Color::Grey)).unwrap();
45
+ s.push(']');
46
+
47
+ write!(&mut s, "{}", ResetColor).unwrap();
48
+
49
+ s
50
+ }
51
+
52
+ fn format_status(&self, level: LogLevel) -> String {
53
+ let mut s = String::new();
27
54
 
28
- fn format_status(status: &str) -> String {
29
- let mut s = String::new();
55
+ let color = match level {
56
+ LogLevel::Success => Color::Rgb { r: 76, g: 175, b: 80 },
57
+ LogLevel::Error => Color::Rgb { r: 244, g: 67, b: 54 },
58
+ LogLevel::Info => Color::Rgb { r: 33, g: 150, b: 243 },
59
+ LogLevel::Warning => Color::Rgb { r: 255, g: 152, b: 0 },
60
+ LogLevel::Watcher => Color::Rgb { r: 156, g: 39, b: 176 },
61
+ LogLevel::Debug => Color::Rgb { r: 103, g: 58, b: 183 },
62
+ };
30
63
 
31
- let color = match status {
32
- "SUCCESS" => Color::Rgb { r: 76, g: 175, b: 80 },
33
- "ERROR" => Color::Rgb { r: 244, g: 67, b: 54 },
34
- "INFO" => Color::Rgb { r: 33, g: 150, b: 243 },
35
- "WARNING" => Color::Rgb { r: 255, g: 152, b: 0 },
36
- _ => Color::Grey,
37
- };
64
+ let status = match level {
65
+ LogLevel::Success => "SUCCESS",
66
+ LogLevel::Error => "ERROR",
67
+ LogLevel::Info => "INFO",
68
+ LogLevel::Warning => "WARNING",
69
+ LogLevel::Watcher => "WATCHER",
70
+ LogLevel::Debug => "DEBUG",
71
+ };
38
72
 
39
- s.push('[');
40
- write!(&mut s, "{}", SetForegroundColor(color)).unwrap();
41
- write!(&mut s, "{}", SetAttribute(Attribute::Bold)).unwrap();
42
- s.push_str(status);
43
- write!(&mut s, "{}", SetAttribute(Attribute::Reset)).unwrap();
44
- s.push(']');
73
+ s.push('[');
74
+ write!(&mut s, "{}", SetForegroundColor(color)).unwrap();
75
+ write!(&mut s, "{}", SetAttribute(Attribute::Bold)).unwrap();
76
+ s.push_str(status);
77
+ write!(&mut s, "{}", SetAttribute(Attribute::Reset)).unwrap();
78
+ s.push(']');
45
79
 
46
- write!(&mut s, "{}", ResetColor).unwrap();
80
+ write!(&mut s, "{}", ResetColor).unwrap();
47
81
 
48
- s
82
+ s
83
+ }
49
84
  }
package/rust/utils/mod.rs CHANGED
@@ -1,8 +1,6 @@
1
1
  pub mod version;
2
2
  pub mod signature;
3
- pub mod path;
4
- pub mod loader;
5
- pub mod logger;
6
- pub mod file;
3
+ pub mod spinner;
7
4
  pub mod watcher;
8
- pub mod config;
5
+ pub mod file;
6
+ pub mod logger;
@@ -1,4 +1,4 @@
1
1
  [defaults]
2
2
  entry = "./src"
3
3
  output = "./output"
4
- watch = true
4
+ watch = false
@@ -1,4 +1,4 @@
1
1
  [defaults]
2
2
  entry = "./src"
3
3
  output = "./output"
4
- watch = true
4
+ watch = false
package/rust/audio/mod.rs DELETED
@@ -1 +0,0 @@
1
- // TODO Audio engine
@@ -1,41 +0,0 @@
1
- use crate::core::types::token::{ Token, TokenKind };
2
-
3
- pub fn handle_rbracket_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
- tokens.push(Token {
13
- kind: TokenKind::RBracket,
14
- lexeme: char.to_string(),
15
- line: *line,
16
- column: *column,
17
- indent: *current_indent,
18
- });
19
-
20
- *column += 1;
21
- }
22
-
23
- pub fn handle_lbracket_lexer(
24
- char: char,
25
- chars: &mut std::iter::Peekable<std::str::Chars>,
26
- current_indent: &mut usize,
27
- indent_stack: &mut Vec<usize>,
28
- tokens: &mut Vec<Token>,
29
- line: &mut usize,
30
- column: &mut usize
31
- ) {
32
- tokens.push(Token {
33
- kind: TokenKind::LBracket,
34
- lexeme: char.to_string(),
35
- line: *line,
36
- column: *column,
37
- indent: *current_indent,
38
- });
39
-
40
- *column += 1;
41
- }
@@ -1,286 +0,0 @@
1
-
2
-
3
- use crate::core::{
4
- lexer::{
5
- at::handle_at_lexer,
6
- brace::{ handle_lbrace_lexer, handle_rbrace_lexer },
7
- colon::handle_colon_lexer,
8
- comment::handle_comment_lexer,
9
- equal::handle_equal_lexer,
10
- newline::handle_newline_lexer,
11
- bracket::{ handle_lbracket_lexer, handle_rbracket_lexer },
12
- dot::handle_dot_lexer,
13
- identifier::handle_identifier_lexer,
14
- indent::handle_indent_lexer,
15
- number::handle_number_lexer,
16
- quote::{ handle_double_quote_lexer, handle_single_quote_lexer },
17
- },
18
- types::token::{ Token, TokenKind },
19
- };
20
-
21
- pub fn lex(input: String) -> Vec<Token> {
22
- let mut tokens = Vec::new();
23
-
24
- let mut line = 1;
25
- let mut column = 1;
26
-
27
- let mut indent_stack: Vec<usize> = vec![0];
28
- let mut current_indent = 0;
29
- let mut at_line_start = true;
30
-
31
- let mut chars = input.chars().peekable();
32
-
33
- while let Some(_) = chars.peek() {
34
- if at_line_start {
35
- let (new_tokens, new_indent_stack, new_line, new_column) = handle_indent_lexer(
36
- &mut chars,
37
- &mut current_indent,
38
- &mut indent_stack,
39
- &mut tokens,
40
- &mut line,
41
- &mut column
42
- );
43
-
44
- // Update the main tokens vector and indent stack
45
- tokens = new_tokens;
46
- indent_stack = new_indent_stack;
47
- line = new_line;
48
- column = new_column;
49
-
50
- // Reset at_line_start flag
51
- at_line_start = false;
52
- }
53
-
54
- // Read the next character
55
- let Some(ch) = chars.next() else {
56
- break;
57
- };
58
-
59
- // Newline handling
60
- if ch == '\n' {
61
- handle_newline_lexer(
62
- ch,
63
- &mut chars,
64
- &mut tokens,
65
- &mut line,
66
- &mut column,
67
- &mut at_line_start,
68
- &mut current_indent
69
- );
70
-
71
- continue;
72
- }
73
-
74
- if ch == ' ' || ch == '\t' {
75
- column += if ch == '\t' { 4 } else { 1 };
76
- continue;
77
- }
78
-
79
- if ch == '#' {
80
- handle_comment_lexer(
81
- ch,
82
- &mut chars,
83
- &mut current_indent,
84
- &mut indent_stack,
85
- &mut tokens,
86
- &mut line,
87
- &mut column
88
- );
89
-
90
- continue;
91
- }
92
-
93
- if ch == ':' {
94
- handle_colon_lexer(
95
- ch,
96
- &mut chars,
97
- &mut current_indent,
98
- &mut indent_stack,
99
- &mut tokens,
100
- &mut line,
101
- &mut column
102
- );
103
-
104
- continue;
105
- }
106
-
107
- if ch == '=' {
108
- handle_equal_lexer(
109
- ch,
110
- &mut chars,
111
- &mut current_indent,
112
- &mut indent_stack,
113
- &mut tokens,
114
- &mut line,
115
- &mut column
116
- );
117
-
118
- continue;
119
- }
120
-
121
- if ch == '[' {
122
- handle_lbracket_lexer(
123
- ch,
124
- &mut chars,
125
- &mut current_indent,
126
- &mut indent_stack,
127
- &mut tokens,
128
- &mut line,
129
- &mut column
130
- );
131
-
132
- continue;
133
- }
134
-
135
- if ch == ']' {
136
- handle_rbracket_lexer(
137
- ch,
138
- &mut chars,
139
- &mut current_indent,
140
- &mut indent_stack,
141
- &mut tokens,
142
- &mut line,
143
- &mut column
144
- );
145
-
146
- continue;
147
- }
148
-
149
- if ch == '{' {
150
- handle_lbrace_lexer(
151
- ch,
152
- &mut chars,
153
- &mut current_indent,
154
- &mut indent_stack,
155
- &mut tokens,
156
- &mut line,
157
- &mut column
158
- );
159
-
160
- continue;
161
- }
162
-
163
- if ch == '}' {
164
- handle_rbrace_lexer(
165
- ch,
166
- &mut chars,
167
- &mut current_indent,
168
- &mut indent_stack,
169
- &mut tokens,
170
- &mut line,
171
- &mut column
172
- );
173
-
174
- continue;
175
- }
176
-
177
- if ch == '"' {
178
- handle_double_quote_lexer(
179
- ch,
180
- &mut chars,
181
- &mut current_indent,
182
- &mut indent_stack,
183
- &mut tokens,
184
- &mut line,
185
- &mut column
186
- );
187
-
188
- continue;
189
- }
190
-
191
- if ch == '\'' {
192
- handle_single_quote_lexer(
193
- ch,
194
- &mut chars,
195
- &mut current_indent,
196
- &mut indent_stack,
197
- &mut tokens,
198
- &mut line,
199
- &mut column
200
- );
201
-
202
- continue;
203
- }
204
-
205
- if ch == '.' {
206
- handle_dot_lexer(
207
- ch,
208
- &mut chars,
209
- &mut current_indent,
210
- &mut indent_stack,
211
- &mut tokens,
212
- &mut line,
213
- &mut column
214
- );
215
-
216
- continue;
217
- }
218
-
219
- if ch == '@' {
220
- handle_at_lexer(
221
- ch,
222
- &mut chars,
223
- &mut current_indent,
224
- &mut indent_stack,
225
- &mut tokens,
226
- &mut line,
227
- &mut column
228
- );
229
-
230
- continue;
231
- }
232
-
233
- if ch.is_ascii_digit() {
234
- handle_number_lexer(
235
- ch,
236
- &mut chars,
237
- &mut current_indent,
238
- &mut indent_stack,
239
- &mut tokens,
240
- &mut line,
241
- &mut column
242
- );
243
-
244
- continue;
245
- }
246
-
247
- if ch.is_ascii_alphabetic() {
248
- handle_identifier_lexer(
249
- ch,
250
- &mut chars,
251
- &mut current_indent,
252
- &mut indent_stack,
253
- &mut tokens,
254
- &mut line,
255
- &mut column
256
- );
257
-
258
- continue;
259
- }
260
-
261
- // Skip unknown char
262
- column += 1;
263
- }
264
-
265
- while indent_stack.len() > 1 {
266
- indent_stack.pop();
267
- current_indent = *indent_stack.last().unwrap();
268
- tokens.push(Token {
269
- kind: TokenKind::Dedent,
270
- lexeme: String::new(),
271
- line,
272
- column,
273
- indent: current_indent,
274
- });
275
- }
276
-
277
- tokens.push(Token {
278
- kind: TokenKind::EOF,
279
- lexeme: String::new(),
280
- line: line + 1, // EOF is considered to be on the next line
281
- column: 0, // EOF has no column
282
- indent: 0, // EOF has no indent
283
- });
284
-
285
- tokens
286
- }
@@ -1,61 +0,0 @@
1
- use crate::core::types::token::{Token, TokenKind};
2
-
3
- pub fn handle_single_quote_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
- let mut string_content = String::new();
13
- *column += 1;
14
-
15
- while let Some(next_ch) = chars.next() {
16
- *column += 1;
17
- if next_ch == '\'' {
18
- break;
19
- } else {
20
- string_content.push(next_ch);
21
- }
22
- }
23
-
24
- tokens.push(Token {
25
- kind: TokenKind::String,
26
- lexeme: string_content,
27
- line: *line,
28
- column: *column,
29
- indent: *current_indent,
30
- });
31
- }
32
-
33
- pub fn handle_double_quote_lexer(
34
- char: char,
35
- chars: &mut std::iter::Peekable<std::str::Chars>,
36
- current_indent: &mut usize,
37
- indent_stack: &mut Vec<usize>,
38
- tokens: &mut Vec<Token>,
39
- line: &mut usize,
40
- column: &mut usize
41
- ) {
42
- let mut string_content = String::new();
43
- *column += 1; // skip the opening quote
44
-
45
- while let Some(next_ch) = chars.next() {
46
- *column += 1;
47
- if next_ch == '"' {
48
- break; // closing quote reached
49
- } else {
50
- string_content.push(next_ch);
51
- }
52
- }
53
-
54
- tokens.push(Token {
55
- kind: TokenKind::String,
56
- lexeme: string_content,
57
- line: *line,
58
- column: *column,
59
- indent: *current_indent,
60
- });
61
- }