Skip to content

Commit

Permalink
chore: refactor '_completeSubjectLiteral' and '_completePredicateLite…
Browse files Browse the repository at this point in the history
…ral'
  • Loading branch information
jeswr committed Mar 24, 2023
1 parent b134613 commit f32e2c3
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/N3Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,31 +558,27 @@ export default class N3Parser {
}

// Completes a literal in subject position
_completeSubjectLiteral(token) {
const completed = this._completeLiteral(token);

this._subject = completed.literal;
// If the token was consumed, continue with the rest of the input
if (completed.token === null)
return this._readPredicateOrNamedGraph;
// Otherwise, consume the token now
else {
return this._readPredicateOrNamedGraph(completed.token);
}
_completeSubjectLiteral(tkn) {
const { literal, token } = this._completeLiteral(tkn);
this._subject = literal;

return token === null ?
// If the token was consumed, continue with the rest of the input
this._readPredicateOrNamedGraph :
// Otherwise, consume the token now
this._readPredicateOrNamedGraph(token);
}

// Completes a literal in predicate position
_completePredicateLiteral(token) {
const completed = this._completeLiteral(token);

this._predicate = completed.literal;
// If the token was consumed, continue with the rest of the input
if (completed.token === null)
return this._readObject;
// Otherwise, consume the token now
else {
return this._readObject(completed.token);
}
_completePredicateLiteral(tkn) {
const { literal, token } = this._completeLiteral(tkn);
this._predicate = literal;

return token === null ?
// If the token was consumed, continue with the rest of the input
this._readObject :
// Otherwise, consume the token now
this._readObject(token);
}

// Completes a literal in object position
Expand Down

0 comments on commit f32e2c3

Please sign in to comment.