in assets/lambda_helper_neptune/python/rdflib/plugins/parsers/notation3.py [0:0]
def directive(self, argstr, i):
j = self.skipSpace(argstr, i)
if j < 0:
return j # eof
res = []
j = self.tok('bind', argstr, i) # implied "#". Obsolete.
if j > 0:
self.BadSyntax(argstr, i,
"keyword bind is obsolete: use @prefix")
j = self.tok('keywords', argstr, i)
if j > 0:
if self.turtle:
self.BadSyntax(argstr, i, "Found 'keywords' when in Turtle mode.")
i = self.commaSeparatedList(argstr, j, res, self.bareWord)
if i < 0:
self.BadSyntax(argstr, i,
"'@keywords' needs comma separated list of words")
self.setKeywords(res[:])
return i
j = self.tok('forAll', argstr, i)
if j > 0:
if self.turtle:
self.BadSyntax(argstr, i, "Found 'forAll' when in Turtle mode.")
i = self.commaSeparatedList(argstr, j, res, self.uri_ref2)
if i < 0:
self.BadSyntax(argstr, i,
"Bad variable list after @forAll")
for x in res:
# self._context.declareUniversal(x)
if x not in self._variables or x in self._parentVariables:
self._variables[x] = self._context.newUniversal(x)
return i
j = self.tok('forSome', argstr, i)
if j > 0:
if self.turtle:
self.BadSyntax(argstr, i, "Found 'forSome' when in Turtle mode.")
i = self. commaSeparatedList(argstr, j, res, self.uri_ref2)
if i < 0:
self.BadSyntax(argstr, i,
"Bad variable list after @forSome")
for x in res:
self._context.declareExistential(x)
return i
j = self.tok('prefix', argstr, i, colon=True) # no implied "#"
if j >= 0:
t = []
i = self.qname(argstr, j, t)
if i < 0:
self.BadSyntax(argstr, j,
"expected qname after @prefix")
j = self.uri_ref2(argstr, i, t)
if j < 0:
self.BadSyntax(argstr, i,
"expected <uriref> after @prefix _qname_")
ns = self.uriOf(t[1])
if self._baseURI:
ns = join(self._baseURI, ns)
elif ":" not in ns:
self.BadSyntax(argstr, j,
"With no base URI, cannot use " +
"relative URI in @prefix <" + ns + ">")
assert ':' in ns # must be absolute
self._bindings[t[0][0]] = ns
self.bind(t[0][0], hexify(ns))
return j
j = self.tok('base', argstr, i) # Added 2007/7/7
if j >= 0:
t = []
i = self.uri_ref2(argstr, j, t)
if i < 0:
self.BadSyntax(argstr, j,
"expected <uri> after @base ")
ns = self.uriOf(t[0])
if self._baseURI:
ns = join(self._baseURI, ns)
else:
self.BadSyntax(argstr, j,
"With no previous base URI, cannot use " +
"relative URI in @base <" + ns + ">")
assert ':' in ns # must be absolute
self._baseURI = ns
return i
return -1 # Not a directive, could be something else.