@devaloop/devalang 0.0.1-beta.2 → 0.1.1
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/README.md +177 -146
- package/out-tsc/api.d.ts +180 -0
- package/out-tsc/api.d.ts.map +1 -0
- package/out-tsc/api.js +286 -0
- package/out-tsc/api.js.map +1 -0
- package/out-tsc/bin/index.d.ts +12 -0
- package/out-tsc/bin/index.d.ts.map +1 -0
- package/out-tsc/bin/index.js +20 -54
- package/out-tsc/bin/index.js.map +1 -0
- package/out-tsc/examples/basic-usage.d.ts +8 -0
- package/out-tsc/examples/basic-usage.d.ts.map +1 -0
- package/out-tsc/examples/basic-usage.js +113 -0
- package/out-tsc/examples/basic-usage.js.map +1 -0
- package/out-tsc/index.d.ts +19 -5
- package/out-tsc/index.d.ts.map +1 -0
- package/out-tsc/index.js +24 -6
- package/out-tsc/index.js.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts +7 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.js +36 -32
- package/out-tsc/scripts/copy-wasm-dts.js.map +1 -0
- package/out-tsc/scripts/postinstall.d.ts +1 -0
- package/out-tsc/scripts/postinstall.d.ts.map +1 -0
- package/out-tsc/scripts/postinstall.js +4 -1
- package/out-tsc/scripts/postinstall.js.map +1 -0
- package/out-tsc/scripts/version/bump.d.ts +5 -1
- package/out-tsc/scripts/version/bump.d.ts.map +1 -0
- package/out-tsc/scripts/version/bump.js +114 -44
- package/out-tsc/scripts/version/bump.js.map +1 -0
- package/out-tsc/scripts/version/fetch.d.ts +12 -1
- package/out-tsc/scripts/version/fetch.d.ts.map +1 -0
- package/out-tsc/scripts/version/fetch.js +68 -24
- package/out-tsc/scripts/version/fetch.js.map +1 -0
- package/out-tsc/scripts/version/index.d.ts +6 -0
- package/out-tsc/scripts/version/index.d.ts.map +1 -0
- package/out-tsc/scripts/version/index.js +44 -22
- package/out-tsc/scripts/version/index.js.map +1 -0
- package/out-tsc/scripts/version/sync.d.ts +5 -1
- package/out-tsc/scripts/version/sync.d.ts.map +1 -0
- package/out-tsc/scripts/version/sync.js +78 -29
- package/out-tsc/scripts/version/sync.js.map +1 -0
- package/out-tsc/types.d.ts +68 -0
- package/out-tsc/types.d.ts.map +1 -0
- package/out-tsc/{core/types/value.js → types.js} +4 -0
- package/out-tsc/types.js.map +1 -0
- package/out-tsc/wasm.d.ts +8 -0
- package/out-tsc/wasm.d.ts.map +1 -0
- package/out-tsc/{core/index.js → wasm.js} +9 -6
- package/out-tsc/wasm.js.map +1 -0
- package/package.json +50 -37
- package/.cargo/config.toml +0 -2
- package/.devalang +0 -9
- package/.github/workflows/ci.yml +0 -103
- package/Cargo.toml +0 -81
- package/docs/CHANGELOG.md +0 -581
- package/docs/CONTRIBUTING.md +0 -101
- package/docs/ROADMAP.md +0 -38
- package/docs/TODO.md +0 -71
- package/examples/automation.deva +0 -42
- package/examples/bank.deva +0 -7
- package/examples/bus.deva +0 -10
- package/examples/condition.deva +0 -20
- package/examples/duration.deva +0 -9
- package/examples/effect.deva +0 -2
- package/examples/events.deva +0 -12
- package/examples/filter.deva +0 -11
- package/examples/function.deva +0 -15
- package/examples/group.deva +0 -12
- package/examples/index.deva +0 -63
- package/examples/lfo.deva +0 -9
- package/examples/loop.deva +0 -10
- package/examples/pattern.deva +0 -8
- package/examples/plugin.deva +0 -16
- package/examples/samples/hat-808.wav +0 -0
- package/examples/samples/kick-808.wav +0 -0
- package/examples/synth.deva +0 -24
- package/examples/synth_types.deva +0 -17
- package/examples/variables.deva +0 -9
- package/out-tsc/core/functions/index.d.ts +0 -42
- package/out-tsc/core/functions/index.js +0 -87
- package/out-tsc/core/index.d.ts +0 -6
- package/out-tsc/core/types/index.d.ts +0 -4
- package/out-tsc/core/types/index.js +0 -20
- package/out-tsc/core/types/plugin.d.ts +0 -18
- package/out-tsc/core/types/plugin.js +0 -2
- package/out-tsc/core/types/result.d.ts +0 -27
- package/out-tsc/core/types/result.js +0 -2
- package/out-tsc/core/types/statement.d.ts +0 -106
- package/out-tsc/core/types/statement.js +0 -2
- package/out-tsc/core/types/value.d.ts +0 -43
- package/out-tsc/pkg/devalang_core.d.ts +0 -15
- package/out-tsc/pkg/devalang_core.js +0 -65
- package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +0 -34
- package/project-version.json +0 -6
- package/rust/cli/bank/api.rs +0 -122
- package/rust/cli/bank/commands.rs +0 -306
- package/rust/cli/bank/mod.rs +0 -29
- package/rust/cli/build/commands.rs +0 -153
- package/rust/cli/build/mod.rs +0 -2
- package/rust/cli/build/process.rs +0 -165
- package/rust/cli/check/mod.rs +0 -208
- package/rust/cli/discover/commands.rs +0 -253
- package/rust/cli/discover/config.rs +0 -111
- package/rust/cli/discover/fs.rs +0 -19
- package/rust/cli/discover/install.rs +0 -103
- package/rust/cli/discover/metadata.rs +0 -48
- package/rust/cli/discover/mod.rs +0 -5
- package/rust/cli/init/commands.rs +0 -88
- package/rust/cli/init/mod.rs +0 -1
- package/rust/cli/install/addon.rs +0 -118
- package/rust/cli/install/bank.rs +0 -72
- package/rust/cli/install/commands.rs +0 -35
- package/rust/cli/install/mod.rs +0 -4
- package/rust/cli/install/plugin.rs +0 -80
- package/rust/cli/login/commands.rs +0 -124
- package/rust/cli/login/mod.rs +0 -1
- package/rust/cli/mod.rs +0 -12
- package/rust/cli/parser.rs +0 -359
- package/rust/cli/play/commands.rs +0 -375
- package/rust/cli/play/io.rs +0 -17
- package/rust/cli/play/mod.rs +0 -5
- package/rust/cli/play/process.rs +0 -159
- package/rust/cli/play/realtime.rs +0 -91
- package/rust/cli/play/utils.rs +0 -23
- package/rust/cli/telemetry/commands.rs +0 -22
- package/rust/cli/telemetry/event_creator.rs +0 -80
- package/rust/cli/telemetry/mod.rs +0 -3
- package/rust/cli/telemetry/send.rs +0 -51
- package/rust/cli/template/commands.rs +0 -69
- package/rust/cli/template/mod.rs +0 -1
- package/rust/cli/update/commands.rs +0 -6
- package/rust/cli/update/mod.rs +0 -1
- package/rust/config/driver.rs +0 -112
- package/rust/config/mod.rs +0 -3
- package/rust/config/ops.rs +0 -26
- package/rust/config/settings.rs +0 -101
- package/rust/core/audio/engine/driver.rs +0 -220
- package/rust/core/audio/engine/export.rs +0 -169
- package/rust/core/audio/engine/helpers.rs +0 -178
- package/rust/core/audio/engine/mod.rs +0 -56
- package/rust/core/audio/engine/notes/dsp.rs +0 -85
- package/rust/core/audio/engine/notes/mod.rs +0 -44
- package/rust/core/audio/engine/notes/params.rs +0 -294
- package/rust/core/audio/engine/sample/insert.rs +0 -199
- package/rust/core/audio/engine/sample/mod.rs +0 -40
- package/rust/core/audio/engine/sample/padding.rs +0 -170
- package/rust/core/audio/evaluator/condition.rs +0 -61
- package/rust/core/audio/evaluator/mod.rs +0 -9
- package/rust/core/audio/evaluator/numeric.rs +0 -152
- package/rust/core/audio/evaluator/rhs.rs +0 -16
- package/rust/core/audio/evaluator/string_expr.rs +0 -94
- package/rust/core/audio/interpreter/driver.rs +0 -574
- package/rust/core/audio/interpreter/mod.rs +0 -2
- package/rust/core/audio/interpreter/statements/arrow_call/interprete.rs +0 -175
- package/rust/core/audio/interpreter/statements/arrow_call/methods/chord.rs +0 -384
- package/rust/core/audio/interpreter/statements/arrow_call/methods/mod.rs +0 -2
- package/rust/core/audio/interpreter/statements/arrow_call/methods/note.rs +0 -316
- package/rust/core/audio/interpreter/statements/arrow_call/mod.rs +0 -3
- package/rust/core/audio/interpreter/statements/arrow_call/types/arp.rs +0 -192
- package/rust/core/audio/interpreter/statements/arrow_call/types/mod.rs +0 -24
- package/rust/core/audio/interpreter/statements/arrow_call/types/pad.rs +0 -116
- package/rust/core/audio/interpreter/statements/arrow_call/types/pluck.rs +0 -97
- package/rust/core/audio/interpreter/statements/arrow_call/types/sub.rs +0 -100
- package/rust/core/audio/interpreter/statements/automate.rs +0 -16
- package/rust/core/audio/interpreter/statements/call.rs +0 -295
- package/rust/core/audio/interpreter/statements/condition.rs +0 -72
- package/rust/core/audio/interpreter/statements/function.rs +0 -24
- package/rust/core/audio/interpreter/statements/let_.rs +0 -36
- package/rust/core/audio/interpreter/statements/load.rs +0 -17
- package/rust/core/audio/interpreter/statements/loop_.rs +0 -115
- package/rust/core/audio/interpreter/statements/mod.rs +0 -12
- package/rust/core/audio/interpreter/statements/sleep.rs +0 -28
- package/rust/core/audio/interpreter/statements/spawn.rs +0 -253
- package/rust/core/audio/interpreter/statements/tempo.rs +0 -40
- package/rust/core/audio/interpreter/statements/trigger.rs +0 -239
- package/rust/core/audio/loader/mod.rs +0 -1
- package/rust/core/audio/loader/trigger.rs +0 -98
- package/rust/core/audio/mod.rs +0 -6
- package/rust/core/audio/player.rs +0 -70
- package/rust/core/audio/special/easing.rs +0 -189
- package/rust/core/audio/special/env.rs +0 -45
- package/rust/core/audio/special/math.rs +0 -134
- package/rust/core/audio/special/mod.rs +0 -9
- package/rust/core/audio/special/modulator.rs +0 -143
- package/rust/core/builder/mod.rs +0 -129
- package/rust/core/debugger/lexer.rs +0 -27
- package/rust/core/debugger/logs.rs +0 -52
- package/rust/core/debugger/mod.rs +0 -30
- package/rust/core/debugger/preprocessor.rs +0 -27
- package/rust/core/debugger/store.rs +0 -38
- package/rust/core/error/mod.rs +0 -269
- package/rust/core/lexer/driver.rs +0 -59
- package/rust/core/lexer/handler/arrow.rs +0 -82
- package/rust/core/lexer/handler/at.rs +0 -21
- package/rust/core/lexer/handler/brace.rs +0 -41
- package/rust/core/lexer/handler/colon.rs +0 -21
- package/rust/core/lexer/handler/comment.rs +0 -30
- package/rust/core/lexer/handler/dot.rs +0 -21
- package/rust/core/lexer/handler/driver.rs +0 -337
- package/rust/core/lexer/handler/identifier.rs +0 -47
- package/rust/core/lexer/handler/indent.rs +0 -66
- package/rust/core/lexer/handler/mod.rs +0 -15
- package/rust/core/lexer/handler/newline.rs +0 -23
- package/rust/core/lexer/handler/number.rs +0 -31
- package/rust/core/lexer/handler/operator.rs +0 -46
- package/rust/core/lexer/handler/parenthesis.rs +0 -41
- package/rust/core/lexer/handler/slash.rs +0 -21
- package/rust/core/lexer/handler/string.rs +0 -63
- package/rust/core/lexer/mod.rs +0 -3
- package/rust/core/lexer/token.rs +0 -91
- package/rust/core/mod.rs +0 -9
- package/rust/core/parser/driver/block.rs +0 -111
- package/rust/core/parser/driver/cursor.rs +0 -82
- package/rust/core/parser/driver/driver_impl.rs +0 -139
- package/rust/core/parser/driver/mod.rs +0 -6
- package/rust/core/parser/driver/parse_array.rs +0 -120
- package/rust/core/parser/driver/parse_map.rs +0 -223
- package/rust/core/parser/driver/parser.rs +0 -160
- package/rust/core/parser/handler/arrow_call.rs +0 -277
- package/rust/core/parser/handler/at.rs +0 -279
- package/rust/core/parser/handler/bank.rs +0 -104
- package/rust/core/parser/handler/condition.rs +0 -83
- package/rust/core/parser/handler/dot.rs +0 -148
- package/rust/core/parser/handler/identifier/automate.rs +0 -254
- package/rust/core/parser/handler/identifier/call.rs +0 -91
- package/rust/core/parser/handler/identifier/emit.rs +0 -70
- package/rust/core/parser/handler/identifier/function.rs +0 -113
- package/rust/core/parser/handler/identifier/group.rs +0 -89
- package/rust/core/parser/handler/identifier/let_.rs +0 -173
- package/rust/core/parser/handler/identifier/mod.rs +0 -55
- package/rust/core/parser/handler/identifier/on.rs +0 -107
- package/rust/core/parser/handler/identifier/print.rs +0 -49
- package/rust/core/parser/handler/identifier/sleep.rs +0 -96
- package/rust/core/parser/handler/identifier/spawn.rs +0 -91
- package/rust/core/parser/handler/identifier/synth.rs +0 -135
- package/rust/core/parser/handler/loop_.rs +0 -194
- package/rust/core/parser/handler/mod.rs +0 -9
- package/rust/core/parser/handler/pattern.rs +0 -74
- package/rust/core/parser/handler/tempo.rs +0 -105
- package/rust/core/parser/mod.rs +0 -3
- package/rust/core/parser/statement.rs +0 -10
- package/rust/core/plugin/loader.rs +0 -137
- package/rust/core/plugin/mod.rs +0 -2
- package/rust/core/plugin/runner/mod.rs +0 -11
- package/rust/core/plugin/runner/non_wasm.rs +0 -297
- package/rust/core/plugin/runner/wasm32.rs +0 -43
- package/rust/core/preprocessor/loader/inject.rs +0 -278
- package/rust/core/preprocessor/loader/loader_helpers.rs +0 -110
- package/rust/core/preprocessor/loader/mod.rs +0 -235
- package/rust/core/preprocessor/mod.rs +0 -4
- package/rust/core/preprocessor/module.rs +0 -55
- package/rust/core/preprocessor/processor/handlers.rs +0 -107
- package/rust/core/preprocessor/processor/mod.rs +0 -1
- package/rust/core/preprocessor/resolver/bank.rs +0 -49
- package/rust/core/preprocessor/resolver/call.rs +0 -124
- package/rust/core/preprocessor/resolver/condition.rs +0 -95
- package/rust/core/preprocessor/resolver/driver.rs +0 -324
- package/rust/core/preprocessor/resolver/function.rs +0 -69
- package/rust/core/preprocessor/resolver/group.rs +0 -122
- package/rust/core/preprocessor/resolver/let_.rs +0 -32
- package/rust/core/preprocessor/resolver/loop_.rs +0 -318
- package/rust/core/preprocessor/resolver/mod.rs +0 -16
- package/rust/core/preprocessor/resolver/pattern.rs +0 -83
- package/rust/core/preprocessor/resolver/spawn.rs +0 -99
- package/rust/core/preprocessor/resolver/synth.rs +0 -54
- package/rust/core/preprocessor/resolver/tempo.rs +0 -48
- package/rust/core/preprocessor/resolver/trigger.rs +0 -116
- package/rust/core/preprocessor/resolver/value.rs +0 -176
- package/rust/core/store/global.rs +0 -57
- package/rust/core/store/mod.rs +0 -1
- package/rust/lib.rs +0 -323
- package/rust/main.rs +0 -388
- package/rust/types/Cargo.toml +0 -11
- package/rust/types/src/addons.rs +0 -55
- package/rust/types/src/ast.rs +0 -202
- package/rust/types/src/config.rs +0 -84
- package/rust/types/src/lib.rs +0 -15
- package/rust/types/src/plugin.rs +0 -20
- package/rust/types/src/store.rs +0 -139
- package/rust/types/src/telemetry.rs +0 -85
- package/rust/utils/Cargo.toml +0 -26
- package/rust/utils/src/error.rs +0 -186
- package/rust/utils/src/file.rs +0 -94
- package/rust/utils/src/first_usage.rs +0 -97
- package/rust/utils/src/lib.rs +0 -9
- package/rust/utils/src/logger.rs +0 -200
- package/rust/utils/src/path.rs +0 -129
- package/rust/utils/src/signature.rs +0 -41
- package/rust/utils/src/spinner.rs +0 -20
- package/rust/utils/src/version.rs +0 -27
- package/rust/utils/src/watcher.rs +0 -46
- package/rust/web/api.rs +0 -5
- package/rust/web/cdn.rs +0 -34
- package/rust/web/mod.rs +0 -3
- package/rust/web/sso.rs +0 -5
- package/templates/minimal/.devalang +0 -5
- package/templates/minimal/README.md +0 -218
- package/templates/minimal/src/index.deva +0 -2
- package/templates/welcome/.devalang +0 -5
- package/templates/welcome/README.md +0 -218
- package/templates/welcome/samples/kick-808.wav +0 -0
- package/templates/welcome/src/index.deva +0 -61
- package/templates/welcome/src/variables.deva +0 -3
- package/tests/integration.rs +0 -21
- package/tests/rust/cli_check_build.rs +0 -21
- package/tests/rust/cli_help.rs +0 -12
- package/tests/rust/cli_template_list.rs +0 -10
- package/tests/rust/cli_version.rs +0 -11
- package/tests/typescript/index.spec.ts +0 -136
- package/tests/typescript/playhead.spec.ts +0 -36
- package/tests/typescript/render_e2e.spec.ts +0 -77
- package/tsconfig.json +0 -115
- package/typescript/bin/index.ts +0 -28
- package/typescript/core/functions/index.ts +0 -94
- package/typescript/core/index.ts +0 -6
- package/typescript/core/types/index.ts +0 -4
- package/typescript/core/types/plugin.ts +0 -19
- package/typescript/core/types/result.ts +0 -29
- package/typescript/core/types/statement.ts +0 -47
- package/typescript/core/types/value.ts +0 -29
- package/typescript/index.ts +0 -8
- package/typescript/pkg/devalang_core.d.ts +0 -4
- package/typescript/pkg/devalang_core.ts +0 -65
- package/typescript/scripts/copy-wasm-dts.ts +0 -41
- package/typescript/scripts/postinstall.ts +0 -85
- package/typescript/scripts/version/bump.ts +0 -44
- package/typescript/scripts/version/fetch.ts +0 -18
- package/typescript/scripts/version/index.ts +0 -25
- package/typescript/scripts/version/sync.ts +0 -24
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn handle_newline_lexer(
|
|
4
|
-
ch: char,
|
|
5
|
-
_chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
6
|
-
tokens: &mut Vec<Token>,
|
|
7
|
-
line: &mut usize,
|
|
8
|
-
column: &mut usize,
|
|
9
|
-
at_line_start: &mut bool,
|
|
10
|
-
current_indent: &mut usize,
|
|
11
|
-
) {
|
|
12
|
-
tokens.push(Token {
|
|
13
|
-
kind: TokenKind::Newline,
|
|
14
|
-
lexeme: ch.to_string(),
|
|
15
|
-
line: *line,
|
|
16
|
-
column: 0,
|
|
17
|
-
indent: *current_indent,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
*line += 1;
|
|
21
|
-
*column = 1;
|
|
22
|
-
*at_line_start = true;
|
|
23
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn handle_number_lexer(
|
|
4
|
-
ch: char,
|
|
5
|
-
chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
6
|
-
current_indent: &mut usize,
|
|
7
|
-
_indent_stack: &mut [usize],
|
|
8
|
-
tokens: &mut Vec<Token>,
|
|
9
|
-
line: &mut usize,
|
|
10
|
-
column: &mut usize,
|
|
11
|
-
) {
|
|
12
|
-
let mut number = ch.to_string();
|
|
13
|
-
|
|
14
|
-
while let Some(&c) = chars.peek() {
|
|
15
|
-
if c.is_ascii_digit() {
|
|
16
|
-
number.push(c);
|
|
17
|
-
chars.next();
|
|
18
|
-
*column += 1;
|
|
19
|
-
} else {
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
tokens.push(Token {
|
|
25
|
-
kind: TokenKind::Number,
|
|
26
|
-
lexeme: number,
|
|
27
|
-
line: *line,
|
|
28
|
-
column: *column,
|
|
29
|
-
indent: *current_indent,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn handle_operator_lexer(
|
|
4
|
-
ch: char,
|
|
5
|
-
chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
6
|
-
current_indent: &mut usize,
|
|
7
|
-
_indent_stack: &mut [usize],
|
|
8
|
-
tokens: &mut Vec<Token>,
|
|
9
|
-
line: &mut usize,
|
|
10
|
-
column: &mut usize,
|
|
11
|
-
) {
|
|
12
|
-
let next = chars.peek().copied();
|
|
13
|
-
|
|
14
|
-
let (kind, len) = match (ch, next) {
|
|
15
|
-
('=', Some('=')) => (TokenKind::DoubleEquals, 2),
|
|
16
|
-
('!', Some('=')) => (TokenKind::NotEquals, 2),
|
|
17
|
-
('>', Some('=')) => (TokenKind::GreaterEqual, 2),
|
|
18
|
-
('<', Some('=')) => (TokenKind::LessEqual, 2),
|
|
19
|
-
('+', _) => (TokenKind::Plus, 1),
|
|
20
|
-
('*', _) => (TokenKind::Asterisk, 1),
|
|
21
|
-
('=', _) => (TokenKind::Equals, 1),
|
|
22
|
-
('>', _) => (TokenKind::Greater, 1),
|
|
23
|
-
('<', _) => (TokenKind::Less, 1),
|
|
24
|
-
_ => {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
if len == 2 {
|
|
30
|
-
chars.next(); // consume second char
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
tokens.push(Token {
|
|
34
|
-
kind,
|
|
35
|
-
lexeme: if len == 2 {
|
|
36
|
-
format!("{}{}", ch, next.unwrap())
|
|
37
|
-
} else {
|
|
38
|
-
ch.to_string()
|
|
39
|
-
},
|
|
40
|
-
line: *line,
|
|
41
|
-
column: *column,
|
|
42
|
-
indent: *current_indent,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
*column += len;
|
|
46
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn handle_rparen_lexer(
|
|
4
|
-
ch: char,
|
|
5
|
-
_chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
6
|
-
current_indent: &mut usize,
|
|
7
|
-
_indent_stack: &mut [usize],
|
|
8
|
-
tokens: &mut Vec<Token>,
|
|
9
|
-
line: &mut usize,
|
|
10
|
-
column: &mut usize,
|
|
11
|
-
) {
|
|
12
|
-
tokens.push(Token {
|
|
13
|
-
kind: TokenKind::RParen,
|
|
14
|
-
lexeme: ch.to_string(),
|
|
15
|
-
line: *line,
|
|
16
|
-
column: *column,
|
|
17
|
-
indent: *current_indent,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
*column += 1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
pub fn handle_lparen_lexer(
|
|
24
|
-
ch: char,
|
|
25
|
-
_chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
26
|
-
current_indent: &mut usize,
|
|
27
|
-
_indent_stack: &mut [usize],
|
|
28
|
-
tokens: &mut Vec<Token>,
|
|
29
|
-
line: &mut usize,
|
|
30
|
-
column: &mut usize,
|
|
31
|
-
) {
|
|
32
|
-
tokens.push(Token {
|
|
33
|
-
kind: TokenKind::LParen,
|
|
34
|
-
lexeme: ch.to_string(),
|
|
35
|
-
line: *line,
|
|
36
|
-
column: *column,
|
|
37
|
-
indent: *current_indent,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
*column += 1;
|
|
41
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn handle_slash_lexer(
|
|
4
|
-
ch: char,
|
|
5
|
-
_chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
6
|
-
current_indent: &mut usize,
|
|
7
|
-
_indent_stack: &mut [usize],
|
|
8
|
-
tokens: &mut Vec<Token>,
|
|
9
|
-
line: &mut usize,
|
|
10
|
-
column: &mut usize,
|
|
11
|
-
) {
|
|
12
|
-
let slash = ch.to_string();
|
|
13
|
-
|
|
14
|
-
tokens.push(Token {
|
|
15
|
-
kind: TokenKind::Slash,
|
|
16
|
-
lexeme: slash,
|
|
17
|
-
line: *line,
|
|
18
|
-
column: *column,
|
|
19
|
-
indent: *current_indent,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn handle_string_lexer(
|
|
4
|
-
ch: char,
|
|
5
|
-
chars: &mut std::iter::Peekable<std::str::Chars>,
|
|
6
|
-
current_indent: &mut usize,
|
|
7
|
-
_indent_stack: &mut [usize],
|
|
8
|
-
tokens: &mut Vec<Token>,
|
|
9
|
-
line: &mut usize,
|
|
10
|
-
column: &mut usize,
|
|
11
|
-
) {
|
|
12
|
-
let quote_char = ch;
|
|
13
|
-
|
|
14
|
-
let start_column = *column;
|
|
15
|
-
let start_line = *line;
|
|
16
|
-
|
|
17
|
-
*column += 1;
|
|
18
|
-
|
|
19
|
-
let mut string_content = String::new();
|
|
20
|
-
|
|
21
|
-
while let Some(&next_ch) = chars.peek() {
|
|
22
|
-
if next_ch == quote_char {
|
|
23
|
-
chars.next();
|
|
24
|
-
*column += 1;
|
|
25
|
-
break;
|
|
26
|
-
} else if next_ch == '\\' {
|
|
27
|
-
chars.next();
|
|
28
|
-
*column += 1;
|
|
29
|
-
|
|
30
|
-
if let Some(escaped) = chars.next() {
|
|
31
|
-
match escaped {
|
|
32
|
-
'n' => string_content.push('\n'),
|
|
33
|
-
't' => string_content.push('\t'),
|
|
34
|
-
'\\' => string_content.push('\\'),
|
|
35
|
-
'"' => string_content.push('"'),
|
|
36
|
-
'\'' => string_content.push('\''),
|
|
37
|
-
other => {
|
|
38
|
-
string_content.push('\\');
|
|
39
|
-
string_content.push(other);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
*column += 1;
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
chars.next();
|
|
46
|
-
if next_ch == '\n' {
|
|
47
|
-
*line += 1;
|
|
48
|
-
*column = 1;
|
|
49
|
-
} else {
|
|
50
|
-
*column += 1;
|
|
51
|
-
}
|
|
52
|
-
string_content.push(next_ch);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
tokens.push(Token {
|
|
57
|
-
kind: TokenKind::String,
|
|
58
|
-
lexeme: string_content,
|
|
59
|
-
indent: *current_indent,
|
|
60
|
-
line: start_line,
|
|
61
|
-
column: start_column,
|
|
62
|
-
});
|
|
63
|
-
}
|
package/rust/core/lexer/mod.rs
DELETED
package/rust/core/lexer/token.rs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
use serde::{Deserialize, Serialize};
|
|
2
|
-
|
|
3
|
-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
4
|
-
pub struct Token {
|
|
5
|
-
pub kind: TokenKind,
|
|
6
|
-
pub lexeme: String,
|
|
7
|
-
pub indent: usize,
|
|
8
|
-
pub line: usize,
|
|
9
|
-
pub column: usize,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
impl Token {
|
|
13
|
-
pub fn is_error(&self) -> bool {
|
|
14
|
-
matches!(&self.kind, TokenKind::Error(_))
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
19
|
-
pub enum TokenKind {
|
|
20
|
-
// ───── Keywords ─────
|
|
21
|
-
At,
|
|
22
|
-
Tempo,
|
|
23
|
-
Bank,
|
|
24
|
-
Pattern,
|
|
25
|
-
Loop,
|
|
26
|
-
Function,
|
|
27
|
-
As,
|
|
28
|
-
On,
|
|
29
|
-
Emit,
|
|
30
|
-
|
|
31
|
-
// ───── Instruments ─────
|
|
32
|
-
Synth,
|
|
33
|
-
|
|
34
|
-
// ───── Literals ─────
|
|
35
|
-
Identifier,
|
|
36
|
-
Number,
|
|
37
|
-
String,
|
|
38
|
-
Boolean,
|
|
39
|
-
Arrow,
|
|
40
|
-
|
|
41
|
-
// ───── Structures ─────
|
|
42
|
-
Map,
|
|
43
|
-
Array,
|
|
44
|
-
|
|
45
|
-
// ───── Symbols ─────
|
|
46
|
-
Colon,
|
|
47
|
-
Comma,
|
|
48
|
-
Equals,
|
|
49
|
-
Dot,
|
|
50
|
-
Slash,
|
|
51
|
-
Plus,
|
|
52
|
-
Asterisk,
|
|
53
|
-
Minus,
|
|
54
|
-
|
|
55
|
-
// ───── Operators ─────
|
|
56
|
-
DoubleEquals,
|
|
57
|
-
NotEquals,
|
|
58
|
-
GreaterEqual,
|
|
59
|
-
LessEqual,
|
|
60
|
-
Greater,
|
|
61
|
-
Less,
|
|
62
|
-
|
|
63
|
-
// ───── Brackets ─────
|
|
64
|
-
LBrace, // {
|
|
65
|
-
RBrace, // }
|
|
66
|
-
LBracket, // [
|
|
67
|
-
RBracket, // ]
|
|
68
|
-
LParen, // (
|
|
69
|
-
RParen, // )
|
|
70
|
-
|
|
71
|
-
// ───── Quotes ─────
|
|
72
|
-
Quote, // '
|
|
73
|
-
DbQuote, // "
|
|
74
|
-
|
|
75
|
-
// ───── Formatting ─────
|
|
76
|
-
Newline,
|
|
77
|
-
Indent,
|
|
78
|
-
Dedent,
|
|
79
|
-
Comment,
|
|
80
|
-
|
|
81
|
-
// ───── Conditions ─────
|
|
82
|
-
If,
|
|
83
|
-
Else,
|
|
84
|
-
ElseIf,
|
|
85
|
-
|
|
86
|
-
// ───── Special / Internal ─────
|
|
87
|
-
Whitespace,
|
|
88
|
-
Unknown,
|
|
89
|
-
Error(String),
|
|
90
|
-
EOF,
|
|
91
|
-
}
|
package/rust/core/mod.rs
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::Token;
|
|
2
|
-
use crate::core::lexer::token::TokenKind;
|
|
3
|
-
use crate::core::store::global::GlobalStore;
|
|
4
|
-
|
|
5
|
-
pub fn collect_block_tokens(
|
|
6
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
7
|
-
base_indent: usize,
|
|
8
|
-
) -> Vec<Token> {
|
|
9
|
-
let mut tokens = Vec::new();
|
|
10
|
-
|
|
11
|
-
while let Some(tok) = parser.peek() {
|
|
12
|
-
if tok.indent <= base_indent && tok.kind != TokenKind::Newline {
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
if let Some(t) = parser.advance() {
|
|
16
|
-
tokens.push(t.clone());
|
|
17
|
-
} else {
|
|
18
|
-
// Unexpected EOF while collecting block tokens: stop collecting
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
tokens
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
pub fn collect_until<F>(
|
|
27
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
28
|
-
condition: F,
|
|
29
|
-
) -> Vec<Token>
|
|
30
|
-
where
|
|
31
|
-
F: Fn(&Token) -> bool,
|
|
32
|
-
{
|
|
33
|
-
let mut collected = Vec::new();
|
|
34
|
-
while let Some(token) = parser.peek() {
|
|
35
|
-
if condition(token) {
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
if token.kind == TokenKind::EOF {
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
if let Some(t) = parser.advance() {
|
|
42
|
-
collected.push(t.clone());
|
|
43
|
-
} else {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
collected
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
pub fn parse_block(
|
|
52
|
-
parser: &crate::core::parser::driver::parser::Parser,
|
|
53
|
-
tokens: Vec<Token>,
|
|
54
|
-
global_store: &mut GlobalStore,
|
|
55
|
-
) -> Vec<crate::core::parser::statement::Statement> {
|
|
56
|
-
let mut inner_parser = crate::core::parser::driver::parser::Parser {
|
|
57
|
-
resolve_modules: parser.resolve_modules,
|
|
58
|
-
tokens,
|
|
59
|
-
token_index: 0,
|
|
60
|
-
current_module: parser.current_module.clone(),
|
|
61
|
-
previous: None,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
inner_parser.parse_tokens(inner_parser.tokens.clone(), global_store)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
pub fn parse_block_until_next_else(
|
|
68
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
69
|
-
base_indent: usize,
|
|
70
|
-
global_store: &mut GlobalStore,
|
|
71
|
-
) -> Vec<crate::core::parser::statement::Statement> {
|
|
72
|
-
let mut block_tokens = Vec::new();
|
|
73
|
-
|
|
74
|
-
while let Some(tok) = parser.peek() {
|
|
75
|
-
// Stop if we encounter an 'else' at same indent level
|
|
76
|
-
if tok.lexeme == "else" && tok.indent == base_indent {
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
if let Some(t) = parser.advance() {
|
|
80
|
-
block_tokens.push(t.clone());
|
|
81
|
-
} else {
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
parse_block(parser, block_tokens, global_store)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
pub fn parse_block_until_else_or_dedent(
|
|
90
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
91
|
-
base_indent: usize,
|
|
92
|
-
global_store: &mut GlobalStore,
|
|
93
|
-
) -> Vec<crate::core::parser::statement::Statement> {
|
|
94
|
-
let mut tokens = Vec::new();
|
|
95
|
-
|
|
96
|
-
while let Some(tok) = parser.peek() {
|
|
97
|
-
if tok.lexeme == "else" && tok.indent == base_indent {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if tok.indent < base_indent && tok.kind != TokenKind::Newline {
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
if let Some(t) = parser.advance() {
|
|
104
|
-
tokens.push(t.clone());
|
|
105
|
-
} else {
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
parse_block(parser, tokens, global_store)
|
|
111
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::{Token, TokenKind};
|
|
2
|
-
|
|
3
|
-
pub fn advance_impl(parser: &mut crate::core::parser::driver::parser::Parser) -> Option<&Token> {
|
|
4
|
-
if is_eof_impl(parser) {
|
|
5
|
-
return None;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
parser.previous = parser.tokens.get(parser.token_index).cloned();
|
|
9
|
-
parser.token_index += 1;
|
|
10
|
-
|
|
11
|
-
parser.tokens.get(parser.token_index - 1)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
pub fn peek_impl(parser: &crate::core::parser::driver::parser::Parser) -> Option<&Token> {
|
|
15
|
-
parser.tokens.get(parser.token_index)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
pub fn peek_clone_impl(parser: &crate::core::parser::driver::parser::Parser) -> Option<Token> {
|
|
19
|
-
parser.tokens.get(parser.token_index).cloned()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
pub fn peek_nth_impl(
|
|
23
|
-
parser: &crate::core::parser::driver::parser::Parser,
|
|
24
|
-
n: usize,
|
|
25
|
-
) -> Option<&Token> {
|
|
26
|
-
if parser.token_index + n < parser.tokens.len() {
|
|
27
|
-
parser.tokens.get(parser.token_index + n)
|
|
28
|
-
} else {
|
|
29
|
-
None
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
pub fn peek_nth_kind_impl(
|
|
34
|
-
parser: &crate::core::parser::driver::parser::Parser,
|
|
35
|
-
n: usize,
|
|
36
|
-
) -> Option<TokenKind> {
|
|
37
|
-
peek_nth_impl(parser, n).map(|t| t.kind.clone())
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
pub fn is_eof_impl(parser: &crate::core::parser::driver::parser::Parser) -> bool {
|
|
41
|
-
parser.token_index >= parser.tokens.len()
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
pub fn previous_clone_impl(parser: &crate::core::parser::driver::parser::Parser) -> Option<Token> {
|
|
45
|
-
parser.previous.clone()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
pub fn match_token_impl(
|
|
49
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
50
|
-
kind: TokenKind,
|
|
51
|
-
) -> bool {
|
|
52
|
-
if let Some(tok) = peek_impl(parser) {
|
|
53
|
-
if tok.kind == kind {
|
|
54
|
-
advance_impl(parser);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
false
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
pub fn advance_if_impl(
|
|
62
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
63
|
-
kind: TokenKind,
|
|
64
|
-
) -> bool {
|
|
65
|
-
match_token_impl(parser, kind)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
pub fn peek_is_impl(parser: &crate::core::parser::driver::parser::Parser, expected: &str) -> bool {
|
|
69
|
-
peek_impl(parser).is_some_and(|t| t.lexeme == expected)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
pub fn expect_impl(
|
|
73
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
74
|
-
kind: TokenKind,
|
|
75
|
-
) -> Result<&Token, String> {
|
|
76
|
-
let tok = advance_impl(parser).ok_or("Unexpected end of input")?;
|
|
77
|
-
if tok.kind == kind {
|
|
78
|
-
Ok(tok)
|
|
79
|
-
} else {
|
|
80
|
-
Err(format!("Expected {:?}, got {:?}", kind, tok.kind))
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
use crate::core::lexer::token::TokenKind;
|
|
2
|
-
use crate::core::store::global::GlobalStore;
|
|
3
|
-
use devalang_types::Value;
|
|
4
|
-
|
|
5
|
-
pub fn parse_tokens_impl(
|
|
6
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
7
|
-
tokens: Vec<crate::core::lexer::token::Token>,
|
|
8
|
-
global_store: &mut GlobalStore,
|
|
9
|
-
) -> Vec<crate::core::parser::statement::Statement> {
|
|
10
|
-
// Filter out Whitespace tokens but keep Newline tokens because some constructs (e.g., print ...)
|
|
11
|
-
// rely on end-of-line semantics.
|
|
12
|
-
parser.tokens = tokens
|
|
13
|
-
.into_iter()
|
|
14
|
-
.filter(|t| t.kind != TokenKind::Whitespace)
|
|
15
|
-
.collect();
|
|
16
|
-
parser.token_index = 0;
|
|
17
|
-
|
|
18
|
-
let mut statements = Vec::new();
|
|
19
|
-
|
|
20
|
-
while !crate::core::parser::driver::cursor::is_eof_impl(parser) {
|
|
21
|
-
let token = match crate::core::parser::driver::cursor::peek_impl(parser) {
|
|
22
|
-
Some(t) => t.clone(),
|
|
23
|
-
None => {
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
if token.kind == TokenKind::Newline {
|
|
29
|
-
crate::core::parser::driver::cursor::advance_impl(parser);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let statement = match &token.kind {
|
|
34
|
-
TokenKind::At => crate::core::parser::handler::at::parse_at_token(parser, global_store),
|
|
35
|
-
TokenKind::Identifier => {
|
|
36
|
-
if
|
|
37
|
-
let Some(next) = crate::core::parser::driver::cursor
|
|
38
|
-
::peek_nth_impl(parser, 1)
|
|
39
|
-
.cloned()
|
|
40
|
-
{
|
|
41
|
-
if next.kind == TokenKind::Arrow {
|
|
42
|
-
crate::core::parser::handler::arrow_call::parse_arrow_call(
|
|
43
|
-
parser,
|
|
44
|
-
global_store
|
|
45
|
-
)
|
|
46
|
-
} else {
|
|
47
|
-
crate::core::parser::handler::identifier::parse_identifier_token(
|
|
48
|
-
parser,
|
|
49
|
-
global_store
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
crate::core::parser::handler::identifier::parse_identifier_token(
|
|
54
|
-
parser,
|
|
55
|
-
global_store
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
TokenKind::Dot =>
|
|
60
|
-
crate::core::parser::handler::dot::parse_dot_token(parser, global_store),
|
|
61
|
-
TokenKind::Tempo =>
|
|
62
|
-
crate::core::parser::handler::tempo::parse_tempo_token(parser, global_store),
|
|
63
|
-
TokenKind::Bank =>
|
|
64
|
-
crate::core::parser::handler::bank::parse_bank_token(parser, global_store),
|
|
65
|
-
TokenKind::Pattern =>
|
|
66
|
-
crate::core::parser::handler::pattern::parse_pattern_token(parser, global_store),
|
|
67
|
-
TokenKind::Loop =>
|
|
68
|
-
crate::core::parser::handler::loop_::parse_loop_token(parser, global_store),
|
|
69
|
-
TokenKind::If =>
|
|
70
|
-
crate::core::parser::handler::condition::parse_condition_token(
|
|
71
|
-
parser,
|
|
72
|
-
global_store
|
|
73
|
-
),
|
|
74
|
-
TokenKind::Function =>
|
|
75
|
-
crate::core::parser::handler::identifier::function::parse_function_token(
|
|
76
|
-
parser,
|
|
77
|
-
global_store
|
|
78
|
-
),
|
|
79
|
-
TokenKind::On =>
|
|
80
|
-
crate::core::parser::handler::identifier::on::parse_on_token(parser, global_store),
|
|
81
|
-
TokenKind::Emit =>
|
|
82
|
-
crate::core::parser::handler::identifier::emit::parse_emit_token(
|
|
83
|
-
parser,
|
|
84
|
-
token.clone(),
|
|
85
|
-
global_store
|
|
86
|
-
),
|
|
87
|
-
|
|
88
|
-
| TokenKind::Else // Ignore else, already handled in `parse_condition_token`
|
|
89
|
-
| TokenKind::Comment
|
|
90
|
-
| TokenKind::Equals
|
|
91
|
-
| TokenKind::Colon
|
|
92
|
-
| TokenKind::Number
|
|
93
|
-
| TokenKind::String
|
|
94
|
-
| TokenKind::LBrace
|
|
95
|
-
| TokenKind::RBrace
|
|
96
|
-
| TokenKind::Comma
|
|
97
|
-
| TokenKind::Dedent
|
|
98
|
-
| TokenKind::Indent => {
|
|
99
|
-
crate::core::parser::driver::cursor::advance_impl(parser);
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
TokenKind::EOF => {
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
_ => {
|
|
108
|
-
crate::core::parser::driver::cursor::advance_impl(parser);
|
|
109
|
-
crate::core::parser::statement::Statement::unknown_with_pos(
|
|
110
|
-
token.indent,
|
|
111
|
-
token.line,
|
|
112
|
-
token.column
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
statements.push(statement);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
statements
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
pub fn parse_condition_until_colon_impl(
|
|
124
|
-
parser: &mut crate::core::parser::driver::parser::Parser,
|
|
125
|
-
) -> Option<Value> {
|
|
126
|
-
let tokens =
|
|
127
|
-
crate::core::parser::driver::block::collect_until(parser, |t| t.kind == TokenKind::Colon);
|
|
128
|
-
if tokens.is_empty() {
|
|
129
|
-
return None;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let condition = tokens
|
|
133
|
-
.iter()
|
|
134
|
-
.map(|t| t.lexeme.clone())
|
|
135
|
-
.collect::<Vec<_>>()
|
|
136
|
-
.join(" ");
|
|
137
|
-
|
|
138
|
-
Some(Value::String(condition))
|
|
139
|
-
}
|