Skip to content

Commit c0a2171

Browse files
committed
Resolve compact IRI conflict (var vs const)
1 parent 53b9415 commit c0a2171

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed

doc/syntax.md

+5-16
Original file line numberDiff line numberDiff line change
@@ -206,28 +206,17 @@ Goal defines a first rule.
206206

207207
## Semantic Web compatibility
208208

209-
Semantic Web uses heavily IRIs as concept identifiers. This library implements datalog syntax enhancement that support absolute and compact IRIs within the query. An absolute IRI is only used as literals but compact IRIs can be used as variables and literals simultaneously.
209+
Semantic Web heavily uses IRIs as identifiers. IRIs defines subjects, predicates and sometimes objects. This library implements datalog syntax enhancement that supports absolute and compact IRIs inside queries either as constants or variables.
210210

211-
The following example shows usage of absolute IRI. You can use them as in-line literals within any predicates.
211+
IRIs as constants uses traditional syntax `<absolute IRI>` or `prefix:suffix`
212212

213213
```
214-
p(x, <http://example.com/1>).
215-
216214
h(x) :- p(x, <http://example.com/1>).
215+
h(x) :- p(x, foaf:name).
217216
```
218217

219-
The following example shows usage of compact IRI, they are only allowed at ground truth or infix predicates.
220-
221-
```
222-
p(x, foaf:name).
223-
224-
h(x) :- p(x, y), y = foaf:name.
225-
```
226-
227-
Any compact IRI within predicate is used as variable
218+
Only compact IRIs are allowed as variable, they have to be prefixed by `'` character
228219

229220
```
230-
h(rdf:id, foaf:name) :- p(rdf:id, foaf:name).
221+
h('rdf:id, 'foaf:name) :- p('rdf:id, 'foaf:name).
231222
```
232-
233-

src/datalog_leex.xrl

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Rules.
3131
{CHAR}+ :
3232
{token, {symbol, TokenLine, TokenChars}}.
3333

34+
'[a-zA-Z_:]* :
35+
{token, {symbol, TokenLine, lists:sublist(TokenChars, 2, TokenLen - 1)}}.
36+
3437
%%
3538
%% xsd:anyURI
3639
%% <http://a/b> - absolute IRI

src/datalog_vm.erl

-5
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ term(T, Predicate)
144144
#{T := Value} -> Value;
145145
_ -> '_'
146146
end;
147-
term({iri, _, _} = T, Predicate) ->
148-
case Predicate of
149-
#{T := Value} -> Value;
150-
_ -> '_'
151-
end;
152147
term(T, _) ->
153148
T.
154149

test/datalog_SUITE.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ recursion_3(_) ->
206206
%%
207207
source_semantic_web(_) ->
208208
datalog(
209-
"?- schema:person(_, _). foaf:person(rdf:id, foaf:name). schema:person(rdf:id, foaf:name) :- foaf:person(rdf:id, foaf:name).",
209+
"?- schema:person(_, _). foaf:person('rdf:id, 'foaf:name). schema:person('rdf:id, 'foaf:name) :- foaf:person('rdf:id, 'foaf:name).",
210210
[{1,2}, {2,3}, {3,4}],
211211
[{1,2}, {2,3}, {3,4}]
212212
).

0 commit comments

Comments
 (0)