-
Notifications
You must be signed in to change notification settings - Fork 0
/
delphi.js
73 lines (73 loc) · 2.6 KB
/
delphi.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
module.exports = function(hljs) {
var DELPHI_KEYWORDS = 'and safecall cdecl then string exports library not pascal set ' +
'virtual file in array label packed end. index while const raise for to implementation ' +
'with except overload destructor downto finally program exit unit inherited override if ' +
'type until function do begin repeat goto nil far initialization object else var uses ' +
'external resourcestring interface end finalization class asm mod case on shr shl of ' +
'register xorwrite threadvar try record near stored constructor stdcall inline div out or ' +
'procedure';
var DELPHI_CLASS_KEYWORDS = 'safecall stdcall pascal stored const implementation ' +
'finalization except to finally program inherited override then exports string read not ' +
'mod shr try div shl set library message packed index for near overload label downto exit ' +
'public goto interface asm on of constructor or private array unit raise destructor var ' +
'type until function else external with case default record while protected property ' +
'procedure published and cdecl do threadvar file in if end virtual write far out begin ' +
'repeat nil initialization object uses resourcestring class register xorwrite inline static';
var CURLY_COMMENT = {
className: 'comment',
begin: '{', end: '}',
relevance: 0
};
var PAREN_COMMENT = {
className: 'comment',
begin: '\\(\\*', end: '\\*\\)',
relevance: 10
};
var STRING = {
className: 'string',
begin: '\'', end: '\'',
contains: [{begin: '\'\''}],
relevance: 0
};
var CHAR_STRING = {
className: 'string', begin: '(#\\d+)+'
};
var FUNCTION = {
className: 'function',
beginWithKeyword: true, end: '[:;]',
keywords: 'function constructor|10 destructor|10 procedure|10',
contains: [
{
className: 'title', begin: hljs.IDENT_RE
},
{
className: 'params',
begin: '\\(', end: '\\)',
keywords: DELPHI_KEYWORDS,
contains: [STRING, CHAR_STRING]
},
CURLY_COMMENT, PAREN_COMMENT
]
};
return {
case_insensitive: true,
keywords: DELPHI_KEYWORDS,
illegal: '("|\\$[G-Zg-z]|\\/\\*|</)',
contains: [
CURLY_COMMENT, PAREN_COMMENT, hljs.C_LINE_COMMENT_MODE,
STRING, CHAR_STRING,
hljs.NUMBER_MODE,
FUNCTION,
{
className: 'class',
begin: '=\\bclass\\b', end: 'end;',
keywords: DELPHI_CLASS_KEYWORDS,
contains: [
STRING, CHAR_STRING,
CURLY_COMMENT, PAREN_COMMENT, hljs.C_LINE_COMMENT_MODE,
FUNCTION
]
}
]
};
};