Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
979 changes: 105 additions & 874 deletions crates/analysis/src/alpha050/exp.rs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions crates/grammar/src/alpha050/expressions/atom/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ pub fn command_parser<'a>(
.then(
choice((
any()
.filter(|c: &Token| {
*c != T!["$"] && *c != T!["{"] && *c != T!["\\"] && *c != T!["-"]
})
.filter(|c: &Token| *c != T!["$"] && *c != T!["{"])
.map(|text| InterpolatedCommand::Text(text.to_string()))
.labelled("command string"),
interpolated,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: tests/analysis/alpha050.rs
source: crates/server/tests/analysis/alpha050.rs
expression: "symbol_table.symbols.iter().map(|(_, symbol_info)|\nsymbol_info.to_string(&generic_types)).collect::<Vec<String>>()"
---
[
"fun compare_arrays(arr: [Int | Num]): Bool",
"arr: [Int | Num]",
"arr: [Int | Num]",
"fun compare_arrays(arr: [Int]): Bool",
"arr: [Int]",
"arr: [Int]",
]
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
source: tests/analysis/alpha050.rs
source: crates/server/tests/analysis/alpha050.rs
expression: "symbol_table.symbols.iter().map(|(_, symbol_info)|\nsymbol_info.to_string(&generic_types)).collect::<Vec<String>>()"
---
[
"fun foo(a?: Any): Any",
"a: Any",
"a: Any",
"a: Any",
"fun foo(a?: Int): Int",
"a: Int",
"a: Int",
"a: Int",
"x: Int",
"fun foo(a?: Int): Int",
"code: Int",
"y: Text",
"fun foo(a?: Text): Text",
"y: Int",
"fun foo(a?: Int): Int",
"code: Int",
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/analysis/alpha050.rs
source: crates/server/tests/analysis/alpha050.rs
expression: backend.files.errors
---
{
Expand All @@ -10,5 +10,10 @@ expression: backend.files.errors
FileVersion(
1,
),
): [],
): [
(
"Expected type `Int`, found type `Text`",
116..122,
),
],
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/analysis/alpha050.rs
source: crates/server/tests/analysis/alpha050.rs
expression: symbol_table.symbols
---
{
Expand Down Expand Up @@ -145,7 +145,7 @@ expression: symbol_table.symbols
is_const: false,
},
),
data_type: Text,
data_type: Int,
is_definition: true,
undefined: false,
span: 108..109,
Expand All @@ -159,7 +159,7 @@ expression: symbol_table.symbols
(
FunctionArgument {
name: "a",
data_type: Text,
data_type: Int,
is_optional: true,
default_value_type: Some(
Int,
Expand All @@ -174,7 +174,7 @@ expression: symbol_table.symbols
docs: None,
},
),
data_type: Text,
data_type: Int,
is_definition: false,
undefined: false,
span: 112..115,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
source: tests/analysis/alpha050.rs
source: crates/server/tests/analysis/alpha050.rs
expression: "symbol_table.symbols.iter().map(|(_, symbol_info)|\nsymbol_info.to_string(&generic_types)).collect::<Vec<String>>()"
---
[
"fun max_value(a: Int | Num | Text | [Int | Num | Text], b: Int | Num | Text | [Int | Num | Text]): Int | Num | Text | [Int | Num | Text]",
"a: Int | Num | Text | [Int | Num | Text]",
"b: Int | Num | Text | [Int | Num | Text]",
"a: Int | Num | Text | [Int | Num | Text]",
"b: Int | Num | Text | [Int | Num | Text]",
"a: Int | Num | Text | [Int | Num | Text]",
"b: Int | Num | Text | [Int | Num | Text]",
"fun max_value(a: Int | Num | Text | [Num | Int | Text], b: Int | Num | Text | [Num | Int | Text]): Int | Num | Text | [Num | Int | Text]",
"a: Int | Num | Text | [Num | Int | Text]",
"b: Int | Num | Text | [Num | Int | Text]",
"a: Int | Num | Text | [Num | Int | Text]",
"b: Int | Num | Text | [Num | Int | Text]",
"a: Int | Num | Text | [Num | Int | Text]",
"b: Int | Num | Text | [Num | Int | Text]",
]
9 changes: 9 additions & 0 deletions crates/server/tests/grammar/alpha050.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ fn test_lexer_command_escapes() {
compiler.tokenize(r#"$echo\ with\ spaces$"#)
);
assert_debug_snapshot!("command_backslash", compiler.tokenize(r#"$test\n$"#));
assert_debug_snapshot!(
"command_new_line",
parse(&compiler.tokenize(
r#"
$ MY_VAR=1 \
my_command $
"#
))
);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
source: crates/server/tests/grammar/alpha050.rs
expression: "parse(&compiler.tokenize(r#\"\n $ MY_VAR=1 \\\n my_command $\n \"#))"
---
(
Some(
[
(
Statement(
(
Expression(
(
Command(
[],
[
(
Text(
"$",
),
5..6,
),
(
Text(
"MY_VAR=1 ",
),
6..16,
),
(
Text(
"\\",
),
16..17,
),
(
Text(
"\n my_command ",
),
17..34,
),
(
Text(
"$",
),
34..35,
),
],
[],
),
5..35,
),
),
5..35,
),
),
5..35,
),
],
),
[],
)