Closed Qata closed 3 weeks ago
The grammar of the language already has some ambiguity problems, which you will run into if you try to use a parser generator for Juniper. Whitespace is actually significant in Juniper programs, specifically in sequence expressions where each expression in the sequence is separated by a newline. Allowing an infix operation to span multiple lines would only add to the ambiguity problem. With the current state of the parser, adding this sort of thing is not possible.
As a workaround, it is allowed to put the |>
on the same line as its left hand side, and have the right hand side span multiple lines. Better illustrated with an example:
value |>
myfun() |>
myfun2()
If we simply allowed expressions to span multiple lines, the ambiguity problems will look like this:
{
expr
(true, 1u32)
}
Could be parsed as either a sequence returning the result of a function call expr(true, 1u32)
or as a sequence returning a tuple.
I'm a fan of writing piped code like this:
But there's a current restriction in the parser that results in this being an error.