You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2022/11/25 16:11:53 UTC

[GitHub] [jena] ericprud commented on a diff in pull request #1637: GH-1636 add support for semantic actions

ericprud commented on code in PR #1637:
URL: https://github.com/apache/jena/pull/1637#discussion_r1032580271


##########
jena-shex/src/main/java/org/apache/jena/shex/parser/ParserShExC.java:
##########
@@ -632,6 +641,48 @@ protected void numericFacetLength(String facetKind, int length, int line, int co
         addNodeConstraint(numLength);
     }
 
+    protected SemAct crackSemanticAction(String iriAndCode, int line, int column) {
+        // e.g. % <http://shex.io/extensions/Test/> { print(s) %}
+        // or   % ex:Test { print(s) %}
+        // or   %<http://shex.io/extensions/Test/>%
+
+        // Trim leading '%' and ws and trim trailing '%}'
+        String whitespaces = " \t\n\r\f";
+        int startOfIri = 1; // get past '%'
+        for (; whitespaces.indexOf(iriAndCode.charAt(startOfIri)) != -1; ++startOfIri)

Review Comment:
   I totally agree that it looks like 80's era K&R C, but I engineered this one pretty hard and I don't think that StringUtils will add anything but cycles. I [added tests](https://github.com/apache/jena/pull/1637/files#diff-f1b4d58d2a4e81046c490afc8b71496e8440f6aed8e15c3ded996bdb8de0c4c9) to verify that whatever the parser accepted, my C ptrs could handle.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org