-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsparql.js
91 lines (79 loc) · 1.91 KB
/
sparql.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
module.exports = function(hljs) {
var SPARQL_IDEN_REGEX = "[a-zA-Z0-9_\\-]+";
var SPARQL_IDEN_EMPTY_REGEX = "[a-zA-Z0-9_\\-]*";
var SPARQL_KEYWORDS = {
keyword: 'base prefix select distinct reduced construct describe ' +
'ask from named where order limit offset filter optional ' +
'graph by asc desc as having undef values group ' +
'minus in not service silent using insert delete ' +
'data copy to move add create drop clear load',
aggregate: 'count sum min max avg'
}
var VARIABLE = {
className: 'variable',
begin: '\\?'+ SPARQL_IDEN_REGEX +'|\\$'+ SPARQL_IDEN_REGEX
};
var URIS = [
{
className: 'uri',
begin: '<', end: '>'
},
{
className: 'uri',
begin: SPARQL_IDEN_EMPTY_REGEX+ '?\\:'+ SPARQL_IDEN_REGEX
},
{
className: 'uri',
begin: '\\ba\\b'
}
];
var RULE = {
className: 'rule',
beginWithKeyword: true,
keywords: 'if then'
};
var STR_CONTAINS = [hljs.BACKSLASH_ESCAPE, RULE];
var STRINGS = [
{
className: 'string',
begin: "'", end: "'",
contains: STR_CONTAINS,
relevance: 0
},
{
className: 'string',
begin: '"', end: '"',
contains: STR_CONTAINS,
relevance: 0
}
];
var STRINGS_MULTIPLE = [
{
className: 'string',
begin: "'''", end: "'''",
contains: STR_CONTAINS,
relevance: 0
},
{
className: 'string',
begin: '"""', end: '"""',
contains: STR_CONTAINS,
relevance: 0
}
];
var NUMBERS = [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE];
var COMMENT = {
className: 'comment',
begin: '#', end: '\\n'
};
var SPARQL_DEFAULT_CONTAINS = [
COMMENT,
VARIABLE,
RULE
].concat(STRINGS_MULTIPLE).concat(STRINGS).concat(NUMBERS).concat(URIS);
return {
case_insensitive: true,
keywords: SPARQL_KEYWORDS,
contains: SPARQL_DEFAULT_CONTAINS
};
};