use of org.apache.jena.riot.tokens.Token in project jena by apache.
the class LangTurtleBase method triplesList.
protected final Node triplesList() {
nextToken();
Node lastCell = null;
Node listHead = null;
startList();
for (; ; ) {
Token errorToken = peekToken();
if (eof())
exception(peekToken(), "Unterminated list");
if (lookingAt(RPAREN)) {
nextToken();
break;
}
// The value.
Node n = triplesNode();
if (n == null)
exception(errorToken, "Malformed list");
// Node for the list structre.
Node nextCell = NodeFactory.createBlankNode();
if (listHead == null)
listHead = nextCell;
if (lastCell != null)
emitTriple(lastCell, NodeConst.nodeRest, nextCell);
lastCell = nextCell;
emitTriple(nextCell, NodeConst.nodeFirst, n);
}
if (lastCell == null) {
// Simple ()
finishList();
return NodeConst.nodeNil;
}
// Finish list.
emitTriple(lastCell, NodeConst.nodeRest, NodeConst.nodeNil);
finishList();
return listHead;
}
use of org.apache.jena.riot.tokens.Token in project jena by apache.
the class LangTurtleBase method predicate.
/** Get predicate - maybe null for "illegal" */
protected final Node predicate() {
Token t = peekToken();
if (t.hasType(TokenType.KEYWORD)) {
boolean strict = isStrictMode;
Token tErr = peekToken();
String image = peekToken().getImage();
if (image.equals(KW_A))
return NodeConst.nodeRDFType;
// N3-isms
if (!strict && image.equals(KW_SAME_AS))
return nodeSameAs;
// Relationship between two formulae in N3.
// if ( !strict && image.equals(KW_LOG_IMPLIES) )
// return log:implies;
exception(tErr, "Unrecognized keyword: " + image);
}
Node n = node();
if (n == null || !n.isURI())
exception(t, "Expected IRI for predicate: got: %s", t);
return n;
}
use of org.apache.jena.riot.tokens.Token in project jena by apache.
the class LangTurtleBase method runParser.
@Override
protected final void runParser() {
while (moreTokens()) {
Token t = peekToken();
if (lookingAt(DIRECTIVE)) {
// @form.
directive();
continue;
}
if (lookingAt(KEYWORD)) {
if (t.getImage().equalsIgnoreCase("PREFIX") || t.getImage().equalsIgnoreCase("BASE")) {
directiveKeyword();
continue;
}
}
oneTopLevelElement();
if (lookingAt(EOF))
break;
}
}
use of org.apache.jena.riot.tokens.Token in project jena by apache.
the class LangEngine method eof.
protected final boolean eof() {
if (tokenEOF != null)
return true;
if (!moreTokens()) {
tokenEOF = new Token(tokens.getLine(), tokens.getColumn());
tokenEOF.setType(EOF);
return true;
}
return false;
}
use of org.apache.jena.riot.tokens.Token in project jena by apache.
the class LangEngine method expect.
protected final void expect(String msg, TokenType ttype) {
if (!lookingAt(ttype)) {
Token location = peekToken();
exception(location, msg);
}
nextToken();
}
Aggregations