Skip to content

Commit d495781

Browse files
committed
[bugfix] Correct the XQuery Parser so that Named Function References can have Postfix Expressions
1 parent 7830629 commit d495781

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

exist-core/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@
724724
<exclude>src/test/java/org/exist/xquery/value/SubSequenceRangeTest.java</exclude>
725725
<exclude>src/test/java/org/exist/xquery/value/SubSequenceTest.java</exclude>
726726
<exclude>src/test/xquery/binary-value.xqm</exclude>
727+
<exclude>src/test/xquery/xquery3/postfix-expr.xqm</exclude>
727728

728729
<!--
729730
Derivative work licensed under dbXML 1.0 and LGPL 2.1
@@ -876,6 +877,7 @@ The original license statement is also included below.]]></preamble>
876877
<include>src/test/java/org/exist/xquery/value/SubSequenceRangeTest.java</include>
877878
<include>src/test/java/org/exist/xquery/value/SubSequenceTest.java</include>
878879
<include>src/test/xquery/binary-value.xqm</include>
880+
<include>src/test/xquery/xquery3/postfix-expr.xqm</include>
879881
</includes>
880882

881883
</licenseSet>

exist-core/src/main/antlr/org/exist/xquery/parser/XQueryTree.g

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,7 @@ throws PermissionDeniedException, EXistException, XPathException
22282228
{ path.add(step); }
22292229
|
22302230
step=functionReference [path]
2231+
step=postfixExpr [step]
22312232
{ path.add(step); }
22322233
|
22332234
step=inlineFunctionDecl [path]

exist-core/src/main/java/org/exist/xquery/NamedFunctionReference.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public void dump(ExpressionDumper dumper) {
102102
dumper.display(Integer.toString(arity));
103103
}
104104

105+
@Override
106+
public String toString() {
107+
return qname.toString() + '#' + arity;
108+
}
109+
105110
@Override
106111
public Sequence eval(Sequence contextSequence, Item contextItem)
107112
throws XPathException {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
(:
2+
: Copyright (C) 2014, Evolved Binary Ltd
3+
:
4+
: This file was originally ported from FusionDB to eXist-db by
5+
: Evolved Binary, for the benefit of the eXist-db Open Source community.
6+
: Only the ported code as it appears in this file, at the time that
7+
: it was contributed to eXist-db, was re-licensed under The GNU
8+
: Lesser General Public License v2.1 only for use in eXist-db.
9+
:
10+
: This license grant applies only to a snapshot of the code as it
11+
: appeared when ported, it does not offer or infer any rights to either
12+
: updates of this source code or access to the original source code.
13+
:
14+
: The GNU Lesser General Public License v2.1 only license follows.
15+
:
16+
: ---------------------------------------------------------------------
17+
:
18+
: Copyright (C) 2014, Evolved Binary Ltd
19+
:
20+
: This library is free software; you can redistribute it and/or
21+
: modify it under the terms of the GNU Lesser General Public
22+
: License as published by the Free Software Foundation; version 2.1.
23+
:
24+
: This library is distributed in the hope that it will be useful,
25+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27+
: Lesser General Public License for more details.
28+
:
29+
: You should have received a copy of the GNU Lesser General Public
30+
: License along with this library; if not, write to the Free Software
31+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32+
:)
33+
xquery version "3.1";
34+
35+
module namespace tpe = "http://exist-db.org/xquery/test/postfix-expr";
36+
37+
declare namespace test = "http://exist-db.org/xquery/xqsuite";
38+
39+
declare
40+
%test:assertEquals("test123")
41+
function tpe:named-function-ref-postfix() {
42+
xs:string#1("test123")
43+
};
44+
45+
declare
46+
%test:assertEquals("test456")
47+
function tpe:include-function-expr-postfix() {
48+
function($x) { $x }("test456")
49+
};

0 commit comments

Comments
 (0)