[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = pascaligo
|
---|
| 4 | pascaligo.displayName = 'pascaligo'
|
---|
| 5 | pascaligo.aliases = []
|
---|
| 6 | function pascaligo(Prism) {
|
---|
| 7 | ;(function (Prism) {
|
---|
| 8 | // Pascaligo is a layer 2 smart contract language for the tezos blockchain
|
---|
| 9 | var braces = /\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\)/.source
|
---|
| 10 | var type = /(?:\b\w+(?:<braces>)?|<braces>)/.source.replace(
|
---|
| 11 | /<braces>/g,
|
---|
| 12 | function () {
|
---|
| 13 | return braces
|
---|
| 14 | }
|
---|
| 15 | )
|
---|
| 16 | var pascaligo = (Prism.languages.pascaligo = {
|
---|
| 17 | comment: /\(\*[\s\S]+?\*\)|\/\/.*/,
|
---|
| 18 | string: {
|
---|
| 19 | pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1|\^[a-z]/i,
|
---|
| 20 | greedy: true
|
---|
| 21 | },
|
---|
| 22 | 'class-name': [
|
---|
| 23 | {
|
---|
| 24 | pattern: RegExp(
|
---|
| 25 | /(\btype\s+\w+\s+is\s+)<type>/.source.replace(
|
---|
| 26 | /<type>/g,
|
---|
| 27 | function () {
|
---|
| 28 | return type
|
---|
| 29 | }
|
---|
| 30 | ),
|
---|
| 31 | 'i'
|
---|
| 32 | ),
|
---|
| 33 | lookbehind: true,
|
---|
| 34 | inside: null // see below
|
---|
| 35 | },
|
---|
| 36 | {
|
---|
| 37 | pattern: RegExp(
|
---|
| 38 | /<type>(?=\s+is\b)/.source.replace(/<type>/g, function () {
|
---|
| 39 | return type
|
---|
| 40 | }),
|
---|
| 41 | 'i'
|
---|
| 42 | ),
|
---|
| 43 | inside: null // see below
|
---|
| 44 | },
|
---|
| 45 | {
|
---|
| 46 | pattern: RegExp(
|
---|
| 47 | /(:\s*)<type>/.source.replace(/<type>/g, function () {
|
---|
| 48 | return type
|
---|
| 49 | })
|
---|
| 50 | ),
|
---|
| 51 | lookbehind: true,
|
---|
| 52 | inside: null // see below
|
---|
| 53 | }
|
---|
| 54 | ],
|
---|
| 55 | keyword: {
|
---|
| 56 | pattern:
|
---|
| 57 | /(^|[^&])\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,
|
---|
| 58 | lookbehind: true
|
---|
| 59 | },
|
---|
| 60 | boolean: {
|
---|
| 61 | pattern: /(^|[^&])\b(?:False|True)\b/i,
|
---|
| 62 | lookbehind: true
|
---|
| 63 | },
|
---|
| 64 | builtin: {
|
---|
| 65 | pattern: /(^|[^&])\b(?:bool|int|list|map|nat|record|string|unit)\b/i,
|
---|
| 66 | lookbehind: true
|
---|
| 67 | },
|
---|
| 68 | function: /\b\w+(?=\s*\()/,
|
---|
| 69 | number: [
|
---|
| 70 | // Hexadecimal, octal and binary
|
---|
| 71 | /%[01]+|&[0-7]+|\$[a-f\d]+/i, // Decimal
|
---|
| 72 | /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?(?:mtz|n)?/i
|
---|
| 73 | ],
|
---|
| 74 | operator:
|
---|
| 75 | /->|=\/=|\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=|]|\b(?:and|mod|or)\b/,
|
---|
| 76 | punctuation: /\(\.|\.\)|[()\[\]:;,.{}]/
|
---|
| 77 | })
|
---|
| 78 | var classNameInside = [
|
---|
| 79 | 'comment',
|
---|
| 80 | 'keyword',
|
---|
| 81 | 'builtin',
|
---|
| 82 | 'operator',
|
---|
| 83 | 'punctuation'
|
---|
| 84 | ].reduce(function (accum, key) {
|
---|
| 85 | accum[key] = pascaligo[key]
|
---|
| 86 | return accum
|
---|
| 87 | }, {})
|
---|
| 88 | pascaligo['class-name'].forEach(function (p) {
|
---|
| 89 | p.inside = classNameInside
|
---|
| 90 | })
|
---|
| 91 | })(Prism)
|
---|
| 92 | }
|
---|