Open
Description
When many function calls are part of the same expression they can be broken incorrectly, e.g., the following input
f(1) + f(1) +
f(1) + f(1) +
f(1) + f(1) +
f(1) + f(1) +
f(1) + f(1) +
f(1) + f(1) +
f(1) + f(1) +
f(1) + f(1);
is formatted with a line break inside the function call
f(1) + f(1) + f(1) + f(1) + f(1) + f(1) + f(1) + f(1) + f(1) + f(1) + f(1) + f(1) + f(
1) + f(1) + f(1) + f(1);
Looking at the produced CST this seems to be due to function calls in expressions not parsing correctly, e.g., with
f(1) + f(1);
I get
$ tree-sitter parse foo.zeek
(source_file [0, 0] - [1, 0]
(stmt [0, 0] - [0, 12]
(expr [0, 0] - [0, 11]
(expr [0, 0] - [0, 8]
(expr [0, 0] - [0, 4]
(expr [0, 0] - [0, 1]
(id [0, 0] - [0, 1]))
(expr_list [0, 2] - [0, 3]
(expr [0, 2] - [0, 3]
(constant [0, 2] - [0, 3]
(integer [0, 2] - [0, 3])))))
(expr [0, 7] - [0, 8]
(id [0, 7] - [0, 8])))
(expr_list [0, 9] - [0, 10]
(expr [0, 9] - [0, 10]
(constant [0, 9] - [0, 10]
(integer [0, 9] - [0, 10]))))))
(nl [0, 12] - [1, 0]))
If this had correct precedence I would expect two nodes (expr (expr (id)) (expr_list ...)
next to each other; instead the function name of the second f
gets incorrectly grouped next to the arguments of the first call.
The current "lightweight" impl also makes it impossible to match multiple function calls in the same expression, e.g., over in https://github.com/bbannier/zeek-language-server I cannot match all calls to compute parameter inlay hints, e.g.,
