[d24f17c] | 1 | /*
|
---|
| 2 | Language: Pony
|
---|
| 3 | Author: Joe Eli McIlvain <joe.eli.mac@gmail.com>
|
---|
| 4 | Description: Pony is an open-source, object-oriented, actor-model,
|
---|
| 5 | capabilities-secure, high performance programming language.
|
---|
| 6 | Website: https://www.ponylang.io
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | function pony(hljs) {
|
---|
| 10 | const KEYWORDS = {
|
---|
| 11 | keyword:
|
---|
| 12 | 'actor addressof and as be break class compile_error compile_intrinsic ' +
|
---|
| 13 | 'consume continue delegate digestof do else elseif embed end error ' +
|
---|
| 14 | 'for fun if ifdef in interface is isnt lambda let match new not object ' +
|
---|
| 15 | 'or primitive recover repeat return struct then trait try type until ' +
|
---|
| 16 | 'use var where while with xor',
|
---|
| 17 | meta:
|
---|
| 18 | 'iso val tag trn box ref',
|
---|
| 19 | literal:
|
---|
| 20 | 'this false true'
|
---|
| 21 | };
|
---|
| 22 |
|
---|
| 23 | const TRIPLE_QUOTE_STRING_MODE = {
|
---|
| 24 | className: 'string',
|
---|
| 25 | begin: '"""',
|
---|
| 26 | end: '"""',
|
---|
| 27 | relevance: 10
|
---|
| 28 | };
|
---|
| 29 |
|
---|
| 30 | const QUOTE_STRING_MODE = {
|
---|
| 31 | className: 'string',
|
---|
| 32 | begin: '"',
|
---|
| 33 | end: '"',
|
---|
| 34 | contains: [ hljs.BACKSLASH_ESCAPE ]
|
---|
| 35 | };
|
---|
| 36 |
|
---|
| 37 | const SINGLE_QUOTE_CHAR_MODE = {
|
---|
| 38 | className: 'string',
|
---|
| 39 | begin: '\'',
|
---|
| 40 | end: '\'',
|
---|
| 41 | contains: [ hljs.BACKSLASH_ESCAPE ],
|
---|
| 42 | relevance: 0
|
---|
| 43 | };
|
---|
| 44 |
|
---|
| 45 | const TYPE_NAME = {
|
---|
| 46 | className: 'type',
|
---|
| 47 | begin: '\\b_?[A-Z][\\w]*',
|
---|
| 48 | relevance: 0
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | const PRIMED_NAME = {
|
---|
| 52 | begin: hljs.IDENT_RE + '\'',
|
---|
| 53 | relevance: 0
|
---|
| 54 | };
|
---|
| 55 |
|
---|
| 56 | const NUMBER_MODE = {
|
---|
| 57 | className: 'number',
|
---|
| 58 | begin: '(-?)(\\b0[xX][a-fA-F0-9]+|\\b0[bB][01]+|(\\b\\d+(_\\d+)?(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)',
|
---|
| 59 | relevance: 0
|
---|
| 60 | };
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
| 63 | * The `FUNCTION` and `CLASS` modes were intentionally removed to simplify
|
---|
| 64 | * highlighting and fix cases like
|
---|
| 65 | * ```
|
---|
| 66 | * interface Iterator[A: A]
|
---|
| 67 | * fun has_next(): Bool
|
---|
| 68 | * fun next(): A?
|
---|
| 69 | * ```
|
---|
| 70 | * where it is valid to have a function head without a body
|
---|
| 71 | */
|
---|
| 72 |
|
---|
| 73 | return {
|
---|
| 74 | name: 'Pony',
|
---|
| 75 | keywords: KEYWORDS,
|
---|
| 76 | contains: [
|
---|
| 77 | TYPE_NAME,
|
---|
| 78 | TRIPLE_QUOTE_STRING_MODE,
|
---|
| 79 | QUOTE_STRING_MODE,
|
---|
| 80 | SINGLE_QUOTE_CHAR_MODE,
|
---|
| 81 | PRIMED_NAME,
|
---|
| 82 | NUMBER_MODE,
|
---|
| 83 | hljs.C_LINE_COMMENT_MODE,
|
---|
| 84 | hljs.C_BLOCK_COMMENT_MODE
|
---|
| 85 | ]
|
---|
| 86 | };
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | module.exports = pony;
|
---|