diff --git a/libkc3/buf_parse.c b/libkc3/buf_parse.c
index f8f235d..4f7e07c 100644
--- a/libkc3/buf_parse.c
+++ b/libkc3/buf_parse.c
@@ -923,6 +923,7 @@ sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, sw min_precedence)
bool b;
character c;
s_tag *left;
+ bool merge_left = true;
s_ident next_op;
sw next_op_precedence;
s_ident op;
@@ -1001,6 +1002,7 @@ sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, sw min_precedence)
result += r;
tag_init_call(right);
right->data.call = tmp2;
+ merge_left = true;
if ((r = buf_ignore_spaces_but_newline(buf)) < 0)
goto ok;
result += r;
@@ -1014,12 +1016,20 @@ sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, sw min_precedence)
! operator_precedence(&next_op, &next_op_precedence)))
goto ok;
}
- call_init_op(&tmp3);
- tmp3.ident = op;
- tmp3.arguments->tag = *left;
- list_next(tmp3.arguments)->tag = *right;
- tag_init_call(left);
- left->data.call = tmp3;
+ if (merge_left) {
+ merge_left = false;
+ call_init_op(&tmp3);
+ tmp3.ident = op;
+ tmp3.arguments->tag = *left;
+ list_next(tmp3.arguments)->tag = *right;
+ tag_init_call(left);
+ left->data.call = tmp3;
+ }
+ r = buf_peek_ident(buf, &next_op);
+ if (r <= 0 ||
+ (! operator_resolve(&next_op, 2, &next_op) ||
+ ! operator_precedence(&next_op, &next_op_precedence)))
+ goto ok;
}
ok:
call_clean(dest);
diff --git a/test/inspect_test.c b/test/inspect_test.c
index eac3a31..2c18cde 100644
--- a/test/inspect_test.c
+++ b/test/inspect_test.c
@@ -180,8 +180,8 @@
tag_init_1(&tag_test, (test)); \
TEST_EQ(inspect_tag(&tag_test, &str_result), &str_result); \
tag_clean(&tag_test); \
- TEST_EQ(str_result.size, strlen(expected)); \
TEST_STRNCMP(str_result.ptr.p, (expected), str_result.size); \
+ TEST_EQ(str_result.size, strlen(expected)); \
str_clean(&str_result); \
test_context(NULL); \
} while (0)
@@ -519,10 +519,10 @@ TEST_CASE(inspect_tag)
"1 + 20");
INSPECT_TEST_TAG("1 + 20 / 3",
"1 + 20 / 3");
- INSPECT_TEST_TAG("1 + 20 / 3 + 4",
- "1 + 20 / 3 + 4");
- INSPECT_TEST_TAG("1 + 20 / 3 + 4 - 5",
- "1 + 20 / 3 + 4 - 5");
+ INSPECT_TEST_TAG("1 + 20 / 3 * 4",
+ "1 + 20 / 3 * 4");
+ INSPECT_TEST_TAG("1 + 20 / 3 * 4 - 5",
+ "1 + 20 / 3 * 4 - 5");
INSPECT_TEST_TAG("a = ? <- 1 ; 2",
"a = ? <- 1 ; 2");
}