You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/11/22 11:34:32 UTC
svn commit: r1544470 -
/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
Author: andy
Date: Fri Nov 22 10:34:32 2013
New Revision: 1544470
URL: http://svn.apache.org/r1544470
Log:
Tighten up strict mode, which is not the normal parsing mode.
+ Bare collections -- ( 1 2 3 ) . -- is illegal
+ Require DOT after @-directives
Modified:
jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java?rev=1544470&r1=1544469&r2=1544470&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java Fri Nov 22 10:34:32 2013
@@ -128,15 +128,21 @@ public abstract class LangTurtleBase ext
if ( x.equals("base") ) {
directiveBase() ;
- skipIf(DOT) ;
- // expect("Base directive not terminated by a dot", DOT) ;
+ if ( profile.isStrictMode() )
+ // The line number is probably one ahead due to the newline
+ expect("Base directive not terminated by a dot", DOT) ;
+ else
+ skipIf(DOT) ;
return ;
}
if ( x.equals("prefix") ) {
directivePrefix() ;
- skipIf(DOT) ;
- // expect("Prefix directive not terminated by a dot", DOT) ;
+ if ( profile.isStrictMode() )
+ // The line number is probably one ahead due to the newline
+ expect("Prefix directive not terminated by a dot", DOT) ;
+ else
+ skipIf(DOT) ;
return ;
}
exception(t, "Unrecognized directive: %s", x) ;
@@ -168,7 +174,6 @@ public abstract class LangTurtleBase ext
String baseStr = token.getImage() ;
dest.base(baseStr) ;
IRI baseIRI = profile.makeIRI(baseStr, currLine, currCol) ;
- skipIf(DOT) ;
nextToken() ;
profile.getPrologue().setBaseURI(baseIRI) ;
}
@@ -187,6 +192,8 @@ public abstract class LangTurtleBase ext
return ;
}
+ boolean maybeList = lookingAt(LPAREN) ;
+
// TriplesSameSubject -> TriplesNode PropertyList?
if ( peekTriplesNodeCompound() ) {
Node n = triplesNodeCompound() ;
@@ -201,13 +208,14 @@ public abstract class LangTurtleBase ext
// There must be a predicate and object.
// -- If strict turtle.
- if ( false ) {
+ // TODO Also for { ( 1 2 3 ) }
+ if ( profile.isStrictMode() && maybeList ) {
if ( peekPredicate() ) {
predicateObjectList(n) ;
expectEndOfTriples() ;
return ;
}
- exception(peekToken(), "Predicate/object required after (...) and [...] - Unexpected token : %s",
+ exception(peekToken(), "Predicate/object required after (...) - Unexpected token : %s",
peekToken()) ;
}
// ---
@@ -243,9 +251,8 @@ public abstract class LangTurtleBase ext
expectEndOfTriples() ;
}
- // XXX Sort out.
- // Move top level loop into LangTriG and LangTurtle.
// Differs between Turtle and TriG.
+ // TriG, inside {} does not need the trailing DOT
protected abstract void expectEndOfTriples() ;
// The DOT is required by Turtle (strictly).