2727from rdflib .compat import decodeUnicodeEscape
2828
2929from . import operators as op
30- from .parserutils import Comp , Param , ParamList
30+ from .parserutils import Comp , Param
3131
3232# from pyparsing import Keyword as CaseSensitiveKeyword
3333
@@ -427,9 +427,9 @@ def expandCollection(terms):
427427)
428428
429429# [45] GraphOrDefault ::= 'DEFAULT' | 'GRAPH'? iri
430- GraphOrDefault = ParamList ( "graph" , Keyword ("DEFAULT" )) | Optional (
430+ GraphOrDefault = Group ( Param ( "graph" , Keyword ("DEFAULT" ) )) | Optional (
431431 Keyword ("GRAPH" )
432- ) + ParamList ( "graph" , iri )
432+ ) + Group ( Param ( "graph" , iri ) )
433433
434434# [65] DataBlockValue ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | 'UNDEF'
435435DataBlockValue = iri | RDFLiteral | NumericLiteral | BooleanLiteral | Keyword ("UNDEF" )
@@ -466,11 +466,11 @@ def expandCollection(terms):
466466# [95] PathNegatedPropertySet ::= PathOneInPropertySet | '(' ( PathOneInPropertySet ( '|' PathOneInPropertySet )* )? ')'
467467PathNegatedPropertySet = Comp (
468468 "PathNegatedPropertySet" ,
469- ParamList ( "part" , PathOneInPropertySet )
469+ Group ( Param ( "part" , PathOneInPropertySet ) )
470470 | "("
471471 + Optional (
472- ParamList ( "part" , PathOneInPropertySet )
473- + ZeroOrMore ("|" + ParamList ( "part" , PathOneInPropertySet ))
472+ Group ( Param ( "part" , PathOneInPropertySet ) )
473+ + ZeroOrMore ("|" + Group ( Param ( "part" , PathOneInPropertySet ) ))
474474 )
475475 + ")" ,
476476)
@@ -498,15 +498,16 @@ def expandCollection(terms):
498498# [90] PathSequence ::= PathEltOrInverse ( '/' PathEltOrInverse )*
499499PathSequence = Comp (
500500 "PathSequence" ,
501- ParamList ( "part" , PathEltOrInverse )
502- + ZeroOrMore ("/" + ParamList ( "part" , PathEltOrInverse )),
501+ Group ( Param ( "part" , PathEltOrInverse ) )
502+ + ZeroOrMore ("/" + Group ( Param ( "part" , PathEltOrInverse ) )),
503503)
504504
505505
506506# [89] PathAlternative ::= PathSequence ( '|' PathSequence )*
507507PathAlternative = Comp (
508508 "PathAlternative" ,
509- ParamList ("part" , PathSequence ) + ZeroOrMore ("|" + ParamList ("part" , PathSequence )),
509+ Group (Param ("part" , PathSequence ))
510+ + ZeroOrMore ("|" + Group (Param ("part" , PathSequence ))),
510511)
511512
512513# [88] Path ::= PathAlternative
@@ -583,8 +584,8 @@ def expandCollection(terms):
583584# To accommodate arbitrary amounts of triples this rule is rewritten to not be
584585# recursive:
585586# [52*] TriplesTemplate ::= TriplesSameSubject ( '.' TriplesSameSubject? )*
586- TriplesTemplate = ParamList ( "triples" , TriplesSameSubject ) + ZeroOrMore (
587- Suppress ("." ) + Optional (ParamList ( "triples" , TriplesSameSubject ))
587+ TriplesTemplate = Group ( Param ( "triples" , TriplesSameSubject ) ) + ZeroOrMore (
588+ Suppress ("." ) + Optional (Group ( Param ( "triples" , TriplesSameSubject ) ))
588589)
589590
590591# [51] QuadsNotTriples ::= 'GRAPH' VarOrIri '{' Optional(TriplesTemplate) '}'
@@ -598,7 +599,7 @@ def expandCollection(terms):
598599 "Quads" ,
599600 Optional (TriplesTemplate )
600601 + ZeroOrMore (
601- ParamList ( "quadsNotTriples" , QuadsNotTriples )
602+ Group ( Param ( "quadsNotTriples" , QuadsNotTriples ) )
602603 + Optional (Suppress ("." ))
603604 + Optional (TriplesTemplate )
604605 ),
@@ -618,7 +619,7 @@ def expandCollection(terms):
618619
619620# [55] TriplesBlock ::= TriplesSameSubjectPath ( '.' Optional(TriplesBlock) )?
620621TriplesBlock = Forward ()
621- TriplesBlock <<= ParamList ( "triples" , TriplesSameSubjectPath ) + Optional (
622+ TriplesBlock <<= Group ( Param ( "triples" , TriplesSameSubjectPath ) ) + Optional (
622623 Suppress ("." ) + Optional (TriplesBlock )
623624)
624625
@@ -631,8 +632,8 @@ def expandCollection(terms):
631632# [67] GroupOrUnionGraphPattern ::= GroupGraphPattern ( 'UNION' GroupGraphPattern )*
632633GroupOrUnionGraphPattern = Comp (
633634 "GroupOrUnionGraphPattern" ,
634- ParamList ( "graph" , GroupGraphPattern )
635- + ZeroOrMore (Keyword ("UNION" ) + ParamList ( "graph" , GroupGraphPattern )),
635+ Group ( Param ( "graph" , GroupGraphPattern ) )
636+ + ZeroOrMore (Keyword ("UNION" ) + Group ( Param ( "graph" , GroupGraphPattern ) )),
636637)
637638
638639
@@ -1000,7 +1001,7 @@ def expandCollection(terms):
10001001 NIL
10011002 | "("
10021003 + Param ("distinct" , _Distinct )
1003- + delimitedList (ParamList ( "expr" , Expression ))
1004+ + delimitedList (Group ( Param ( "expr" , Expression ) ))
10041005 + ")"
10051006)
10061007
@@ -1045,8 +1046,8 @@ def expandCollection(terms):
10451046 "MultiplicativeExpression" ,
10461047 Param ("expr" , UnaryExpression )
10471048 + ZeroOrMore (
1048- ParamList ( "op" , "*" ) + ParamList ( "other" , UnaryExpression )
1049- | ParamList ( "op" , "/" ) + ParamList ( "other" , UnaryExpression )
1049+ Group ( Param ( "op" , "*" )) + Group ( Param ( "other" , UnaryExpression ) )
1050+ | Group ( Param ( "op" , "/" )) + Group ( Param ( "other" , UnaryExpression ) )
10501051 ),
10511052).setEvalFn (op .MultiplicativeExpression )
10521053
@@ -1063,8 +1064,8 @@ def expandCollection(terms):
10631064 "AdditiveExpression" ,
10641065 Param ("expr" , MultiplicativeExpression )
10651066 + ZeroOrMore (
1066- ParamList ( "op" , "+" ) + ParamList ( "other" , MultiplicativeExpression )
1067- | ParamList ( "op" , "-" ) + ParamList ( "other" , MultiplicativeExpression )
1067+ Group ( Param ( "op" , "+" )) + Group ( Param ( "other" , MultiplicativeExpression ) )
1068+ | Group ( Param ( "op" , "-" )) + Group ( Param ( "other" , MultiplicativeExpression ) )
10681069 ),
10691070).setEvalFn (op .AdditiveExpression )
10701071
@@ -1099,14 +1100,15 @@ def expandCollection(terms):
10991100# [112] ConditionalAndExpression ::= ValueLogical ( '&&' ValueLogical )*
11001101ConditionalAndExpression = Comp (
11011102 "ConditionalAndExpression" ,
1102- Param ("expr" , ValueLogical ) + ZeroOrMore ("&&" + ParamList ("other" , ValueLogical )),
1103+ Param ("expr" , ValueLogical )
1104+ + ZeroOrMore ("&&" + Group (Param ("other" , ValueLogical ))),
11031105).setEvalFn (op .ConditionalAndExpression )
11041106
11051107# [111] ConditionalOrExpression ::= ConditionalAndExpression ( '||' ConditionalAndExpression )*
11061108ConditionalOrExpression = Comp (
11071109 "ConditionalOrExpression" ,
11081110 Param ("expr" , ConditionalAndExpression )
1109- + ZeroOrMore ("||" + ParamList ( "other" , ConditionalAndExpression )),
1111+ + ZeroOrMore ("||" + Group ( Param ( "other" , ConditionalAndExpression ) )),
11101112).setEvalFn (op .ConditionalOrExpression )
11111113
11121114# [110] Expression ::= ConditionalOrExpression
@@ -1154,7 +1156,7 @@ def expandCollection(terms):
11541156 "GroupClause" ,
11551157 Keyword ("GROUP" )
11561158 + Keyword ("BY" )
1157- + OneOrMore (ParamList ( "condition" , GroupCondition )),
1159+ + OneOrMore (Group ( Param ( "condition" , GroupCondition ) )),
11581160)
11591161
11601162
@@ -1222,7 +1224,7 @@ def expandCollection(terms):
12221224 Param ("delete" , DeleteClause ) + Optional (Param ("insert" , InsertClause ))
12231225 | Param ("insert" , InsertClause )
12241226 )
1225- + ZeroOrMore (ParamList ( "using" , UsingClause ))
1227+ + ZeroOrMore (Group ( Param ( "using" , UsingClause ) ))
12261228 + Keyword ("WHERE" )
12271229 + Param ("where" , GroupGraphPattern ),
12281230)
@@ -1246,17 +1248,22 @@ def expandCollection(terms):
12461248
12471249# [63] InlineDataOneVar ::= Var '{' ZeroOrMore(DataBlockValue) '}'
12481250InlineDataOneVar = (
1249- ParamList ("var" , Var ) + "{" + ZeroOrMore (ParamList ("value" , DataBlockValue )) + "}"
1251+ Group (Param ("var" , Var ))
1252+ + "{"
1253+ + ZeroOrMore (Group (Param ("value" , DataBlockValue )))
1254+ + "}"
12501255)
12511256
12521257# [64] InlineDataFull ::= ( NIL | '(' ZeroOrMore(Var) ')' ) '{' ( '(' ZeroOrMore(DataBlockValue) ')' | NIL )* '}'
12531258InlineDataFull = (
1254- (NIL | "(" + ZeroOrMore (ParamList ( "var" , Var )) + ")" )
1259+ (NIL | "(" + ZeroOrMore (Group ( Param ( "var" , Var ) )) + ")" )
12551260 + "{"
12561261 + ZeroOrMore (
1257- ParamList (
1258- "value" ,
1259- Group (Suppress ("(" ) + ZeroOrMore (DataBlockValue ) + Suppress (")" ) | NIL ),
1262+ Group (
1263+ Param (
1264+ "value" ,
1265+ Group (Suppress ("(" ) + ZeroOrMore (DataBlockValue ) + Suppress (")" ) | NIL ),
1266+ )
12601267 )
12611268 )
12621269 + "}"
@@ -1274,7 +1281,7 @@ def expandCollection(terms):
12741281
12751282# [74] ConstructTriples ::= TriplesSameSubject ( '.' Optional(ConstructTriples) )?
12761283ConstructTriples = Forward ()
1277- ConstructTriples <<= ParamList ( "template" , TriplesSameSubject ) + Optional (
1284+ ConstructTriples <<= Group ( Param ( "template" , TriplesSameSubject ) ) + Optional (
12781285 Suppress ("." ) + Optional (ConstructTriples )
12791286)
12801287
@@ -1331,11 +1338,11 @@ def expandCollection(terms):
13311338# [54] GroupGraphPatternSub ::= Optional(TriplesBlock) ( GraphPatternNotTriples '.'? Optional(TriplesBlock) )*
13321339GroupGraphPatternSub = Comp (
13331340 "GroupGraphPatternSub" ,
1334- Optional (ParamList ( "part" , Comp ("TriplesBlock" , TriplesBlock )))
1341+ Optional (Group ( Param ( "part" , Comp ("TriplesBlock" , TriplesBlock ) )))
13351342 + ZeroOrMore (
1336- ParamList ( "part" , GraphPatternNotTriples )
1343+ Group ( Param ( "part" , GraphPatternNotTriples ) )
13371344 + Optional ("." )
1338- + Optional (ParamList ( "part" , Comp ("TriplesBlock" , TriplesBlock )))
1345+ + Optional (Group ( Param ( "part" , Comp ("TriplesBlock" , TriplesBlock ) )))
13391346 ),
13401347)
13411348
@@ -1347,7 +1354,7 @@ def expandCollection(terms):
13471354# [21] HavingClause ::= 'HAVING' HavingCondition+
13481355HavingClause = Comp (
13491356 "HavingClause" ,
1350- Keyword ("HAVING" ) + OneOrMore (ParamList ( "condition" , HavingCondition )),
1357+ Keyword ("HAVING" ) + OneOrMore (Group ( Param ( "condition" , HavingCondition ) )),
13511358)
13521359
13531360# [24] OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression )
@@ -1364,7 +1371,7 @@ def expandCollection(terms):
13641371 "OrderClause" ,
13651372 Keyword ("ORDER" )
13661373 + Keyword ("BY" )
1367- + OneOrMore (ParamList ( "condition" , OrderCondition )),
1374+ + OneOrMore (Group ( Param ( "condition" , OrderCondition ) )),
13681375)
13691376
13701377# [26] LimitClause ::= 'LIMIT' INTEGER
@@ -1394,19 +1401,21 @@ def expandCollection(terms):
13941401 + Optional (Param ("modifier" , Keyword ("DISTINCT" ) | Keyword ("REDUCED" )))
13951402 + (
13961403 OneOrMore (
1397- ParamList (
1398- "projection" ,
1399- Comp (
1400- "vars" ,
1401- Param ("var" , Var )
1402- | (
1403- Literal ("(" )
1404- + Param ("expr" , Expression )
1405- + Keyword ("AS" )
1406- + Param ("evar" , Var )
1407- + ")"
1404+ Group (
1405+ Param (
1406+ "projection" ,
1407+ Comp (
1408+ "vars" ,
1409+ Param ("var" , Var )
1410+ | (
1411+ Literal ("(" )
1412+ + Param ("expr" , Expression )
1413+ + Keyword ("AS" )
1414+ + Param ("evar" , Var )
1415+ + ")"
1416+ ),
14081417 ),
1409- ),
1418+ )
14101419 )
14111420 )
14121421 | "*"
@@ -1428,7 +1437,7 @@ def expandCollection(terms):
14281437SelectQuery = Comp (
14291438 "SelectQuery" ,
14301439 SelectClause
1431- + ZeroOrMore (ParamList ( "datasetClause" , DatasetClause ))
1440+ + ZeroOrMore (Group ( Param ( "datasetClause" , DatasetClause ) ))
14321441 + WhereClause
14331442 + SolutionModifier
14341443 + ValuesClause ,
@@ -1442,19 +1451,19 @@ def expandCollection(terms):
14421451 Keyword ("CONSTRUCT" )
14431452 + (
14441453 ConstructTemplate
1445- + ZeroOrMore (ParamList ( "datasetClause" , DatasetClause ))
1454+ + ZeroOrMore (Group ( Param ( "datasetClause" , DatasetClause ) ))
14461455 + WhereClause
14471456 + SolutionModifier
14481457 + ValuesClause
1449- | ZeroOrMore (ParamList ( "datasetClause" , DatasetClause ))
1458+ | ZeroOrMore (Group ( Param ( "datasetClause" , DatasetClause ) ))
14501459 + Keyword ("WHERE" )
14511460 + "{"
14521461 + Optional (
14531462 Param (
14541463 "where" ,
14551464 Comp (
14561465 "FakeGroupGraphPatten" ,
1457- ParamList ( "part" , Comp ("TriplesBlock" , TriplesTemplate )),
1466+ Group ( Param ( "part" , Comp ("TriplesBlock" , TriplesTemplate ) )),
14581467 ),
14591468 )
14601469 )
@@ -1478,7 +1487,7 @@ def expandCollection(terms):
14781487DescribeQuery = Comp (
14791488 "DescribeQuery" ,
14801489 Keyword ("DESCRIBE" )
1481- + (OneOrMore (ParamList ( "var" , VarOrIri )) | "*" )
1490+ + (OneOrMore (Group ( Param ( "var" , VarOrIri ) )) | "*" )
14821491 + Param ("datasetClause" , ZeroOrMore (DatasetClause ))
14831492 + Optional (WhereClause )
14841493 + SolutionModifier
@@ -1487,8 +1496,8 @@ def expandCollection(terms):
14871496
14881497# [29] Update ::= Prologue ( Update1 ( ';' Update )? )?
14891498Update = Forward ()
1490- Update <<= ParamList ( "prologue" , Prologue ) + Optional (
1491- ParamList ( "request" , Update1 ) + Optional (";" + Update )
1499+ Update <<= Group ( Param ( "prologue" , Prologue ) ) + Optional (
1500+ Group ( Param ( "request" , Update1 ) ) + Optional (";" + Update )
14921501)
14931502
14941503
0 commit comments