diff --git a/antidotum/tergo/src/rust/Cargo.toml b/antidotum/tergo/src/rust/Cargo.toml index a3a6f414..20971bb0 100644 --- a/antidotum/tergo/src/rust/Cargo.toml +++ b/antidotum/tergo/src/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tergo" -version = "0.1.1" +version = "0.1.2" edition = "2021" [lib] @@ -8,7 +8,7 @@ crate-type = ["staticlib"] name = "tergo" [dependencies] -tergo-lib = "0.2.7" +tergo-lib = "0.2.8" toml = "0.8.19" extendr-api = "*" diff --git a/antidotum/tergo/src/rust/vendor.tar.xz b/antidotum/tergo/src/rust/vendor.tar.xz index f0c67399..dbafa4bb 100644 Binary files a/antidotum/tergo/src/rust/vendor.tar.xz and b/antidotum/tergo/src/rust/vendor.tar.xz differ diff --git a/antidotum/tergo/tergo_0.1.5.9001.tar.gz b/antidotum/tergo/tergo_0.1.5.9001.tar.gz new file mode 100644 index 00000000..b92299d8 Binary files /dev/null and b/antidotum/tergo/tergo_0.1.5.9001.tar.gz differ diff --git a/balnea/Cargo.toml b/balnea/Cargo.toml index 163c8770..e0cfdf66 100644 --- a/balnea/Cargo.toml +++ b/balnea/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tergo-lib" -version = "0.2.7" +version = "0.2.8" edition = "2021" description = "A tool to format R code" license = "MIT" @@ -13,7 +13,7 @@ path = "src/lib.rs" [dependencies] tokenizer = { package = "tergo-tokenizer", path = "../aqua", version = "0.2.2" } -parser = { package = "tergo-parser", path = "../spongia", version = "0.2.2" } +parser = { package = "tergo-parser", path = "../spongia", version = "0.2.3" } formatter = { package = "tergo-formatter", path = "../unguentum", version = "0.2.6" } log = "0.4.21" env_logger = "0.11.3" diff --git a/balnea/tests/format_integration.rs b/balnea/tests/format_integration.rs index 4dab17ea..8aab469a 100644 --- a/balnea/tests/format_integration.rs +++ b/balnea/tests/format_integration.rs @@ -267,6 +267,17 @@ comparison_test!( "092", Config::default() ); +comparison_test!(regression_25, "093", Config::default()); +comparison_test!( + function_call_with_one_unnamed_one_named_arg, + "094", + Config::default() +); +comparison_test!( + function_call_with_many_newlines_after_arg_names, + "095", + Config::default() +); // Tidyverse styleguide examples comparison_test!(tidyverse_commas, "tidyverse_style_guide_001"); diff --git a/balnea/tests/test_cases/093.R b/balnea/tests/test_cases/093.R new file mode 100644 index 00000000..35731c6c --- /dev/null +++ b/balnea/tests/test_cases/093.R @@ -0,0 +1,2 @@ +list.files(".", ignore.case + = TRUE) diff --git a/balnea/tests/test_cases/093.expected b/balnea/tests/test_cases/093.expected new file mode 100644 index 00000000..78448301 --- /dev/null +++ b/balnea/tests/test_cases/093.expected @@ -0,0 +1 @@ +list.files(".", ignore.case = TRUE) diff --git a/balnea/tests/test_cases/094.R b/balnea/tests/test_cases/094.R new file mode 100644 index 00000000..78448301 --- /dev/null +++ b/balnea/tests/test_cases/094.R @@ -0,0 +1 @@ +list.files(".", ignore.case = TRUE) diff --git a/balnea/tests/test_cases/094.expected b/balnea/tests/test_cases/094.expected new file mode 100644 index 00000000..78448301 --- /dev/null +++ b/balnea/tests/test_cases/094.expected @@ -0,0 +1 @@ +list.files(".", ignore.case = TRUE) diff --git a/balnea/tests/test_cases/095.R b/balnea/tests/test_cases/095.R new file mode 100644 index 00000000..57be57d9 --- /dev/null +++ b/balnea/tests/test_cases/095.R @@ -0,0 +1,8 @@ +list.files(".", ignore.case + + = TRUE, +test + += + +1) diff --git a/balnea/tests/test_cases/095.expected b/balnea/tests/test_cases/095.expected new file mode 100644 index 00000000..94f301c9 --- /dev/null +++ b/balnea/tests/test_cases/095.expected @@ -0,0 +1 @@ +list.files(".", ignore.case = TRUE, test = 1) diff --git a/scopa/Cargo.toml b/scopa/Cargo.toml index af3ff291..4fe7e79f 100644 --- a/scopa/Cargo.toml +++ b/scopa/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scopa" -version = "0.1.0" +version = "0.1.1" edition = "2021" [lib] @@ -9,7 +9,7 @@ path = "./src/lib.rs" [dependencies] wit-bindgen = "0.32.0" -tergo-lib = { path = "../balnea", version = "0.2.0" } +tergo-lib = { path = "../balnea", version = "0.2.8" } [dev-dependencies] wasm-tools = "1.217.0" diff --git a/spongia/Cargo.toml b/spongia/Cargo.toml index bd153c7b..25b0b333 100644 --- a/spongia/Cargo.toml +++ b/spongia/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tergo-parser" -version = "0.2.2" +version = "0.2.3" edition = "2021" license = "MIT" description = "Parser for tergo" diff --git a/spongia/src/compound.rs b/spongia/src/compound.rs index 4ea20d0f..702ab73e 100644 --- a/spongia/src/compound.rs +++ b/spongia/src/compound.rs @@ -12,7 +12,7 @@ use crate::{ Arg, Args, Delimiter, ElseIfConditional, Expression, ForLoop, FunctionDefinition, IfConditional, IfExpression, Lambda, RepeatExpression, TrailingElse, WhileExpression, }, - expressions::expr, + expressions::{expr, expr_with_newlines}, program::statement_or_expr, token_parsers::*, Input, @@ -48,10 +48,10 @@ where tuple(( left_delimiter, many0(newline), - opt(expr), + opt(expr_with_newlines), many0(tuple(( tuple((comma, many0(newline))), - tuple((opt(expr), many0(newline))), + tuple((opt(expr_with_newlines), many0(newline))), ))), many0(newline), right_delimiter, diff --git a/spongia/src/expressions.rs b/spongia/src/expressions.rs index 4683c350..3d26069f 100644 --- a/spongia/src/expressions.rs +++ b/spongia/src/expressions.rs @@ -309,6 +309,22 @@ pub(crate) fn expr<'a, 'b: 'a>(tokens: Input<'a, 'b>) -> IResult, } } +pub(crate) fn expr_with_newlines<'a, 'b: 'a>( + tokens: Input<'a, 'b>, +) -> IResult, Expression<'a>> { + trace!("expr: {}", TokensBuffer(tokens)); + let (mut tokens, term) = unary_term(tokens)?; + while !tokens.is_empty() && tokens[0].token == Newline { + tokens = &tokens[1..]; + } + if !tokens.is_empty() { + let parser = ExprParser(0); + parser.parse(term, tokens) + } else { + Ok((tokens, term)) + } +} + #[cfg(test)] mod tests { use tokenizer::tokens::commented_tokens; diff --git a/tergo/Cargo.toml b/tergo/Cargo.toml index ba25c04e..0f48d605 100644 --- a/tergo/Cargo.toml +++ b/tergo/Cargo.toml @@ -10,5 +10,5 @@ repository = "https://github.com/kpagacz/tergo/" clap = { version = "4.5.17", features = ["derive"] } env_logger = "0.11.5" log = "0.4.22" -tergo-lib = { path = "../balnea", version = "0.2.7" } +tergo-lib = { path = "../balnea", version = "0.2.8" } toml = "0.8.19" diff --git a/unguentum/Cargo.toml b/unguentum/Cargo.toml index 39253a57..19f71196 100644 --- a/unguentum/Cargo.toml +++ b/unguentum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tergo-formatter" -version = "0.2.6" +version = "0.2.7" edition = "2021" license = "MIT" description = "Formatter for tergo" @@ -10,7 +10,7 @@ repository = "https://github.com/kpagacz/tergo/tree/main/unguentum" [dependencies] tokenizer = { package = "tergo-tokenizer", path = "../aqua", version = "0.2.2" } -parser = { package = "tergo-parser", path = "../spongia", version = "0.2.2" } +parser = { package = "tergo-parser", path = "../spongia", version = "0.2.3" } log = "0.4.21" serde = { version = "1.0.210", features = ["derive"] }