80 lines
2.7 KiB
JavaScript
80 lines
2.7 KiB
JavaScript
/*
|
|
Language: Delphi
|
|
*/
|
|
|
|
hljs.LANGUAGES['delphi'] = 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,
|
|
defaultMode: {
|
|
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
|
|
]
|
|
}
|
|
]
|
|
}
|
|
};
|
|
}(hljs);
|