Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
333 commits
Select commit Hold shift + click to select a range
6e51262
adds license comment at the begin oft he files
hartig Mar 4, 2024
ad867da
Merge branch 'UnfoldAndFoldWithCompositeValues' of github.com:hartig/…
hartig Mar 4, 2024
5329001
permanent URI for the CDT datatypes and functions
hartig May 18, 2024
2b29e61
removes the InputStream versions of parseListLiteral and parseMapLiteral
hartig May 25, 2024
9476dec
adds the possibility to create CDT literals that are known to be ill-…
hartig May 26, 2024
05efa88
changes the parsing of CDT literals such that the scope of bnode iden…
hartig May 26, 2024
c49821c
Merge branch 'apache:main' into master
hartig May 26, 2024
9cc5647
initial addition of Unfold to the ARQ grammar, including all code cha…
hartig Jul 3, 2022
920ed9f
extends ElementTransform to cover ElementUnfold
hartig Jul 3, 2022
4e12e3d
extends ElementVisitor to cover ElementUnfold
hartig Jul 3, 2022
08e98d8
initial functional version of QueryIterUnfold
hartig Jul 4, 2022
85a6d6e
enable visiting of ElementUnfold
hartig Jul 6, 2022
a705c97
fully working version of QueryIterUnfold
hartig Aug 10, 2022
78aa795
bug fix: if evaluating the expression of an UNFOLD operator fails, cr…
hartig Aug 10, 2022
73ac3a9
bug fix: if evaluating the expression of an UNFOLD operator does not …
hartig Aug 10, 2022
ff0fd1f
adds support for UNFOLDing of untyped maps
hartig Aug 10, 2022
736b435
adds FOLD
hartig Aug 11, 2022
47d0b94
extends the implementation of FOLD to actually support the type argum…
hartig Aug 11, 2022
54a8f2a
adds support for collection-related functions
hartig Aug 11, 2022
48ba8a3
adds POC of a 'concat' function for lists
hartig Aug 17, 2022
bca1338
creates Node_LiteralWithList and Node_LiteralWithMap, so far only as …
hartig Aug 19, 2022
e469c7c
adds an actual parser for the lexical form of cdt:List and cdt:Map li…
hartig Nov 10, 2022
4613165
updating the URI prefix 'cdt:'
hartig Nov 10, 2022
4b887b9
adds the constructor function cdt:List
hartig Nov 10, 2022
d5d1f5d
adds comparison of cdt:List literals and of cdt:Map literals as anoth…
hartig Nov 10, 2022
5c55d9e
correct recursive implementation of 'equals' in 'CDTValue'
hartig Nov 10, 2022
61d5108
adds the cdt:contains function
hartig Nov 14, 2022
ec226f9
remove debug printing
hartig Nov 14, 2022
e2afad3
adds CDTLiteralParserBase to create special Node objects for cdt:List…
hartig Nov 14, 2022
bd68c99
bug fix: avoid NPE
hartig Nov 14, 2022
8522b3d
bug fix in the CDT grammar (it was possible to have lists that begin …
hartig Nov 19, 2022
1e3d40c
changes CDTValue such that it can be only null or an RDF term
hartig Nov 20, 2022
37d2ce0
adds cdt:containsTerm function
hartig Nov 29, 2022
6af6013
adds cdt:get function
hartig Nov 29, 2022
cb93163
adds cdt:head function
hartig Nov 30, 2022
2032c75
adds base class FunctionBase1List
hartig Nov 30, 2022
98e0a03
adds cdt:tail function
hartig Nov 30, 2022
306294e
changes arguments of '_exec' in FunctionBase1List
hartig Nov 30, 2022
7e5f3eb
adds cdt:reverse function
hartig Nov 30, 2022
e83f127
adds cdt:subseq function
hartig Nov 30, 2022
f79e9b4
bugfix in 'isEqual' of CompositeDatatypeList (needs to throw ExprEval…
hartig Nov 30, 2022
28c72a3
fix: comparing two cdt:List literals using the = operator may still r…
hartig Dec 1, 2022
61a1f4c
changes the implementation of the cdt:List constructor to be a functi…
hartig Dec 13, 2022
c658014
makes cdt:concat an n-ary function
hartig Jan 4, 2023
ac457ee
support for the two-variables version of UNFOLD for cdt:List literals
hartig Mar 18, 2023
f022f13
support for the one-variable version of UNFOLD for cdt:Map literals
hartig Mar 18, 2023
2bde792
support for comparison of cdt:List literals (i.e., < and >)
hartig May 11, 2023
47c00cb
bug fix: visit(OpUnfold) must pop the current expression from the stack
hartig May 19, 2023
6716bf7
changes implementation of 'list-equal' and 'list-less-than' such that…
hartig Jun 8, 2023
aefcb34
FOLD must not accept blank nodes as keys for maps
hartig Jun 15, 2023
0e9885c
adds the map version of cdt:get, in this context also changes 'equals…
hartig Aug 10, 2023
eeff445
adds support for cdt:containsKey
hartig Aug 10, 2023
23797e4
adds support for cdt:keys
hartig Aug 10, 2023
6058d9d
adds support for cdt:remove
hartig Aug 10, 2023
4ee22c4
bug fix: CDTValue needs to override toString() and hashCode() and can…
hartig Aug 11, 2023
ab6e489
adds CDTLiteralFunctionUtils
hartig Aug 11, 2023
af74bac
adds support for cdt:put
hartig Aug 11, 2023
e92b6a4
renames CollectionLiteralFunctions to CDTLiteralFunctions
hartig Aug 11, 2023
76fc2ba
renames 'org.apache.jena.sparql.function.library.collections' package…
hartig Aug 11, 2023
71c9da1
adds support for cdt:Map constructor
hartig Aug 11, 2023
c002994
big fix: CDTKey does not have a 'isNode()' function anymore
hartig Aug 21, 2023
ef65146
the datatypes for the CDT literals need to be registered
hartig Sep 14, 2023
de715eb
changes the implementation of LiteralLabelForCDTs to use the correspo…
hartig Sep 14, 2023
fd445d4
some clean up in CompositeDatatypeList and in CompositeDatatypeMap
hartig Sep 15, 2023
4f71f6f
fixes implementation of 'map-equal'
hartig Sep 18, 2023
51cdf5a
adds support for cdt:merge
hartig Sep 19, 2023
bcdc0c6
extends SPARQL parser to recognize ORDER BY for FOLD
hartig Oct 5, 2023
c9094b2
support for DISTINCT in FOLD
hartig Oct 5, 2023
46ef9ff
split AggFold into AggFoldList and AggFoldMap
hartig Oct 5, 2023
66891a8
bug fix: correct creation of empty lists and empty maps in FOLD
hartig Oct 5, 2023
943eb2e
support for ORDER BY in FOLD
hartig Oct 12, 2023
16afd0c
changes the tests of FOLD(DISTINCT ...) to capture the decision that …
hartig Oct 13, 2023
db2f7f9
support for ORDER BY in FOLD for maps
hartig Oct 14, 2023
510a252
support for comparison (<, <=, >, >=) of cdt:Map literals
hartig Oct 17, 2023
1d57625
bug fix in comparison of cdt:List literals
hartig Oct 17, 2023
c7136d9
bug fix in FOLD with both DISTINCT, as revealed by the 'fold-list-dis…
hartig Oct 16, 2023
1e0df20
support for ORDER BY for cdt:List literals
hartig Oct 18, 2023
fe2d313
support for ORDER BY for cdt:Map literals
hartig Oct 18, 2023
55d1132
changed the implementation of ORDER BY for CDT literals such that the…
hartig Oct 20, 2023
04f6e1a
implements the decision that 'null=null' is true rather than an error
hartig Nov 27, 2023
c3d0d60
implements the decision that null is not equal to any RDF term
hartig Dec 19, 2023
c9e0d7f
bug fix: map keys cannot be blank nodes
hartig Jan 8, 2024
b601bcc
changes CDTLiteralParserBase to extend LangParserBase instead of Turt…
hartig Jan 12, 2024
0f051bd
moves the CDT literals grammar to the subdirectory './jena-arq/Gramma…
hartig Jan 12, 2024
e904dc9
adds license comment at the begin oft he files
hartig Mar 4, 2024
c75f0cc
extends LiteralLabelForCDTs with a constructor to pass both the lexic…
hartig Jan 13, 2024
7445c4f
permanent URI for the CDT datatypes and functions
hartig May 18, 2024
18e781c
removes the InputStream versions of parseListLiteral and parseMapLiteral
hartig May 25, 2024
c5ab8df
adds the possibility to create CDT literals that are known to be ill-…
hartig May 26, 2024
00ae9e5
changes the parsing of CDT literals such that the scope of bnode iden…
hartig May 26, 2024
a17d584
Merge branch 'UnfoldAndFoldWithCompositeValues' of github.com:hartig/…
hartig May 27, 2024
3ead259
adaption to the reorganized NodeValue class after rebasing
hartig May 27, 2024
02cddf4
a few more fixes of issues that resulted from rebasing
hartig May 27, 2024
26e1d5e
after rebasing, changes the CDT implementation to adapt to the fact t…
hartig May 27, 2024
a072d92
further adaption to the reorganized NodeValue class after rebasing (O…
hartig May 27, 2024
b6dfaf8
a bit more cleaning up after rebasing
hartig May 27, 2024
eab675f
corrects the handling of = and < for CDT literals after rebasing, als…
hartig May 28, 2024
6de9f47
adds license header to CDTAwareParserProfile
hartig Jun 4, 2024
51a6e15
Merge branch 'apache:main' into master
hartig Jun 4, 2024
6b63dd7
initial addition of Unfold to the ARQ grammar, including all code cha…
hartig Jul 3, 2022
b240b96
extends ElementTransform to cover ElementUnfold
hartig Jul 3, 2022
a22eff8
extends ElementVisitor to cover ElementUnfold
hartig Jul 3, 2022
c9f5e86
initial functional version of QueryIterUnfold
hartig Jul 4, 2022
2f8413b
enable visiting of ElementUnfold
hartig Jul 6, 2022
5ca2a51
fully working version of QueryIterUnfold
hartig Aug 10, 2022
58b72a5
bug fix: if evaluating the expression of an UNFOLD operator fails, cr…
hartig Aug 10, 2022
fa5e530
bug fix: if evaluating the expression of an UNFOLD operator does not …
hartig Aug 10, 2022
0c60a2a
adds support for UNFOLDing of untyped maps
hartig Aug 10, 2022
995756c
adds FOLD
hartig Aug 11, 2022
2121eb8
extends the implementation of FOLD to actually support the type argum…
hartig Aug 11, 2022
1c94b5c
adds support for collection-related functions
hartig Aug 11, 2022
2944432
adds POC of a 'concat' function for lists
hartig Aug 17, 2022
22190ec
creates Node_LiteralWithList and Node_LiteralWithMap, so far only as …
hartig Aug 19, 2022
10c07f2
adds an actual parser for the lexical form of cdt:List and cdt:Map li…
hartig Nov 10, 2022
6d13fb5
updating the URI prefix 'cdt:'
hartig Nov 10, 2022
5c96408
adds the constructor function cdt:List
hartig Nov 10, 2022
142c78e
adds comparison of cdt:List literals and of cdt:Map literals as anoth…
hartig Nov 10, 2022
b74f462
correct recursive implementation of 'equals' in 'CDTValue'
hartig Nov 10, 2022
b76ffb5
adds the cdt:contains function
hartig Nov 14, 2022
9ad3617
remove debug printing
hartig Nov 14, 2022
5ba0f2a
adds CDTLiteralParserBase to create special Node objects for cdt:List…
hartig Nov 14, 2022
18d922c
bug fix: avoid NPE
hartig Nov 14, 2022
b8677d4
bug fix in the CDT grammar (it was possible to have lists that begin …
hartig Nov 19, 2022
24a5822
changes CDTValue such that it can be only null or an RDF term
hartig Nov 20, 2022
c1f25ff
adds cdt:containsTerm function
hartig Nov 29, 2022
11e84c5
adds cdt:get function
hartig Nov 29, 2022
51e6133
adds cdt:head function
hartig Nov 30, 2022
b0d097d
adds base class FunctionBase1List
hartig Nov 30, 2022
3462466
adds cdt:tail function
hartig Nov 30, 2022
0460224
changes arguments of '_exec' in FunctionBase1List
hartig Nov 30, 2022
e462cb7
adds cdt:reverse function
hartig Nov 30, 2022
b47d601
adds cdt:subseq function
hartig Nov 30, 2022
8d1650a
bugfix in 'isEqual' of CompositeDatatypeList (needs to throw ExprEval…
hartig Nov 30, 2022
26a0bb8
fix: comparing two cdt:List literals using the = operator may still r…
hartig Dec 1, 2022
7778a68
changes the implementation of the cdt:List constructor to be a functi…
hartig Dec 13, 2022
0f2a7e2
makes cdt:concat an n-ary function
hartig Jan 4, 2023
1a40112
support for the two-variables version of UNFOLD for cdt:List literals
hartig Mar 18, 2023
f329a0d
support for the one-variable version of UNFOLD for cdt:Map literals
hartig Mar 18, 2023
04711bb
support for comparison of cdt:List literals (i.e., < and >)
hartig May 11, 2023
5de4880
bug fix: visit(OpUnfold) must pop the current expression from the stack
hartig May 19, 2023
7b7a010
changes implementation of 'list-equal' and 'list-less-than' such that…
hartig Jun 8, 2023
c67e583
FOLD must not accept blank nodes as keys for maps
hartig Jun 15, 2023
b600985
adds the map version of cdt:get, in this context also changes 'equals…
hartig Aug 10, 2023
43a4c25
adds support for cdt:containsKey
hartig Aug 10, 2023
ac52919
adds support for cdt:keys
hartig Aug 10, 2023
eb9528d
adds support for cdt:remove
hartig Aug 10, 2023
bbdd153
bug fix: CDTValue needs to override toString() and hashCode() and can…
hartig Aug 11, 2023
4ea569f
adds CDTLiteralFunctionUtils
hartig Aug 11, 2023
1aa8fd5
adds support for cdt:put
hartig Aug 11, 2023
95dcb74
renames CollectionLiteralFunctions to CDTLiteralFunctions
hartig Aug 11, 2023
ed16c84
renames 'org.apache.jena.sparql.function.library.collections' package…
hartig Aug 11, 2023
c7a4054
adds support for cdt:Map constructor
hartig Aug 11, 2023
6e864aa
big fix: CDTKey does not have a 'isNode()' function anymore
hartig Aug 21, 2023
72406bb
the datatypes for the CDT literals need to be registered
hartig Sep 14, 2023
d9a4a27
changes the implementation of LiteralLabelForCDTs to use the correspo…
hartig Sep 14, 2023
9c80646
some clean up in CompositeDatatypeList and in CompositeDatatypeMap
hartig Sep 15, 2023
19f2f03
fixes implementation of 'map-equal'
hartig Sep 18, 2023
bc17340
adds support for cdt:merge
hartig Sep 19, 2023
a77a1c1
extends SPARQL parser to recognize ORDER BY for FOLD
hartig Oct 5, 2023
de19a46
support for DISTINCT in FOLD
hartig Oct 5, 2023
396ea86
split AggFold into AggFoldList and AggFoldMap
hartig Oct 5, 2023
b4c87d2
bug fix: correct creation of empty lists and empty maps in FOLD
hartig Oct 5, 2023
e41b527
support for ORDER BY in FOLD
hartig Oct 12, 2023
3454fa2
changes the tests of FOLD(DISTINCT ...) to capture the decision that …
hartig Oct 13, 2023
69be5f9
support for ORDER BY in FOLD for maps
hartig Oct 14, 2023
6e3b2a6
support for comparison (<, <=, >, >=) of cdt:Map literals
hartig Oct 17, 2023
715db70
bug fix in comparison of cdt:List literals
hartig Oct 17, 2023
b48d317
bug fix in FOLD with both DISTINCT, as revealed by the 'fold-list-dis…
hartig Oct 16, 2023
60ca2b0
support for ORDER BY for cdt:List literals
hartig Oct 18, 2023
5867176
support for ORDER BY for cdt:Map literals
hartig Oct 18, 2023
e7750de
changed the implementation of ORDER BY for CDT literals such that the…
hartig Oct 20, 2023
66ef7e0
implements the decision that 'null=null' is true rather than an error
hartig Nov 27, 2023
6cb1870
implements the decision that null is not equal to any RDF term
hartig Dec 19, 2023
4a1ab4a
bug fix: map keys cannot be blank nodes
hartig Jan 8, 2024
c1c8add
changes CDTLiteralParserBase to extend LangParserBase instead of Turt…
hartig Jan 12, 2024
c45a004
moves the CDT literals grammar to the subdirectory './jena-arq/Gramma…
hartig Jan 12, 2024
5aabb49
adds license comment at the begin oft he files
hartig Mar 4, 2024
b5f98d5
extends LiteralLabelForCDTs with a constructor to pass both the lexic…
hartig Jan 13, 2024
26280be
permanent URI for the CDT datatypes and functions
hartig May 18, 2024
49bb7e7
removes the InputStream versions of parseListLiteral and parseMapLiteral
hartig May 25, 2024
ced5f7c
adds the possibility to create CDT literals that are known to be ill-…
hartig May 26, 2024
eecfc04
changes the parsing of CDT literals such that the scope of bnode iden…
hartig May 26, 2024
164fea5
initial addition of Unfold to the ARQ grammar, including all code cha…
hartig Jul 3, 2022
9e2cb97
initial functional version of QueryIterUnfold
hartig Jul 4, 2022
91f3e2e
fully working version of QueryIterUnfold
hartig Aug 10, 2022
67f49c4
adds support for UNFOLDing of untyped maps
hartig Aug 10, 2022
2daa403
adds FOLD
hartig Aug 11, 2022
94bd4cf
extends the implementation of FOLD to actually support the type argum…
hartig Aug 11, 2022
71aac09
adds support for collection-related functions
hartig Aug 11, 2022
dde32ba
adds POC of a 'concat' function for lists
hartig Aug 17, 2022
be87791
creates Node_LiteralWithList and Node_LiteralWithMap, so far only as …
hartig Aug 19, 2022
108b236
adds an actual parser for the lexical form of cdt:List and cdt:Map li…
hartig Nov 10, 2022
c8cccb0
updating the URI prefix 'cdt:'
hartig Nov 10, 2022
87d7c92
adds the constructor function cdt:List
hartig Nov 10, 2022
5a4259f
adds comparison of cdt:List literals and of cdt:Map literals as anoth…
hartig Nov 10, 2022
da9f3fb
correct recursive implementation of 'equals' in 'CDTValue'
hartig Nov 10, 2022
d3deb8e
adds the cdt:contains function
hartig Nov 14, 2022
8508e53
adds CDTLiteralParserBase to create special Node objects for cdt:List…
hartig Nov 14, 2022
6d28de9
bug fix in the CDT grammar (it was possible to have lists that begin …
hartig Nov 19, 2022
cb2d10a
changes CDTValue such that it can be only null or an RDF term
hartig Nov 20, 2022
42864e0
adds cdt:containsTerm function
hartig Nov 29, 2022
b5f9329
adds cdt:get function
hartig Nov 29, 2022
af5719f
adds cdt:head function
hartig Nov 30, 2022
845683a
adds base class FunctionBase1List
hartig Nov 30, 2022
f6adcc1
adds cdt:tail function
hartig Nov 30, 2022
afb1020
changes arguments of '_exec' in FunctionBase1List
hartig Nov 30, 2022
d311448
adds cdt:reverse function
hartig Nov 30, 2022
a475abb
adds cdt:subseq function
hartig Nov 30, 2022
678e164
bugfix in 'isEqual' of CompositeDatatypeList (needs to throw ExprEval…
hartig Nov 30, 2022
1079577
fix: comparing two cdt:List literals using the = operator may still r…
hartig Dec 1, 2022
ea8f4b4
changes the implementation of the cdt:List constructor to be a functi…
hartig Dec 13, 2022
4aa9bc4
makes cdt:concat an n-ary function
hartig Jan 4, 2023
05b39c4
support for comparison of cdt:List literals (i.e., < and >)
hartig May 11, 2023
ab7db7c
changes implementation of 'list-equal' and 'list-less-than' such that…
hartig Jun 8, 2023
9ef3b7f
FOLD must not accept blank nodes as keys for maps
hartig Jun 15, 2023
dcb2059
adds the map version of cdt:get, in this context also changes 'equals…
hartig Aug 10, 2023
8d41d66
adds support for cdt:containsKey
hartig Aug 10, 2023
829f3ea
adds support for cdt:keys
hartig Aug 10, 2023
8d200b4
adds support for cdt:remove
hartig Aug 10, 2023
93cf90e
adds CDTLiteralFunctionUtils
hartig Aug 11, 2023
f9cd4e9
adds support for cdt:put
hartig Aug 11, 2023
cf77517
renames CollectionLiteralFunctions to CDTLiteralFunctions
hartig Aug 11, 2023
ad6dae5
renames 'org.apache.jena.sparql.function.library.collections' package…
hartig Aug 11, 2023
05db05e
changes the implementation of LiteralLabelForCDTs to use the correspo…
hartig Sep 14, 2023
46b7cc1
some clean up in CompositeDatatypeList and in CompositeDatatypeMap
hartig Sep 15, 2023
b7b2c7c
fixes implementation of 'map-equal'
hartig Sep 18, 2023
fa36dcf
extends SPARQL parser to recognize ORDER BY for FOLD
hartig Oct 5, 2023
2a8c646
support for DISTINCT in FOLD
hartig Oct 5, 2023
b05f9fd
split AggFold into AggFoldList and AggFoldMap
hartig Oct 5, 2023
f206200
support for comparison (<, <=, >, >=) of cdt:Map literals
hartig Oct 17, 2023
ebdb75e
support for ORDER BY for cdt:List literals
hartig Oct 18, 2023
1cb1165
support for ORDER BY for cdt:Map literals
hartig Oct 18, 2023
31435f3
changed the implementation of ORDER BY for CDT literals such that the…
hartig Oct 20, 2023
267bd15
implements the decision that 'null=null' is true rather than an error
hartig Nov 27, 2023
fcff8a8
implements the decision that null is not equal to any RDF term
hartig Dec 19, 2023
2ed03c9
bug fix: map keys cannot be blank nodes
hartig Jan 8, 2024
b88ae1d
changes CDTLiteralParserBase to extend LangParserBase instead of Turt…
hartig Jan 12, 2024
c3137db
moves the CDT literals grammar to the subdirectory './jena-arq/Gramma…
hartig Jan 12, 2024
203c3fa
adds the possibility to create CDT literals that are known to be ill-…
hartig May 26, 2024
77a4a77
adaption to the reorganized NodeValue class after rebasing
hartig May 27, 2024
aaff3ec
a few more fixes of issues that resulted from rebasing
hartig May 27, 2024
451a6d9
after rebasing, changes the CDT implementation to adapt to the fact t…
hartig May 27, 2024
280bb15
further adaption to the reorganized NodeValue class after rebasing (O…
hartig May 27, 2024
4dd0cc2
a bit more cleaning up after rebasing
hartig May 27, 2024
6ca6d45
corrects the handling of = and < for CDT literals after rebasing, als…
hartig May 28, 2024
b3bc222
adds license header to CDTAwareParserProfile
hartig Jun 4, 2024
872d834
Merge branch 'UnfoldAndFoldWithCompositeValues' of github.com:hartig/…
hartig Jun 4, 2024
1670e39
fixes issues that resulted from rebasing
hartig Jun 4, 2024
2549435
copies the test suite from the SPARQL-CDTs repo
hartig Jul 4, 2024
9cb08f1
CDT literals must be create using both their lex.form and value; othe…
hartig Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
370 changes: 370 additions & 0 deletions jena-arq/Grammar/CDTs/cdt_literals.jj
Original file line number Diff line number Diff line change
@@ -0,0 +1,370 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

options
{
// Use \ u escapes in streams AND use a reader for the query
// => get both raw and escaped unicode

JAVA_UNICODE_ESCAPE = true ;
UNICODE_INPUT = false ;

STATIC = false ;
// DEBUG_PARSER = true ;
// DEBUG_TOKEN_MANAGER = true ;
}

PARSER_BEGIN(CDTLiteralParser)
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.jena.cdt.parser;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.jena.cdt.*;
import org.apache.jena.graph.Node;

import static org.apache.jena.riot.lang.extra.LangParserLib.*;

public class CDTLiteralParser extends CDTLiteralParserBase
{
}
PARSER_END(CDTLiteralParser)

// --- Entry point for cdt:List literals

List<CDTValue> List() : { List<CDTValue> l = new ArrayList<CDTValue>(); }
{
<LBRACKET>

( NonEmptyListContent(l) )?

<RBRACKET>

{ return l; }
}

void NonEmptyListContent(List<CDTValue> l) : { }
{
ListElement(l)

( <COMMA> ListElement(l) )*
}

void ListElement(List<CDTValue> l) : { String iri; Node n; List<CDTValue> subList; Map<CDTKey,CDTValue> m; }
{
iri = IRI_REF() { n = createURI(iri, token.beginLine, token.beginColumn); l.add( CDTFactory.createValue(n) ); }
|
n = BlankNode() { l.add( CDTFactory.createValue(n) ); }
|
n = RDFLiteral() { l.add( CDTFactory.createValue(n) ); }
|
n = NumericLiteral() { l.add( CDTFactory.createValue(n) ); }
|
n = BooleanLiteral() { l.add( CDTFactory.createValue(n) ); }
|
<NULL> { l.add( CDTFactory.getNullValue() ); }
|
subList = List() { l.add( CDTFactory.createValue(subList) ); }
|
m = Map() { l.add( CDTFactory.createValue(m) ); }
}

// --- Entry point for cdt:Map literals

Map<CDTKey,CDTValue> Map() : { Map<CDTKey,CDTValue> m = new HashMap<CDTKey,CDTValue>(); }
{
<LBRACE>

( NonEmptyMapContent(m) )?

<RBRACE>

{ return m; }
}

void NonEmptyMapContent(Map<CDTKey,CDTValue> m) : { }
{
MapEntry(m)

( <COMMA> MapEntry(m) )*
}

void MapEntry(Map<CDTKey,CDTValue> m) : { CDTKey key; CDTValue value; }
{
key = MapKey()

<COLON>

value = MapValue()

{
final CDTValue oldValue = m.put(key, value);
if ( oldValue != null ) throw new ParseException("map with non-unique key (" + key.toString() + ")");
}
}

CDTKey MapKey() : { String iri; Node n; }
{
iri = IRI_REF() { n = createURI(iri, token.beginLine, token.beginColumn); return CDTFactory.createKey(n); }
|
n = RDFLiteral() { return CDTFactory.createKey(n); }
|
n = NumericLiteral() { return CDTFactory.createKey(n); }
|
n = BooleanLiteral() { return CDTFactory.createKey(n); }
}

CDTValue MapValue() : { String iri; Node n; List<CDTValue> subList; Map<CDTKey,CDTValue> m; }
{
iri = IRI_REF() { n = createURI(iri, token.beginLine, token.beginColumn); return CDTFactory.createValue(n); }
|
n = BlankNode() { return CDTFactory.createValue(n); }
|
n = RDFLiteral() { return CDTFactory.createValue(n); }
|
n = NumericLiteral() { return CDTFactory.createValue(n); }
|
n = BooleanLiteral() { return CDTFactory.createValue(n); }
|
<NULL> { return CDTFactory.getNullValue(); }
|
subList = List() { return CDTFactory.createValue(subList); }
|
m = Map() { return CDTFactory.createValue(m); }
}


// ---- Basic terms

String IRI_REF() : { Token t ; }
{
t = <IRIref>
{ return resolveQuotedIRI(t.image, t.beginLine, t.beginColumn) ; }
}

Node BlankNode() : { Token t = null ; }
{
t = <BLANK_NODE_LABEL>

{
return createBNode(t.image, t.beginLine, t.beginColumn);
}
}

Node NumericLiteral() : { Token t ; }
{
t = <INTEGER> { return createLiteralInteger(t.image, t.beginLine, t.beginColumn); }
| t = <DECIMAL> { return createLiteralDecimal(t.image, t.beginLine, t.beginColumn); }
| t = <DOUBLE> { return createLiteralDouble(t.image, t.beginLine, t.beginColumn); }
}

Node BooleanLiteral() : {}
{
<TRUE> { return XSD_TRUE; }
|
<FALSE> { return XSD_FALSE; }
}

Node RDFLiteral() : { String lex = null ; }
{
lex = String()
// Optional lang tag and datatype.
{ String lang = null ; String dt = null ; }
(
lang = Langtag()
|
( <DATATYPE> dt = IRI_REF() ) // divergence from the Turtle parser here; instead of IRIref(), we only permit IRI_REF()
)?

{
return createLiteral(lex, lang, dt, token.beginLine, token.beginColumn);
}
}

String Langtag() : { Token t ; }
{
t = <LANGTAG> // divergence from the Turtle parser here, which also permits AnyDirective() at this point
{ String lang = stripChars(t.image, 1) ; return lang ; }
}

String String() : { Token t ; String lex ; }
{
( t = <STRING_LITERAL1> { lex = stripQuotes(t.image) ; }
| t = <STRING_LITERAL2> { lex = stripQuotes(t.image) ; }
| t = <STRING_LITERAL_LONG1> { lex = stripQuotes3(t.image) ; }
| t = <STRING_LITERAL_LONG2> { lex = stripQuotes3(t.image) ; }
)
{ lex = unescapeStr(lex, t.beginLine, t.beginColumn) ;
return lex ;
}
}


// ------------------------------------------
// Tokens

// Comments and whitespace

SKIP : { " " | "\t" | "\n" | "\r" | "\f" }

TOKEN: { <#WS: " " | "\t" | "\n" | "\r" | "\f"> }


// -------------------------------------------------
// Keywords

TOKEN [IGNORE_CASE] :
{
< TRUE: "true" >
| < FALSE: "false" >

// -------------------------------------------------

| < INTEGER: (["-","+"])? <DIGITS> >
|
< DECIMAL: (["-","+"])?
((<DIGITS>)+ "." (<DIGITS>)* | "." (<DIGITS>)+)
>
// Required exponent.
| < DOUBLE:
(["+","-"])?
(
(["0"-"9"])+ "." (["0"-"9"])* <EXPONENT>
| "." (["0"-"9"])+ (<EXPONENT>)
| (["0"-"9"])+ <EXPONENT>
)
>
| < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
| < #QUOTE_3D: "\"\"\"">
| < #QUOTE_3S: "'''">
// "u" done by javacc input stream.
// "U" escapes not supported yet for Java strings
| <ECHAR: "\\" ("t"|"b"|"n"|"r"|"f"|"\\"|"\""|"'")>

| < STRING_LITERAL1:
// Single quoted string
"'" ( (~["'","\\","\n","\r"]) | <ECHAR> )* "'" >

| < STRING_LITERAL2:
// Double quoted string
"\"" ( (~["\"","\\","\n","\r"]) | <ECHAR> )* "\"" >

| < STRING_LITERAL_LONG1:
<QUOTE_3S>
( ~["'","\\"] | <ECHAR> | ("'" ~["'"]) | ("''" ~["'"]))*
<QUOTE_3S> >

| < STRING_LITERAL_LONG2:
<QUOTE_3D>
( ~["\"","\\"] | <ECHAR> | ("\"" ~["\""]) | ("\"\"" ~["\""]))*
<QUOTE_3D> >
| < DIGITS: (["0"-"9"])+>
// | <HEX: ["0"-"9"] | ["A"-"F"] | ["a"-"f"]>
}

TOKEN:
{
// Includes # for relative URIs
<IRIref: "<" (~[ ">","<", "\"", "{", "}", "^", "\\", "|", "`",
"\u0000"-"\u0020"])* ">" >
| <BLANK_NODE_LABEL: "_:" <PN_LOCAL> >
| <LANGTAG: <AT> (<A2Z>)+("-" (<A2ZN>)+)* >
| <#A2Z: ["a"-"z","A"-"Z"]>
| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
}


TOKEN :
{
< NULL: "null" >

| < LBRACE: "{" >
| < RBRACE: "}" >

| < LBRACKET: "[" >
| < RBRACKET: "]" >

| < COMMA: "," >
| < COLON: ":" >
}

// Operator

TOKEN :
{
< DATATYPE: "^^">
| < AT: "@">
}

TOKEN:
{
<#PN_CHARS_BASE:
["A"-"Z"] | ["a"-"z"] |
["\u00C0"-"\u00D6"] | ["\u00D8"-"\u00F6"] | ["\u00F8"-"\u02FF"] |
["\u0370"-"\u037D"] | ["\u037F"-"\u1FFF"] |
["\u200C"-"\u200D"] | ["\u2070"-"\u218F"] | ["\u2C00"-"\u2FEF"] |
["\u3001"-"\uD7FF"] | ["\uF900"-"\uFFFD"]
>
// [#x10000-#xEFFFF]
|
<#PN_CHARS_U: <PN_CHARS_BASE> | "_" >
|
// No DOT
<#PN_CHARS: (<PN_CHARS_U> | "-" | ["0"-"9"] | "\u00B7" |
["\u0300"-"\u036F"] | ["\u203F"-"\u2040"] ) >
|
// With a leading "_", no dot at end of local name.
<#PN_LOCAL: (<PN_CHARS_U> | ["0"-"9"]) ((<PN_CHARS>|".")* <PN_CHARS>)? >
}

// Catch-all tokens. Must be last.
// Any non-whitespace. Causes a parser exception, rather than a
// token manager error (with hidden line numbers).
// Only bad IRIs (e.g. spaces) now give unhelpful parse errors.
TOKEN:
{
<#UNKNOWN: (~[" ","\t","\n","\r","\f" ])+ >
}

/*
# Local Variables:
# tab-width: 4
# indent-tabs-mode: nil
# comment-default-style: "//"
# End:
*/
Loading