2024-01-16 21:26:16 +08:00
|
|
|
/*
|
|
|
|
Language: Pony
|
|
|
|
Author: Joe Eli McIlvain <joe.eli.mac@gmail.com>
|
|
|
|
Description: Pony is an open-source, object-oriented, actor-model,
|
|
|
|
capabilities-secure, high performance programming language.
|
|
|
|
Website: https://www.ponylang.io
|
|
|
|
*/
|
|
|
|
|
|
|
|
function pony(hljs) {
|
|
|
|
const KEYWORDS = {
|
2023-12-18 13:12:25 +08:00
|
|
|
keyword:
|
|
|
|
'actor addressof and as be break class compile_error compile_intrinsic ' +
|
|
|
|
'consume continue delegate digestof do else elseif embed end error ' +
|
|
|
|
'for fun if ifdef in interface is isnt lambda let match new not object ' +
|
|
|
|
'or primitive recover repeat return struct then trait try type until ' +
|
|
|
|
'use var where while with xor',
|
|
|
|
meta:
|
|
|
|
'iso val tag trn box ref',
|
|
|
|
literal:
|
|
|
|
'this false true'
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const TRIPLE_QUOTE_STRING_MODE = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'string',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '"""',
|
|
|
|
end: '"""',
|
2023-12-18 13:12:25 +08:00
|
|
|
relevance: 10
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const QUOTE_STRING_MODE = {
|
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 SINGLE_QUOTE_CHAR_MODE = {
|
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
|
|
|
relevance: 0
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const TYPE_NAME = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'type',
|
|
|
|
begin: '\\b_?[A-Z][\\w]*',
|
|
|
|
relevance: 0
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const PRIMED_NAME = {
|
|
|
|
begin: hljs.IDENT_RE + '\'',
|
|
|
|
relevance: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
const NUMBER_MODE = {
|
|
|
|
className: 'number',
|
|
|
|
begin: '(-?)(\\b0[xX][a-fA-F0-9]+|\\b0[bB][01]+|(\\b\\d+(_\\d+)?(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)',
|
|
|
|
relevance: 0
|
2023-12-18 13:12:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `FUNCTION` and `CLASS` modes were intentionally removed to simplify
|
|
|
|
* highlighting and fix cases like
|
|
|
|
* ```
|
|
|
|
* interface Iterator[A: A]
|
|
|
|
* fun has_next(): Bool
|
|
|
|
* fun next(): A?
|
|
|
|
* ```
|
|
|
|
* where it is valid to have a function head without a body
|
|
|
|
*/
|
|
|
|
|
|
|
|
return {
|
2024-01-16 21:26:16 +08:00
|
|
|
name: 'Pony',
|
2023-12-18 13:12:25 +08:00
|
|
|
keywords: KEYWORDS,
|
|
|
|
contains: [
|
|
|
|
TYPE_NAME,
|
|
|
|
TRIPLE_QUOTE_STRING_MODE,
|
|
|
|
QUOTE_STRING_MODE,
|
|
|
|
SINGLE_QUOTE_CHAR_MODE,
|
|
|
|
PRIMED_NAME,
|
2024-01-16 21:26:16 +08:00
|
|
|
NUMBER_MODE,
|
2023-12-18 13:12:25 +08:00
|
|
|
hljs.C_LINE_COMMENT_MODE,
|
|
|
|
hljs.C_BLOCK_COMMENT_MODE
|
|
|
|
]
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = pony;
|