@@ -211,7 +211,6 @@ public void addFromNamedGraph(IriAst graph) {
211211 /**
212212 * Sets the LIMIT for pagination
213213 *
214- * @param limit
215214 */
216215 public void setLimit (long limit ) {
217216 this .limit = limit ;
@@ -220,7 +219,6 @@ public void setLimit(long limit) {
220219 /**
221220 * Sets the OFFSET for pagination
222221 *
223- * @param offset
224222 */
225223 public void setOffset (long offset ) {
226224 this .offset = offset ;
@@ -608,15 +606,15 @@ public ConstraintAst createFunCall(IriAst functionName, List<TermAst> args) {
608606
609607 public TermAst termFromVerb (fr .inria .corese .core .next .impl .parser .antlr .SparqlParser .VerbContext ctx ) {
610608 if (ctx .A () != null ) return this .iri ("a" );
611- return termFromVarOrIriRef (ctx .varOrIRIref ());
609+ return termFromVarOrIriRef (ctx .varOrIri ());
612610 }
613611
614612 public TermAst termFromVarOrTerm (fr .inria .corese .core .next .impl .parser .antlr .SparqlParser .VarOrTermContext ctx ) {
615613 if (ctx .var_ () != null ) return termFromVar (ctx .var_ ());
616614 return termFromGraphTerm (ctx .graphTerm ());
617615 }
618616
619- public TermAst termFromVarOrIriRef (fr . inria . corese . core . next . impl . parser . antlr . SparqlParser .VarOrIRIrefContext ctx ) {
617+ public TermAst termFromVarOrIriRef (SparqlParser .VarOrIriContext ctx ) {
620618 if (ctx .var_ () != null ) {
621619 return termFromVar (ctx .var_ ());
622620 }
@@ -731,7 +729,7 @@ public TermAst termFromIriRefOrFunction(fr.inria.corese.core.next.impl.parser.an
731729 }
732730
733731 public List <TermAst > termListFromArgList (fr .inria .corese .core .next .impl .parser .antlr .SparqlParser .ArgListContext ctx ) {
734- return ctx .expression ().stream ().map (arg -> ( TermAst ) termFromExpression ( arg ) ).toList ();
732+ return ctx .expression ().stream ().map (this :: termFromExpression ).toList ();
735733 }
736734
737735 public TermAst termFromIriRef (fr .inria .corese .core .next .impl .parser .antlr .SparqlParser .IriRefContext ctx ) {
@@ -940,7 +938,12 @@ public TermAst termFromAdditive(fr.inria.corese.core.next.impl.parser.antlr.Spar
940938 case fr .inria .corese .core .next .impl .parser .antlr .SparqlParser .NumericLiteralNegativeContext numericLiteralNegativeContext ->
941939 (ExprAst ) termFromNumericLiteralNegative (numericLiteralNegativeContext );
942940 case null , default ->
943- throw new QueryEvaluationException ("Unexpected left hand termFromExpression in additive termFromExpression " + ctx .getText () + " " + child .getText ());
941+ throw new QueryEvaluationException (
942+ "Unexpected left hand termFromExpression in additive termFromExpression "
943+ + ctx .getText ()
944+ + " "
945+ + (child != null ? child .getText () : "null" )
946+ );
944947 };
945948 leftHand = createConstraint (op , List .of (leftHand , rightHand ));
946949 }
@@ -994,7 +997,7 @@ public TermAst termFromUnary(fr.inria.corese.core.next.impl.parser.antlr.SparqlP
994997 ASTConstants .Constraint op = null ;
995998 if (ctx .PLUS () != null ) {
996999 op = ASTConstants .OPERATOR .PLUS ;
997- } else if (ctx .MINUS () != null ) {
1000+ } else if (ctx .MINUS_SIGN () != null ) {
9981001 op = ASTConstants .OPERATOR .MINUS ;
9991002 } else if (ctx .EXCLAMATION () != null ) {
10001003 op = ASTConstants .OPERATOR .NOT ;
@@ -1018,4 +1021,37 @@ public TermAst termFromRegex(SparqlParser.RegexExpressionContext ctx) {
10181021 throw new QueryEvaluationException ("Unexpected arguments for REGEX call" );
10191022 }
10201023 }
1024+
1025+ /**
1026+ * Predicate as a property path.
1027+ * For simple triples without a composed path, this is just an iriRef or 'a'.
1028+ * Composed property paths will be expanded in a later phase if needed.
1029+ */
1030+ public TermAst termFromVerbPath (SparqlParser .VerbPathContext ctx ) {
1031+ return this .iri (ctx .getText ());
1032+ }
1033+
1034+ /**
1035+ * Predicate as a simple variable (e.g. ?p used as a predicate).
1036+ */
1037+ public TermAst termFromVerbSimple (SparqlParser .VerbSimpleContext ctx ) {
1038+ return termFromVar (ctx .var_ ());
1039+ }
1040+
1041+ /**
1042+ * List of objects inside a property path triple.
1043+ * Blank node property lists and collections are not yet fully supported (raw text fallback).
1044+ */
1045+ public List <TermAst > termListFromObjectListPath (SparqlParser .ObjectListPathContext ctx ) {
1046+ List <TermAst > out = new ArrayList <>();
1047+ for (var objPath : ctx .objectPath ()) {
1048+ var graphNodePath = objPath .graphNodePath ();
1049+ if (graphNodePath .varOrTerm () != null ) {
1050+ out .add (termFromVarOrTerm (graphNodePath .varOrTerm ()));
1051+ } else {
1052+ out .add (this .iri (graphNodePath .getText ()));
1053+ }
1054+ }
1055+ return out ;
1056+ }
10211057}
0 commit comments