main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | /*
|
---|
| 2 | Language: Prolog
|
---|
| 3 | Description: Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics.
|
---|
| 4 | Author: Raivo Laanemets <raivo@infdot.com>
|
---|
| 5 | Website: https://en.wikipedia.org/wiki/Prolog
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | function prolog(hljs) {
|
---|
| 9 | const ATOM = {
|
---|
| 10 |
|
---|
| 11 | begin: /[a-z][A-Za-z0-9_]*/,
|
---|
| 12 | relevance: 0
|
---|
| 13 | };
|
---|
| 14 |
|
---|
| 15 | const VAR = {
|
---|
| 16 |
|
---|
| 17 | className: 'symbol',
|
---|
| 18 | variants: [
|
---|
| 19 | {
|
---|
| 20 | begin: /[A-Z][a-zA-Z0-9_]*/
|
---|
| 21 | },
|
---|
| 22 | {
|
---|
| 23 | begin: /_[A-Za-z0-9_]*/
|
---|
| 24 | }
|
---|
| 25 | ],
|
---|
| 26 | relevance: 0
|
---|
| 27 | };
|
---|
| 28 |
|
---|
| 29 | const PARENTED = {
|
---|
| 30 |
|
---|
| 31 | begin: /\(/,
|
---|
| 32 | end: /\)/,
|
---|
| 33 | relevance: 0
|
---|
| 34 | };
|
---|
| 35 |
|
---|
| 36 | const LIST = {
|
---|
| 37 |
|
---|
| 38 | begin: /\[/,
|
---|
| 39 | end: /\]/
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | const LINE_COMMENT = {
|
---|
| 43 |
|
---|
| 44 | className: 'comment',
|
---|
| 45 | begin: /%/,
|
---|
| 46 | end: /$/,
|
---|
| 47 | contains: [ hljs.PHRASAL_WORDS_MODE ]
|
---|
| 48 | };
|
---|
| 49 |
|
---|
| 50 | const BACKTICK_STRING = {
|
---|
| 51 |
|
---|
| 52 | className: 'string',
|
---|
| 53 | begin: /`/,
|
---|
| 54 | end: /`/,
|
---|
| 55 | contains: [ hljs.BACKSLASH_ESCAPE ]
|
---|
| 56 | };
|
---|
| 57 |
|
---|
| 58 | const CHAR_CODE = {
|
---|
| 59 | className: 'string', // 0'a etc.
|
---|
| 60 | begin: /0'(\\'|.)/
|
---|
| 61 | };
|
---|
| 62 |
|
---|
| 63 | const SPACE_CODE = {
|
---|
| 64 | className: 'string',
|
---|
| 65 | begin: /0'\\s/ // 0'\s
|
---|
| 66 | };
|
---|
| 67 |
|
---|
| 68 | const PRED_OP = { // relevance booster
|
---|
| 69 | begin: /:-/
|
---|
| 70 | };
|
---|
| 71 |
|
---|
| 72 | const inner = [
|
---|
| 73 |
|
---|
| 74 | ATOM,
|
---|
| 75 | VAR,
|
---|
| 76 | PARENTED,
|
---|
| 77 | PRED_OP,
|
---|
| 78 | LIST,
|
---|
| 79 | LINE_COMMENT,
|
---|
| 80 | hljs.C_BLOCK_COMMENT_MODE,
|
---|
| 81 | hljs.QUOTE_STRING_MODE,
|
---|
| 82 | hljs.APOS_STRING_MODE,
|
---|
| 83 | BACKTICK_STRING,
|
---|
| 84 | CHAR_CODE,
|
---|
| 85 | SPACE_CODE,
|
---|
| 86 | hljs.C_NUMBER_MODE
|
---|
| 87 | ];
|
---|
| 88 |
|
---|
| 89 | PARENTED.contains = inner;
|
---|
| 90 | LIST.contains = inner;
|
---|
| 91 |
|
---|
| 92 | return {
|
---|
| 93 | name: 'Prolog',
|
---|
| 94 | contains: inner.concat([
|
---|
| 95 | { // relevance booster
|
---|
| 96 | begin: /\.$/
|
---|
| 97 | }
|
---|
| 98 | ])
|
---|
| 99 | };
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | module.exports = prolog;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.