[d24f17c] | 1 | (function (Prism) {
|
---|
| 2 |
|
---|
| 3 | // Pascaligo is a layer 2 smart contract language for the tezos blockchain
|
---|
| 4 |
|
---|
| 5 | var braces = /\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\)/.source;
|
---|
| 6 | var type = /(?:\b\w+(?:<braces>)?|<braces>)/.source.replace(/<braces>/g, function () { return braces; });
|
---|
| 7 |
|
---|
| 8 | var pascaligo = Prism.languages.pascaligo = {
|
---|
| 9 | 'comment': /\(\*[\s\S]+?\*\)|\/\/.*/,
|
---|
| 10 | 'string': {
|
---|
| 11 | pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1|\^[a-z]/i,
|
---|
| 12 | greedy: true
|
---|
| 13 | },
|
---|
| 14 | 'class-name': [
|
---|
| 15 | {
|
---|
| 16 | pattern: RegExp(/(\btype\s+\w+\s+is\s+)<type>/.source.replace(/<type>/g, function () { return type; }), 'i'),
|
---|
| 17 | lookbehind: true,
|
---|
| 18 | inside: null // see below
|
---|
| 19 | },
|
---|
| 20 | {
|
---|
| 21 | pattern: RegExp(/<type>(?=\s+is\b)/.source.replace(/<type>/g, function () { return type; }), 'i'),
|
---|
| 22 | inside: null // see below
|
---|
| 23 | },
|
---|
| 24 | {
|
---|
| 25 | pattern: RegExp(/(:\s*)<type>/.source.replace(/<type>/g, function () { return type; })),
|
---|
| 26 | lookbehind: true,
|
---|
| 27 | inside: null // see below
|
---|
| 28 | }
|
---|
| 29 | ],
|
---|
| 30 | 'keyword': {
|
---|
| 31 | pattern: /(^|[^&])\b(?:begin|block|case|const|else|end|fail|for|from|function|if|is|nil|of|remove|return|skip|then|type|var|while|with)\b/i,
|
---|
| 32 | lookbehind: true
|
---|
| 33 | },
|
---|
| 34 | 'boolean': {
|
---|
| 35 | pattern: /(^|[^&])\b(?:False|True)\b/i,
|
---|
| 36 | lookbehind: true
|
---|
| 37 | },
|
---|
| 38 | 'builtin': {
|
---|
| 39 | pattern: /(^|[^&])\b(?:bool|int|list|map|nat|record|string|unit)\b/i,
|
---|
| 40 | lookbehind: true
|
---|
| 41 | },
|
---|
| 42 | 'function': /\b\w+(?=\s*\()/,
|
---|
| 43 | 'number': [
|
---|
| 44 | // Hexadecimal, octal and binary
|
---|
| 45 | /%[01]+|&[0-7]+|\$[a-f\d]+/i,
|
---|
| 46 | // Decimal
|
---|
| 47 | /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?(?:mtz|n)?/i
|
---|
| 48 | ],
|
---|
| 49 | 'operator': /->|=\/=|\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=|]|\b(?:and|mod|or)\b/,
|
---|
| 50 | 'punctuation': /\(\.|\.\)|[()\[\]:;,.{}]/
|
---|
| 51 | };
|
---|
| 52 |
|
---|
| 53 | var classNameInside = ['comment', 'keyword', 'builtin', 'operator', 'punctuation'].reduce(function (accum, key) {
|
---|
| 54 | accum[key] = pascaligo[key];
|
---|
| 55 | return accum;
|
---|
| 56 | }, {});
|
---|
| 57 |
|
---|
| 58 | pascaligo['class-name'].forEach(function (p) {
|
---|
| 59 | p.inside = classNameInside;
|
---|
| 60 | });
|
---|
| 61 |
|
---|
| 62 | }(Prism));
|
---|