-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
mata.js
56 lines (54 loc) · 1.75 KB
/
mata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-nocheck
mata.displayName = 'mata'
mata.aliases = []
/** @type {import('../core.js').Syntax} */
export default function mata(Prism) {
// https://www.stata.com/manuals/m.pdf
;(function (Prism) {
var orgType = /\b(?:(?:col|row)?vector|matrix|scalar)\b/.source
var type =
/\bvoid\b|<org>|\b(?:complex|numeric|pointer(?:\s*\([^()]*\))?|real|string|(?:class|struct)\s+\w+|transmorphic)(?:\s*<org>)?/.source.replace(
/<org>/g,
orgType
)
Prism.languages.mata = {
comment: {
pattern:
/\/\/.*|\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\//,
greedy: true
},
string: {
pattern: /"[^"\r\n]*"|[‘`']".*?"[’`']/,
greedy: true
},
'class-name': {
pattern: /(\b(?:class|extends|struct)\s+)\w+(?=\s*(?:\{|\bextends\b))/,
lookbehind: true
},
type: {
pattern: RegExp(type),
alias: 'class-name',
inside: {
punctuation: /[()]/,
keyword: /\b(?:class|function|struct|void)\b/
}
},
keyword:
/\b(?:break|class|continue|do|else|end|extends|external|final|for|function|goto|if|pragma|private|protected|public|return|static|struct|unset|unused|version|virtual|while)\b/,
constant: /\bNULL\b/,
number: {
pattern:
/(^|[^\w.])(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|\d[a-f0-9]*(?:\.[a-f0-9]+)?x[+-]?\d+)i?(?![\w.])/i,
lookbehind: true
},
missing: {
pattern: /(^|[^\w.])(?:\.[a-z]?)(?![\w.])/,
lookbehind: true,
alias: 'symbol'
},
function: /\b[a-z_]\w*(?=\s*\()/i,
operator: /\.\.|\+\+|--|&&|\|\||:?(?:[!=<>]=|[+\-*/^<>&|:])|[!?=\\#’`']/,
punctuation: /[()[\]{},;.]/
}
})(Prism)
}