qt4cg / qtspecs

QT4 specifications
https://qt4cg.org/
Other
28 stars 15 forks source link

Grammar discrepancy on fn:pin() examples #1107

Closed johnlumley closed 5 months ago

johnlumley commented 5 months ago

I'm probably getting the wrong end of the stick, but I can't see how the example for fn:pin():

pin(["a","b","c"])?1 => label()?parent => array:foot()

meets the current EBNF. (I know bits of this area may be in flux, so this may be just for the record .)

pin(["a","b","c"])?1 => label()

meets the production for ArrowExpr, and the RHS of an ArrowExpr is, in this case, an ArrowStaticFunction ArgumentList pair, which doesn't encompass the subsequent lookup.

But for LookupExpr to include the ?parent requires PostfixExpr as its first term, and PostfixExpr can only include ArrowExpr via PrimaryExpr/ParenthesizedExpr, i.e. with brackets.

ChristianGruen commented 5 months ago

True. The given query could be rewritten as:

pin([ "a", "b", "c"] )?1
! label(.)?parent
! array:foot(.)

It’s a common problem with the arrow operator that it can only be used for simple function calls (it’s one reason why I would like to have a value map operator, as motivated in #755).

ChristianGruen commented 5 months ago

I’ve added a fix in the PR #1078.