Skip to content

Commit

Permalink
Bugfix: Syntax error when first output is dropped (#41)
Browse files Browse the repository at this point in the history
Fixes #39 

It was a bug in the parser, but **mofmt** also needed an update, so that
all dropped outputs are handled the same way.
  • Loading branch information
ErykMroczek authored Feb 19, 2024
2 parents feebc27 + fd9c406 commit 23f19da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["Modelica", "development", "formatter"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
moparse = "0.1.4"
moparse = "0.1.5-rc1"

[profile.release]
strip = true
3 changes: 3 additions & 0 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,9 @@ fn output_expression_list(f: &mut Formatter, tree: Tree, mut wrapped: bool) -> b
match child {
Child::Tree(t) => wrapped = expression(f, t, wrapped, true),
Child::Token(tok) => {
if f.prev_tok == ModelicaToken::LParen {
f.markers.push(Marker::Space);
}
f.handle_token(tok);
f.markers.push(Marker::Space);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/samples/code-input.mo
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ algorithm
(A,B,C):= foo.bar.baz
(a);
(D,,E) := foo.bar .baz(b);
(F, G,(H,
(, G,(H,
J)) := foo.bar.baz(c);

foo:={{bar[i] + j*
Expand Down
2 changes: 1 addition & 1 deletion tests/samples/code-output.mo
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ algorithm

(A, B, C) := foo.bar.baz(a);
(D, , E) := foo.bar.baz(b);
(F, G, (H, J)) := foo.bar.baz(c);
( , G, (H, J)) := foo.bar.baz(c);

foo := {
{
Expand Down

0 comments on commit 23f19da

Please sign in to comment.