Skip to content

Commit

Permalink
[bugfix] Correct the XQuery Parser so that Named Function References …
Browse files Browse the repository at this point in the history
…can have Postfix Expressions
  • Loading branch information
adamretter committed Nov 3, 2023
1 parent ec356d0 commit 33b6c05
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exist-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@
<exclude>src/test/xquery/xqsuite/xqsuite-assertions-dynamic.xqm</exclude>
<exclude>src/test/xquery/xqsuite/xqsuite-assertions-inline.xqm</exclude>
<exclude>src/test/xquery/xqsuite/xqsuite-assertions.resources.xqm.ignore</exclude>
<exclude>src/test/xquery/xquery3/postfix-expr.xqm</exclude>

<!--
Derivative work licensed under dbXML 1.0 and LGPL 2.1
Expand Down Expand Up @@ -935,6 +936,7 @@ The original license statement is also included below.]]></preamble>
<include>src/test/xquery/xqsuite/xqsuite-assertions-dynamic.xqm</include>
<include>src/test/xquery/xqsuite/xqsuite-assertions-inline.xqm</include>
<include>src/test/xquery/xqsuite/xqsuite-assertions.resources.xqm.ignore</include>
<include>src/test/xquery/xquery3/postfix-expr.xqm</include>
</includes>

</licenseSet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@ throws PermissionDeniedException, EXistException, XPathException
{ path.add(step); }
|
step=functionReference [path]
step=postfixExpr [step]
{ path.add(step); }
|
step=inlineFunctionDecl [path]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public void dump(ExpressionDumper dumper) {
dumper.display(Integer.toString(arity));
}

@Override
public String toString() {
return qname.toString() + '#' + arity;
}

@Override
public Sequence eval(Sequence contextSequence, Item contextItem)
throws XPathException {
Expand Down
49 changes: 49 additions & 0 deletions exist-core/src/test/xquery/xquery3/postfix-expr.xqm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
(:
: Copyright (C) 2014, Evolved Binary Ltd
:
: This file was originally ported from FusionDB to eXist-db by
: Evolved Binary, for the benefit of the eXist-db Open Source community.
: Only the ported code as it appears in this file, at the time that
: it was contributed to eXist-db, was re-licensed under The GNU
: Lesser General Public License v2.1 only for use in eXist-db.
:
: This license grant applies only to a snapshot of the code as it
: appeared when ported, it does not offer or infer any rights to either
: updates of this source code or access to the original source code.
:
: The GNU Lesser General Public License v2.1 only license follows.
:
: ---------------------------------------------------------------------
:
: Copyright (C) 2014, Evolved Binary Ltd
:
: This library is free software; you can redistribute it and/or
: modify it under the terms of the GNU Lesser General Public
: License as published by the Free Software Foundation; version 2.1.
:
: This library is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
: Lesser General Public License for more details.
:
: You should have received a copy of the GNU Lesser General Public
: License along with this library; if not, write to the Free Software
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
:)
xquery version "3.1";

module namespace tpe = "http://exist-db.org/xquery/test/postfix-expr";

declare namespace test = "http://exist-db.org/xquery/xqsuite";

declare
%test:assertEquals("test123")
function tpe:named-function-ref-postfix() {
xs:string#1("test123")
};

declare
%test:assertEquals("test456")
function tpe:include-function-expr-postfix() {
function($x) { $x }("test456")
};

0 comments on commit 33b6c05

Please sign in to comment.