1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/prolog.js

103 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/*
Language: Prolog
Description: Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics.
Author: Raivo Laanemets <raivo@infdot.com>
Website: https://en.wikipedia.org/wiki/Prolog
*/
2023-12-18 13:12:25 +08:00
2024-01-16 21:26:16 +08:00
function prolog(hljs) {
const ATOM = {
2023-12-18 13:12:25 +08:00
begin: /[a-z][A-Za-z0-9_]*/,
relevance: 0
};
2024-01-16 21:26:16 +08:00
const VAR = {
2023-12-18 13:12:25 +08:00
className: 'symbol',
variants: [
2024-01-16 21:26:16 +08:00
{
begin: /[A-Z][a-zA-Z0-9_]*/
},
{
begin: /_[A-Za-z0-9_]*/
}
2023-12-18 13:12:25 +08:00
],
relevance: 0
};
2024-01-16 21:26:16 +08:00
const PARENTED = {
2023-12-18 13:12:25 +08:00
begin: /\(/,
end: /\)/,
relevance: 0
};
2024-01-16 21:26:16 +08:00
const LIST = {
2023-12-18 13:12:25 +08:00
begin: /\[/,
end: /\]/
};
2024-01-16 21:26:16 +08:00
const LINE_COMMENT = {
2023-12-18 13:12:25 +08:00
className: 'comment',
2024-01-16 21:26:16 +08:00
begin: /%/,
end: /$/,
contains: [ hljs.PHRASAL_WORDS_MODE ]
2023-12-18 13:12:25 +08:00
};
2024-01-16 21:26:16 +08:00
const BACKTICK_STRING = {
2023-12-18 13:12:25 +08:00
className: 'string',
2024-01-16 21:26:16 +08:00
begin: /`/,
end: /`/,
contains: [ hljs.BACKSLASH_ESCAPE ]
2023-12-18 13:12:25 +08:00
};
2024-01-16 21:26:16 +08:00
const CHAR_CODE = {
2023-12-18 13:12:25 +08:00
className: 'string', // 0'a etc.
2024-01-16 21:26:16 +08:00
begin: /0'(\\'|.)/
2023-12-18 13:12:25 +08:00
};
2024-01-16 21:26:16 +08:00
const SPACE_CODE = {
2023-12-18 13:12:25 +08:00
className: 'string',
2024-01-16 21:26:16 +08:00
begin: /0'\\s/ // 0'\s
2023-12-18 13:12:25 +08:00
};
2024-01-16 21:26:16 +08:00
const PRED_OP = { // relevance booster
2023-12-18 13:12:25 +08:00
begin: /:-/
};
2024-01-16 21:26:16 +08:00
const inner = [
2023-12-18 13:12:25 +08:00
ATOM,
VAR,
PARENTED,
PRED_OP,
LIST,
LINE_COMMENT,
hljs.C_BLOCK_COMMENT_MODE,
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
BACKTICK_STRING,
CHAR_CODE,
SPACE_CODE,
hljs.C_NUMBER_MODE
];
PARENTED.contains = inner;
LIST.contains = inner;
return {
2024-01-16 21:26:16 +08:00
name: 'Prolog',
2023-12-18 13:12:25 +08:00
contains: inner.concat([
2024-01-16 21:26:16 +08:00
{ // relevance booster
begin: /\.$/
}
2023-12-18 13:12:25 +08:00
])
};
2024-01-16 21:26:16 +08:00
}
module.exports = prolog;